Skip to content

Commit 3d336c0

Browse files
committed
[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
1 parent 01abe68 commit 3d336c0

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

Classes/Updates/ContainerDeleteChildrenWithWrongPid.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use B13\Container\Integrity\Error\WrongPidError;
1616
use B13\Container\Integrity\Integrity;
1717
use B13\Container\Integrity\IntegrityFix;
18+
use Symfony\Component\Console\Output\OutputInterface;
1819
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
1920
use TYPO3\CMS\Core\Core\Bootstrap;
2021
use TYPO3\CMS\Core\Core\Environment;
@@ -24,12 +25,13 @@
2425
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
2526
use TYPO3\CMS\Core\Utility\GeneralUtility;
2627
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
28+
use TYPO3\CMS\Install\Updates\ChattyInterface;
2729
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
2830
use TYPO3\CMS\Install\Updates\RepeatableInterface;
2931
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
3032

3133
#[UpgradeWizard('container_containerDeleteChildrenWithWrongPid')]
32-
class ContainerDeleteChildrenWithWrongPid implements UpgradeWizardInterface, RepeatableInterface
34+
class ContainerDeleteChildrenWithWrongPid implements UpgradeWizardInterface, RepeatableInterface, ChattyInterface
3335
{
3436
public const IDENTIFIER = 'container_deleteChildrenWithWrongPid';
3537

@@ -43,12 +45,19 @@ class ContainerDeleteChildrenWithWrongPid implements UpgradeWizardInterface, Rep
4345
*/
4446
protected $integrityFix;
4547

48+
private OutputInterface $output;
49+
4650
public function __construct(Integrity $integrity, IntegrityFix $integrityFix)
4751
{
4852
$this->integrity = $integrity;
4953
$this->integrityFix = $integrityFix;
5054
}
5155

56+
public function setOutput(OutputInterface $output): void
57+
{
58+
$this->output = $output;
59+
}
60+
5261
public function getIdentifier(): string
5362
{
5463
return self::IDENTIFIER;
@@ -92,6 +101,12 @@ public function executeUpdate(): bool
92101
} else {
93102
Bootstrap::initializeBackendUser();
94103
}
104+
if ($GLOBALS['BE_USER'] === null || $GLOBALS['BE_USER']->user === null) {
105+
$this->output->writeln(
106+
'<error>EXT:container Migrations need a valid Backend User, Login to the Backend to execute Wizard, or use CLI</error>'
107+
);
108+
return false;
109+
}
95110
Bootstrap::initializeBackendAuthentication();
96111
$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromUserPreferences($GLOBALS['BE_USER']);
97112
}

Classes/Updates/ContainerMigrateSorting.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
use B13\Container\Integrity\Sorting;
16+
use Symfony\Component\Console\Output\OutputInterface;
1617
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
1718
use TYPO3\CMS\Core\Core\Bootstrap;
1819
use TYPO3\CMS\Core\Core\Environment;
@@ -22,15 +23,18 @@
2223
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
2324
use TYPO3\CMS\Core\Utility\GeneralUtility;
2425
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
26+
use TYPO3\CMS\Install\Updates\ChattyInterface;
2527
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
2628
use TYPO3\CMS\Install\Updates\RepeatableInterface;
2729
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
2830

2931
#[UpgradeWizard('container_containerMigrateSorting')]
30-
class ContainerMigrateSorting implements UpgradeWizardInterface, RepeatableInterface
32+
class ContainerMigrateSorting implements UpgradeWizardInterface, RepeatableInterface, ChattyInterface
3133
{
3234
public const IDENTIFIER = 'container_migratesorting';
3335

36+
private OutputInterface $output;
37+
3438
/**
3539
* @var Sorting
3640
*/
@@ -41,6 +45,11 @@ public function __construct(Sorting $sorting)
4145
$this->sorting = $sorting;
4246
}
4347

48+
public function setOutput(OutputInterface $output): void
49+
{
50+
$this->output = $output;
51+
}
52+
4453
public function getIdentifier(): string
4554
{
4655
return self::IDENTIFIER;
@@ -79,6 +88,12 @@ public function executeUpdate(): bool
7988
} else {
8089
Bootstrap::initializeBackendUser();
8190
}
91+
if ($GLOBALS['BE_USER'] === null || $GLOBALS['BE_USER']->user === null) {
92+
$this->output->writeln(
93+
'<error>EXT:container Migrations need a valid Backend User, Login to the Backend to execute Wizard, or use CLI</error>'
94+
);
95+
return false;
96+
}
8297
Bootstrap::initializeBackendAuthentication();
8398
$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromUserPreferences($GLOBALS['BE_USER']);
8499
}

0 commit comments

Comments
 (0)