Skip to content

Commit c5e796d

Browse files
authored
[TASK] Allow shipping upgrade wizards w/o requiring EXT:install (#6269)
* [TASK] Allow shipping upgrade wizards w/o requiring EXT:install Resolves: TYPO3-Documentation/Changelog-To-Doc#1496 Releases: main * [TASK] Allow shipping upgrade wizards w/o requiring EXT:install Resolves: TYPO3-Documentation/Changelog-To-Doc#1496 Releases: main * [FEATURE] Add attribute AsNonSchedulableCommand for "schedulable" Resolves: TYPO3-Documentation/Changelog-To-Doc#1470 Releases: main
1 parent 57b910d commit c5e796d

File tree

4 files changed

+52
-28
lines changed

4 files changed

+52
-28
lines changed

Documentation/ExtensionArchitecture/HowTo/UpdateExtensions/UpdateWizards/Concept.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ Each wizard is able to check pre-conditions to prevent execution, if nothing has
2626
to be updated. The wizard can log information and executed SQL statements, that
2727
can be displayed after execution.
2828

29-
Best practice
30-
=============
29+
.. rubric:: Best practice
3130

3231
Each extension can provide as many upgrade wizards as necessary. Each wizard
3332
should perform exactly one specific update.
3433

35-
Examples
36-
========
34+
.. rubric:: Examples
3735

38-
The TYPO3 Core itself provides upgrade wizards inside
39-
:t3src:`install/Classes/Updates/`.
36+
See `Examples for common upgrade wizards <https://docs.typo3.org/permalink/t3coreapi:upgrade-wizard-examples>`_.

Documentation/ExtensionArchitecture/HowTo/UpdateExtensions/UpdateWizards/Creation.rst

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111
Implementing an upgrade wizard
1212
==============================
1313

14-
.. versionchanged:: 13.0
15-
The registration via
16-
:php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']`
17-
in :file:`ext_localconf.php` was removed in TYPO3 v13.
14+
.. deprecated:: 14.0
15+
The attribute :php:`\TYPO3\CMS\Install\Attribute\UpgradeWizard` has been
16+
deprecated in favour of :php:`\TYPO3\CMS\Core\Attribute\UpgradeWizard`.
17+
18+
The interfaces and classes used for upgrade wizards have been moved from
19+
namespace `\TYPO3\CMS\Install\Updates` to `\TYPO3\CMS\Core\Upgrades`.
20+
21+
Using the old locations is deprecated in v14 but can be used to provide
22+
compatibility with both TYPO3 v13 and v14.
1823

1924
To create an upgrade wizard you have to add a class which implements the
2025
:ref:`UpgradeWizardInterface <upgrade-wizards-interface>`.
@@ -35,12 +40,20 @@ The class *may* implement other interfaces (optional):
3540
UpgradeWizardInterface
3641
======================
3742

43+
.. deprecated:: 14.0
44+
:php:`\TYPO3\CMS\Install\Updates\UpgradeWizardInterface` has been deprecated,
45+
implement :php:`\TYPO3\CMS\Core\Upgrades\UpgradeWizardInterface` once dropping
46+
TYPO3 v13 support.
47+
48+
The attribute :php:`\TYPO3\CMS\Install\Attribute\UpgradeWizard` has been
49+
deprecated in favour of :php:`\TYPO3\CMS\Core\Attribute\UpgradeWizard`.
50+
3851
Each upgrade wizard consists of a single PHP file containing a single PHP class.
39-
This class has to implement :php:`TYPO3\CMS\Install\Updates\UpgradeWizardInterface`
52+
This class has to implement :php:`\TYPO3\CMS\Core\Upgrades\UpgradeWizardInterface`
4053
and its methods.
4154

4255
The registration of an upgrade wizard is done directly in the class by adding
43-
the class attribute :php:`\TYPO3\CMS\Install\Attribute\UpgradeWizard`. The
56+
the class attribute :php:`\TYPO3\CMS\Core\Attribute\UpgradeWizard`. The
4457
:ref:`unique identifier <upgrade-wizards-identifier>` is passed as an argument.
4558

4659
.. literalinclude:: _ExampleUpgradeWizard.php
@@ -68,16 +81,16 @@ Method :php:`getPrerequisites()`
6881
can define dependencies before it can be performed. Currently, the following
6982
prerequisites exist:
7083

71-
* `DatabaseUpdatedPrerequisite`:
84+
* :php-short:`\TYPO3\CMS\Core\Upgrades\DatabaseUpdatedPrerequisite`:
7285
Ensures that the database table fields are up-to-date.
73-
* `ReferenceIndexUpdatedPrerequisite`:
86+
* :php-short:`\TYPO3\CMS\Core\Upgrades\ReferenceIndexUpdatedPrerequisite`:
7487
The reference index needs to be up-to-date.
7588

7689
.. code-block:: php
7790
:caption: EXT:my_extension/Classes/Upgrades/ExampleUpgradeWizard.php
7891
79-
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
80-
use TYPO3\CMS\Install\Updates\ReferenceIndexUpdatedPrerequisite;
92+
use TYPO3\CMS\Core\Upgrades\DatabaseUpdatedPrerequisite;
93+
use TYPO3\CMS\Core\Upgrades\ReferenceIndexUpdatedPrerequisite;
8194
8295
/**
8396
* @return string[]
@@ -107,7 +120,6 @@ command:
107120

108121
.. include:: /_includes/CliCacheFlush.rst.txt
109122

110-
111123
.. index:: Upgrade wizards; Identifier
112124
.. _upgrade-wizards-identifier:
113125

@@ -158,12 +170,17 @@ Some examples:
158170
Marking wizard as done
159171
======================
160172

173+
.. deprecated:: 14.0
174+
:php:`\TYPO3\CMS\Install\Updates\RepeatableInterface` has been deprecated,
175+
implement :php:`\TYPO3\CMS\Core\Upgrades\RepeatableInterface` once dropping
176+
TYPO3 v13 support.
177+
161178
As soon as the wizard has completely finished, for example, it detected that no
162179
upgrade is necessary anymore, the wizard is marked as done and will not be
163180
checked anymore.
164181

165182
To force TYPO3 to check the wizard every time, the interface
166-
:t3src:`install/Classes/Updates/RepeatableInterface.php` has to be implemented.
183+
:php:`\TYPO3\CMS\Core\Upgrades\RepeatableInterface` has to be implemented.
167184
This interface works as a marker and does not force any methods to be
168185
implemented.
169186

@@ -175,23 +192,24 @@ implemented.
175192
Generating output
176193
=================
177194

178-
The :php:`ChattyInterface` can be implemented for wizards which should generate
179-
output. :t3src:`install/Classes/Updates/ChattyInterface.php` uses the Symfony
180-
interface `OutputInterface`_.
181-
182-
.. _OutputInterface: https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Console/Output/OutputInterface.php
195+
The :php:`\TYPO3\CMS\Install\Updates\ChattyInterface` can be implemented for
196+
wizards which should generate
197+
output. It uses the Symfony interface
198+
:php:`\Symfony\Component\Console\Output\OutputInterface`.
183199

184200
Classes using this interface must implement the following method:
185201

186202
.. code-block:: php
187203
:caption: vendor/symfony/console/Output/OutputInterface.php
188204
205+
use Symfony\Component\Console\Output\OutputInterface;
206+
189207
/**
190208
* Setter injection for output into upgrade wizards
191209
*/
192210
public function setOutput(OutputInterface $output): void;
193211
194-
The class :t3src:`install/Classes/Updates/DatabaseUpdatedPrerequisite.php`
212+
The class :php:`\TYPO3\CMS\Core\Upgrades\DatabaseUpdatedPrerequisite`
195213
implements this interface. We are showing a simplified example here, based on
196214
this class:
197215

@@ -200,6 +218,8 @@ this class:
200218
:emphasize-lines: 8,10-13,20
201219
202220
use Symfony\Component\Console\Output\OutputInterface;
221+
use TYPO3\CMS\Core\Upgrades\DatabaseUpdatedPrerequisite;
222+
use TYPO3\CMS\Core\Upgrades\ChattyInterface;
203223
204224
class DatabaseUpdatedPrerequisite implements PrerequisiteInterface, ChattyInterface
205225
{
@@ -234,6 +254,13 @@ this class:
234254
Executing the wizard
235255
====================
236256

257+
.. versionchanged:: 14.0
258+
The upgrade wizards can always be run via the console command
259+
`typo3 upgrade:run`.
260+
261+
The backend module :guilabel:`System > Upgrade` can only be used if
262+
:composer:`typo3/cms-install` is installed.
263+
237264
Wizards are listed in the backend module :guilabel:`System > Upgrade` and
238265
the card :guilabel:`Upgrade Wizard`. The registered wizard should be shown
239266
there, as long as it is not done.

Documentation/ExtensionArchitecture/HowTo/UpdateExtensions/UpdateWizards/_ExampleUpgradeWizard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace MyVendor\MyExtension\Upgrades;
66

7-
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
8-
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
7+
use TYPO3\CMS\Core\Attribute\UpgradeWizard;
8+
use TYPO3\CMS\Core\Upgrades\UpgradeWizardInterface;
99

1010
#[UpgradeWizard('myExtension_exampleUpgradeWizard')]
1111
final class ExampleUpgradeWizard implements UpgradeWizardInterface

Documentation/ExtensionArchitecture/HowTo/UpdateExtensions/UpdateWizards/_SwitchableControllerActionUpgradeWizard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace MyVendor\MyExtension\Upgrades;
66

7+
use TYPO3\CMS\Core\Attribute\UpgradeWizard;
78
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
89
use TYPO3\CMS\Core\Database\ConnectionPool;
9-
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
10-
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
10+
use TYPO3\CMS\Core\Upgrades\UpgradeWizardInterface;
1111

1212
#[UpgradeWizard('myExtension_switchableControllerActionUpgradeWizard')]
1313
final class SwitchableControllerActionUpgradeWizard implements UpgradeWizardInterface

0 commit comments

Comments
 (0)