From 3d336c05727fc8fe7774ca91183504c166d89c25 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Thu, 22 Jan 2026 17:03:37 +0100 Subject: [PATCH] [BUGFIX] prevent PHP Warning in install tool this change disables containers upgrade wizards in install tool, if no backend user is logged in. containers upgrade wizards requires a backend user because they use TYPO3 DataHandler You can run the wizards when logged in, or in the TYPO3 Upgrade Module or per CLI as usual Fixes: #640 --- .../ContainerDeleteChildrenWithWrongPid.php | 17 ++++++++++++++++- Classes/Updates/ContainerMigrateSorting.php | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Classes/Updates/ContainerDeleteChildrenWithWrongPid.php b/Classes/Updates/ContainerDeleteChildrenWithWrongPid.php index 55fb30e1..969e7e0b 100644 --- a/Classes/Updates/ContainerDeleteChildrenWithWrongPid.php +++ b/Classes/Updates/ContainerDeleteChildrenWithWrongPid.php @@ -15,6 +15,7 @@ use B13\Container\Integrity\Error\WrongPidError; use B13\Container\Integrity\Integrity; use B13\Container\Integrity\IntegrityFix; +use Symfony\Component\Console\Output\OutputInterface; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Core\Bootstrap; use TYPO3\CMS\Core\Core\Environment; @@ -24,12 +25,13 @@ use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Install\Attribute\UpgradeWizard; +use TYPO3\CMS\Install\Updates\ChattyInterface; 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 +class ContainerDeleteChildrenWithWrongPid implements UpgradeWizardInterface, RepeatableInterface, ChattyInterface { public const IDENTIFIER = 'container_deleteChildrenWithWrongPid'; @@ -43,12 +45,19 @@ class ContainerDeleteChildrenWithWrongPid implements UpgradeWizardInterface, Rep */ protected $integrityFix; + private OutputInterface $output; + public function __construct(Integrity $integrity, IntegrityFix $integrityFix) { $this->integrity = $integrity; $this->integrityFix = $integrityFix; } + public function setOutput(OutputInterface $output): void + { + $this->output = $output; + } + public function getIdentifier(): string { return self::IDENTIFIER; @@ -92,6 +101,12 @@ public function executeUpdate(): bool } else { Bootstrap::initializeBackendUser(); } + if ($GLOBALS['BE_USER'] === null || $GLOBALS['BE_USER']->user === null) { + $this->output->writeln( + 'EXT:container Migrations need a valid Backend User, Login to the Backend to execute Wizard, or use CLI' + ); + return false; + } Bootstrap::initializeBackendAuthentication(); $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromUserPreferences($GLOBALS['BE_USER']); } diff --git a/Classes/Updates/ContainerMigrateSorting.php b/Classes/Updates/ContainerMigrateSorting.php index 882a37e1..652b0404 100644 --- a/Classes/Updates/ContainerMigrateSorting.php +++ b/Classes/Updates/ContainerMigrateSorting.php @@ -13,6 +13,7 @@ */ use B13\Container\Integrity\Sorting; +use Symfony\Component\Console\Output\OutputInterface; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Core\Bootstrap; use TYPO3\CMS\Core\Core\Environment; @@ -22,15 +23,18 @@ use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Install\Attribute\UpgradeWizard; +use TYPO3\CMS\Install\Updates\ChattyInterface; 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 +class ContainerMigrateSorting implements UpgradeWizardInterface, RepeatableInterface, ChattyInterface { public const IDENTIFIER = 'container_migratesorting'; + private OutputInterface $output; + /** * @var Sorting */ @@ -41,6 +45,11 @@ public function __construct(Sorting $sorting) $this->sorting = $sorting; } + public function setOutput(OutputInterface $output): void + { + $this->output = $output; + } + public function getIdentifier(): string { return self::IDENTIFIER; @@ -79,6 +88,12 @@ public function executeUpdate(): bool } else { Bootstrap::initializeBackendUser(); } + if ($GLOBALS['BE_USER'] === null || $GLOBALS['BE_USER']->user === null) { + $this->output->writeln( + 'EXT:container Migrations need a valid Backend User, Login to the Backend to execute Wizard, or use CLI' + ); + return false; + } Bootstrap::initializeBackendAuthentication(); $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromUserPreferences($GLOBALS['BE_USER']); }