Skip to content

Commit

Permalink
[BUGFIX] upgrade wizards
Browse files Browse the repository at this point in the history
* do not register upgrade wizards if EXT:install is not installed
* use PHP Attributes for upgrade wizards
* adapt phpstan

Fixes. b13#525
  • Loading branch information
achimfritz committed Oct 2, 2024
1 parent be8abab commit 29c2f39
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,11 @@ case ${TEST_SUITE} in
SUITE_EXIT_CODE=$?
;;
phpstan)
COMMAND=(php -dxdebug.mode=off .Build/bin/phpstan analyse -c Build/phpstan${TYPO3}.neon --no-progress --no-interaction --memory-limit 4G "$@")
if [ ${PHP_VERSION} == "7.4" ]; then
COMMAND=(php -dxdebug.mode=off .Build/bin/phpstan analyse -c Build/phpstan${TYPO3}-7.4.neon --no-progress --no-interaction --memory-limit 4G "$@")
else
COMMAND=(php -dxdebug.mode=off .Build/bin/phpstan analyse -c Build/phpstan${TYPO3}.neon --no-progress --no-interaction --memory-limit 4G "$@")
fi
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name phpstan-${SUFFIX} ${IMAGE_PHP} "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
Expand Down
61 changes: 61 additions & 0 deletions Build/phpstan-baseline-11-7.4.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
parameters:
ignoreErrors:
-
message: "#^Method TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\:\\:getLanguageOverlay\\(\\) invoked with 3 parameters, 2 required\\.$#"
count: 1
path: ../Classes/Domain/Factory/PageView/Frontend/ContainerFactory.php

-
message: "#^Constant LF not found\\.$#"
count: 4
path: ../Classes/Tca/Registry.php

-
message: "#^PHPDoc tag @return has invalid value \\(\\)\\: Unexpected token \"\\\\n \\* \", expected type at offset 679$#"
count: 1
path: ../Tests/Acceptance/Support/BackendTester.php

-
message: "#^PHPDoc tag @return has invalid value \\(\\)\\: Unexpected token \"\\\\n \\* \", expected type at offset 743$#"
count: 1
path: ../Tests/Acceptance/Support/BackendTester.php

-
message: "#^PHPDoc tag @throws with type B13\\\\Container\\\\Tests\\\\Acceptance\\\\Support\\\\_generated\\\\ConfigurationException is not subtype of Throwable$#"
count: 1
path: ../Tests/Acceptance/Support/BackendTester.php

-
message: "#^PHPDoc tag @throws with type B13\\\\Container\\\\Tests\\\\Acceptance\\\\Support\\\\_generated\\\\ModuleException is not subtype of Throwable$#"
count: 1
path: ../Tests/Acceptance/Support/BackendTester.php

-
message: "#^Call to an undefined static method TYPO3\\\\TestingFramework\\\\Core\\\\Acceptance\\\\Extension\\\\BackendEnvironment\\:\\:_initialize\\(\\)\\.$#"
count: 1
path: ../Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php

-
message: "#^Call to an undefined static method TYPO3\\\\TestingFramework\\\\Core\\\\Acceptance\\\\Extension\\\\BackendEnvironment\\:\\:bootstrapTypo3Environment\\(\\)\\.$#"
count: 1
path: ../Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php

-
message: "#^Constant ORIGINAL_ROOT not found\\.$#"
count: 1
path: ../Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php

-
message: "#^Property TYPO3\\\\TestingFramework\\\\Core\\\\Acceptance\\\\Helper\\\\AbstractPageTree\\:\\:\\$tester \\(AcceptanceTester\\) does not accept B13\\\\Container\\\\Tests\\\\Acceptance\\\\Support\\\\BackendTester\\.$#"
count: 1
path: ../Tests/Acceptance/Support/PageTree.php

-
message: "#^Constant ORIGINAL_ROOT not found\\.$#"
count: 1
path: ../Tests/Functional/Datahandler/AbstractDatahandler.php

-
message: "#^Class TYPO3\\\\CMS\\\\Backend\\\\View\\\\PageLayoutContext constructor invoked with 5 parameters, 2 required\\.$#"
count: 1
path: ../Tests/Functional/Integrity/IntegrityTest.php
11 changes: 10 additions & 1 deletion Build/phpstan-baseline-11.neon
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,13 @@ parameters:
-
message: "#^Class TYPO3\\\\CMS\\\\Backend\\\\View\\\\PageLayoutContext constructor invoked with 5 parameters, 2 required\\.$#"
count: 1
path: ../Tests/Functional/Integrity/IntegrityTest.php
path: ../Tests/Functional/Integrity/IntegrityTest.php
-
message: "#^Attribute class TYPO3\\\\CMS\\\\Install\\\\Attribute\\\\UpgradeWizard does not exist\\.$#"
count: 1
path: ../Classes/Updates/ContainerDeleteChildrenWithWrongPid.php

-
message: "#^Attribute class TYPO3\\\\CMS\\\\Install\\\\Attribute\\\\UpgradeWizard does not exist\\.$#"
count: 1
path: ../Classes/Updates/ContainerMigrateSorting.php
18 changes: 18 additions & 0 deletions Build/phpstan11-7.4.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
includes:
- phpstan-baseline-11-7.4.neon

parameters:
level: 5

paths:
- %currentWorkingDirectory%/Classes
- %currentWorkingDirectory%/Tests

excludePaths:
- %currentWorkingDirectory%/Classes/Listener/ModifyNewContentElementWizardItems.php
- %currentWorkingDirectory%/Classes/Listener/ContentUsedOnPage.php
- %currentWorkingDirectory%/Tests/Unit/Listener/ContentUsedOnPageTest.php
- %currentWorkingDirectory%/Tests/Functional/Listener/ContentUsedOnPageTest.php
- %currentWorkingDirectory%/Classes/Listener/RecordSummaryForLocalization.php
- %currentWorkingDirectory%/Classes/Listener/PageTsConfig.php

2 changes: 2 additions & 0 deletions Classes/Updates/ContainerDeleteChildrenWithWrongPid.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;

#[UpgradeWizard('container_containerDeleteChildrenWithWrongPid')]
class ContainerDeleteChildrenWithWrongPid implements UpgradeWizardInterface, RepeatableInterface
{
public const IDENTIFIER = 'container_deleteChildrenWithWrongPid';
Expand Down
2 changes: 2 additions & 0 deletions Classes/Updates/ContainerMigrateSorting.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;

#[UpgradeWizard('container_containerMigrateSorting')]
class ContainerMigrateSorting implements UpgradeWizardInterface, RepeatableInterface
{
public const IDENTIFIER = 'container_migratesorting';
Expand Down
10 changes: 6 additions & 4 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']
);

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][B13\Container\Updates\ContainerMigrateSorting::IDENTIFIER]
= B13\Container\Updates\ContainerMigrateSorting::class;
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][B13\Container\Updates\ContainerDeleteChildrenWithWrongPid::IDENTIFIER]
= B13\Container\Updates\ContainerDeleteChildrenWithWrongPid::class;
if ($packageManager->isPackageActive('typo3/cms-install')) {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][B13\Container\Updates\ContainerMigrateSorting::IDENTIFIER]
= B13\Container\Updates\ContainerMigrateSorting::class;
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][B13\Container\Updates\ContainerDeleteChildrenWithWrongPid::IDENTIFIER]
= B13\Container\Updates\ContainerDeleteChildrenWithWrongPid::class;
}
});

0 comments on commit 29c2f39

Please sign in to comment.