Issue Bug Under Review Quiet

#109968Command application loads all commands with incomplete Container

Alexander Stehlik 06/02/26, 22:53 updated 10/02/26, 07:01

Description

In some edge cases the \TYPO3\CMS\Core\Console\CommandApplication will try to load all registered commands, even if only the minimal fallback container has been initialized.

The issue can be reproduced by executing bin/typo3 dump in a Composer installation.

Observed errors

I’ve seen 3 different error messages during my tests:

> Too few arguments to function TYPO3\CMS\Core\Schema\TcaSchemaFactory::__construct(), 0 passed in typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 2884

> Uncaught TYPO3 Exception Too few arguments to function TYPO3\CMS\Core\Registry::__construct(), 0 passed in typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 2489 and exactly 2 expected thrown in file typo3/sysext/core/Classes/Registry.php in line 45

Both are caused by \TYPO3\CMS\Impexp\Import::fetchStorages() which is called in the constructor.

> No TCA schema exists for the name “sys_redirect”.

This one is caused by the \TYPO3\CMS\Redirects\Command\CleanupRedirectsCommand which depends on the \TYPO3\CMS\Redirects\Repository\RedirectRepository which tries to fetch the sys_redirect TCA schema in its contructor.

The hidden error

Both errors mask the actual error message that should be displayed because the command is disabled in a Composer environment.

> The command “dumpautoload” does not exist.

This happens due to the alias resolution in the Command Application and Symfony Console’s error handling:

  • First it checks, if a full boot is needed, since the alias is not known, it assumes it is
  • In a later check the real command dumpautoload has been resolved and a full boot is no longer required. This means the TCA will not be initialized
  • The dumpautoload command is not enabled in Composer environments. Therefore Symfony will fail with a \Symfony\Component\Console\Exception\CommandNotFoundException
  • During the Failure, Symfony will load all commands to show more information to the user
  • This will crash for commands of which the constructor depends on a fully available Container / TCA

Possible solutions

  • Make sure the container is fully initialized, if the command is not available (current Patch)
  • Alternative 1: Fix the underlying issues by making the Command Constructors more robust and not rely on TCA functions
  • Alternative 2: Remove fallback logic that boots the container without loading TCA -> uses can not rely on aliases, the full command must be used

Reviews 1

History 46