b13 / container

A TYPO3 Extension for creating custom nested content elements
GNU General Public License v2.0
167 stars 62 forks source link

Running Upgrade Wizards with TYPO3 Console seems not to work anymore #286

Closed gilbertsoft closed 2 years ago

gilbertsoft commented 2 years ago

Looks like the commit https://github.com/b13/container/commit/944da0d19190bed39cbc85175ee73aa8eea27df8 is breaking using the TYPO3 Console to run the upgrade wizard. Can you confirm this or is it maybe a misconfiguration?

ddev exec -- typo3cms -vvv upgrade:run all

  [ InvalidArgumentException ]                                                      
  The parsedUri "http:///var/www/html/vendor/bin/typo3cms" appears to be malformed  

Exception code: 1436717322

Exception trace:
#0 ()
   vendor/typo3/cms-core/Classes/Http/Uri.php:125
#1 TYPO3\CMS\Core\Http\Uri->parseUri()
   vendor/typo3/cms-core/Classes/Http/Uri.php:111
#2 TYPO3\CMS\Core\Http\Uri->__construct()
   vendor/typo3/cms-core/Classes/Http/ServerRequestFactory.php:65
#3 TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals()
   vendor/typo3/cms-core/Classes/Authentication/AbstractUserAuthentication.php:258
#4 TYPO3\CMS\Core\Authentication\AbstractUserAuthentication->start()
   vendor/typo3/cms-core/Classes/Core/Bootstrap.php:579
#5 TYPO3\CMS\Core\Core\Bootstrap::initializeBackendUser()
   vendor/b13/container/Classes/Updates/ContainerMigrateSorting.php:64
#6 B13\Container\Updates\ContainerMigrateSorting->executeUpdate()
   vendor/helhum/typo3-console/Classes/Console/Install/Upgrade/UpgradeWizardExecutor.php:67
#7 Helhum\Typo3Console\Install\Upgrade\UpgradeWizardExecutor->executeWizard()
   vendor/helhum/typo3-console/Classes/Console/Install/Upgrade/UpgradeHandling.php:142
#8 Helhum\Typo3Console\Install\Upgrade\UpgradeHandling->runWizard()
   vendor/helhum/typo3-console/Classes/Console/Install/Upgrade/UpgradeHandling.php:111
#9 Helhum\Typo3Console\Install\Upgrade\UpgradeHandling->runWizards()
   vendor/helhum/typo3-console/Classes/Console/Command/Upgrade/UpgradeRunCommand.php:143
#10 Helhum\Typo3Console\Command\Upgrade\UpgradeRunCommand->execute()
   vendor/symfony/console/Command/Command.php:298
#11 Symfony\Component\Console\Command\Command->run()
   vendor/symfony/console/Application.php:1024
#12 Symfony\Component\Console\Application->doRunCommand()
   vendor/helhum/typo3-console/Classes/Console/Mvc/Cli/Symfony/Application.php:189
#13 Helhum\Typo3Console\Mvc\Cli\Symfony\Application->doRunCommand()
   vendor/symfony/console/Application.php:299
#14 Symfony\Component\Console\Application->doRun()
   vendor/symfony/console/Application.php:171
#15 Symfony\Component\Console\Application->run()
   vendor/helhum/typo3-console/Classes/Console/Core/Kernel.php:114
#16 Helhum\Typo3Console\Core\Kernel->handle()
   vendor/helhum/typo3-console/Scripts/typo3-console.php:18
#17 {closure}()
   vendor/helhum/typo3-console/Scripts/typo3-console.php:20
#18 require()
   vendor/helhum/typo3-console/typo3cms:3
#19 include()
   vendor/bin/typo3cms:120

upgrade:run [-y|--confirm CONFIRM] [-d|--deny DENY] [-f|--force] [--force-row-updater FORCE-ROW-UPDATER] [--] <wizardIdentifiers>...

Failed to execute command typo3cms -vvv upgrade:run all: exit status 255

This problem was discovered by @chrcan during an update today.

achimfritz commented 2 years ago

which TYPO3/PHP Version? (works for me with 10 and 7.2)

chrcan commented 2 years ago

V11.5.14 and PHP 8.0

achimfritz commented 2 years ago

@chrcan ok, got it, seems a problem with typo3-console and DataHandler used in the Upgrade Wizard (no idea why at the moment) I would recommend to use to container:sorting --apply ddev exec -- typo3cms container:sorting --apply

chrcan commented 2 years ago

I'm currently working with the container version 1.6.1 can wait until a fix comes ... But I will test your suggestion Thanks

gilbertsoft commented 2 years ago

@achimfritz my guess, it's related to the new be auth in v11 which makes a http request but the url could not be properly calculated because of the missing information in the cli context. That's why it may also be a misconfiguration e.g. for other console commands the url can be defined. But I'm wondering why a be login is needed here at all.... Avoiding it would solve the issue as far as I can see. Maybe also @helhum has a hint.

achimfritz commented 2 years ago

the Migration use DataHandler to fix sorting

websi commented 2 years ago

The following patch solve these issue for us. Works within deployment with typo3_console and Install Tool with a normal login. The standalone Install Tool will not work. Some error with missing a global request object within method initializeBackendAuthentication.

Index: Classes/Updates/ContainerMigrateSorting.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Classes/Updates/ContainerMigrateSorting.php b/Classes/Updates/ContainerMigrateSorting.php
--- a/Classes/Updates/ContainerMigrateSorting.php
+++ b/Classes/Updates/ContainerMigrateSorting.php   (date 1662016044833)
@@ -13,7 +13,10 @@
  */

 use B13\Container\Integrity\Sorting;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication;
 use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
 use TYPO3\CMS\Install\Updates\RepeatableInterface;
 use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
@@ -61,7 +64,7 @@

     public function executeUpdate(): bool
     {
-        Bootstrap::initializeBackendUser();
+        Bootstrap::initializeBackendUser(Environment::isCli() ? CommandLineUserAuthentication::class : BackendUserAuthentication::class);
         Bootstrap::initializeBackendAuthentication();
         Bootstrap::initializeLanguageObject();
         $this->sorting->run(false);
Index: Classes/Updates/ContainerDeleteChildrenWithWrongPid.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Classes/Updates/ContainerDeleteChildrenWithWrongPid.php b/Classes/Updates/ContainerDeleteChildrenWithWrongPid.php
--- a/Classes/Updates/ContainerDeleteChildrenWithWrongPid.php
+++ b/Classes/Updates/ContainerDeleteChildrenWithWrongPid.php   (date 1662016044829)
@@ -15,7 +15,10 @@
 use B13\Container\Integrity\Error\WrongPidError;
 use B13\Container\Integrity\Integrity;
 use B13\Container\Integrity\IntegrityFix;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication;
 use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
 use TYPO3\CMS\Install\Updates\RepeatableInterface;
 use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
@@ -76,7 +77,7 @@

     public function executeUpdate(): bool
     {
-        Bootstrap::initializeBackendUser();
+        Bootstrap::initializeBackendUser(Environment::isCli() ? CommandLineUserAuthentication::class : BackendUserAuthentication::class);
         Bootstrap::initializeBackendAuthentication();
         Bootstrap::initializeLanguageObject();
         $res = $this->integrity->run();
helhum commented 2 years ago

the Migration use DataHandler to fix sorting

@achimfritz Upgrade Wizards always run with a full bootstrapped TYPO3. So the question is, why you think you need to add some bootstrap code in addition.

achimfritz commented 2 years ago

@websi , @helhum thanks for feedback, no bootstrap is required for cli mode and also not for TYPO3 v10 Install-Tool. but bootstrap is required for TYPO3 v11 Install Tool (else the Datahandler throws an Exception because has no BE_USER)

helhum commented 2 years ago

@achimfritz then this is a bug in v11 install tool I would argue

helhum commented 2 years ago

no bootstrap is required for cli mode and also not for TYPO3 v10 Install-Tool. but bootstrap is required for TYPO3 v11 Install Tool (else the Datahandler throws an Exception because has no BE_USER)

I looked into the code of 10.4 and 11.5. In both versions a backend user is initialized properly (like it should) on CLI, but not for web requests in the install tool. This is a TYPO3 bug, that needs to be fixed within TYPO3, otherwise upgrade wizards can't run DataHandler actions reliably.

With that in mind, I'd argue the bootstrap code should rather removed here to allow execution of the wizards on CLI.