#110600Install Tool "Database Analyzer" throws ArgumentCountError for TcaSchemaFactory (missing resetContainer=false in MaintenanceController)
Description
Summary
Opening Install Tool -> Maintenance -> Analyze Database Structure (and executing suggested changes) throws an uncaught ArgumentCountError from TYPO3\CMS\Core\Schema\TcaSchemaFactory::__construct(), on an otherwise healthy, fully installed TYPO3 14.3 instance.
Steps to reproduce
- Set up a plain TYPO3 14.3 instance (composer-based).
- Open the Install Tool.
- Go to Maintenance -> Analyze Database Structure.
- The action fails once any core code path that does a GeneralUtility::makeInstance()-based DB query runs during this request (e.g. ConnectionMigrator::getUnusedTableUpdateSuggestions() via Connection::count()/createQueryBuilder()).
Expected behavior
The Database Analyzer computes and displays schema update suggestions without error.
Actual behavior
ArgumentCountError Too few arguments to function TYPO3\CMS\Core\Schema\TcaSchemaFactory::__construct(), 0 passed in vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php on line 2905 and exactly 3 expected in vendor/typo3/cms-core/Classes/Schema/TcaSchemaFactory.php line 41 at TYPO3\CMS\Core\Schema\TcaSchemaFactory->__construct() in vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php line 2905 at TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance() in vendor/typo3/cms-core/Classes/Database/Query/Restriction/DeletedRestriction.php line 36 at TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction->__construct() in vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php line 2905 at TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance() in vendor/typo3/cms-core/Classes/Database/Query/Restriction/AbstractRestrictionContainer.php line 109 at TYPO3\CMS\Core\Database\Query\Restriction\AbstractRestrictionContainer->createRestriction() in vendor/typo3/cms-core/Classes/Database/Query/Restriction/DefaultRestrictionContainer.php line 43 at TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer->__construct() in vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php line 2905 at TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance() in vendor/typo3/cms-core/Classes/Database/Connection.php line 121 at TYPO3\CMS\Core\Database\Connection->createQueryBuilder() in vendor/typo3/cms-core/Classes/Database/Connection.php line 351 at TYPO3\CMS\Core\Database\Connection->count() in vendor/typo3/cms-core/Classes/Database/Schema/ConnectionMigrator.php line 1330 at TYPO3\CMS\Core\Database\Schema\ConnectionMigrator->getTableRecordCount() in vendor/typo3/cms-core/Classes/Database/Schema/ConnectionMigrator.php line 898 at TYPO3\CMS\Core\Database\Schema\ConnectionMigrator->getUnusedTableUpdateSuggestions() in vendor/typo3/cms-core/Classes/Database/Schema/ConnectionMigrator.php line 122 at TYPO3\CMS\Core\Database\Schema\ConnectionMigrator->getUpdateSuggestions() in vendor/typo3/cms-core/Classes/Database/Schema/SchemaMigrator.php line 75 at TYPO3\CMS\Core\Database\Schema\SchemaMigrator->getUpdateSuggestions() in vendor/typo3/cms-install/Classes/Controller/MaintenanceController.php line 291 at TYPO3\CMS\Install\Controller\MaintenanceController->databaseAnalyzerAnalyzeAction()
Root cause
TYPO3\CMS\Core\Schema\TcaSchemaFactory is declared #[Autoconfigure(public: true, shared: true)], so it is only resolvable via GeneralUtility::makeInstance() when the currently active container (GeneralUtility::getContainer()) is the fully compiled, non-failsafe container. GeneralUtility::makeInstance() silently falls back to a bare “new $class()” (no constructor args) when the class cannot be resolved from that container – which is exactly what produces the ArgumentCountError here.
TYPO3\CMS\Install\Controller\MaintenanceController::databaseAnalyzerAnalyzeAction() and ::databaseAnalyzerExecuteAction() boot the required container via:
$container = $this->lateBootService->loadExtLocalconfDatabaseAndExtTables();
TYPO3\CMS\Install\Service\LateBootService::loadExtLocalconfDatabaseAndExtTables() overrides its parent’s $resetContainer default of false (TYPO3\CMS\Core\Core\BootService::loadExtLocalconfDatabaseAndExtTables(), line 118) with true (LateBootService.php, line 33). Internally, BootService::loadExtLocalconfDatabaseAndExtTables() sets the newly built, fully compiled container as the current global container via GeneralUtility::setContainer() (through makeCurrent()) while it loads ext_localconf.php/TCA/ext_tables.php. But because $resetContainer is true here, makeCurrent(null, $backup) is called right at the end of loadExtLocalconfDatabaseAndExtTables(), which immediately reverts the global container back to the original (failsafe) one – before the method even returns.
Both affected controller actions then use the returned $container object directly for $container->get(SchemaMigrator::class), which works fine since that’s a direct container call. However, SchemaMigrator / ConnectionMigrator internally rely on plain GeneralUtility::makeInstance() calls deeper in the call chain (e.g. for DefaultRestrictionContainer/DeletedRestriction when building a QueryBuilder). Those calls resolve against the global container (GeneralUtility::getContainer()), which was already reverted to the failsafe container that does not provide TcaSchemaFactory – hence the crash.
This is inconsistent with every other call site in the very same file. All 5 other calls to loadExtLocalconfDatabaseAndExtTables() in MaintenanceController.php explicitly pass resetContainer: false:
Classes/Controller/MaintenanceController.php:112 (clearTypo3tempFilesStatsAction) Classes/Controller/MaintenanceController.php:140 (clearTypo3tempFilesAction) Classes/Controller/MaintenanceController.php:599 (languagePacksGetDataAction) Classes/Controller/MaintenanceController.php:761 (languagePacksUpdatePackAction) Classes/Controller/MaintenanceController.php:857 (referenceIndexUpdateAction)
Only databaseAnalyzerAnalyzeAction (line 228) and databaseAnalyzerExecuteAction (line 382) omit the argument, relying on LateBootService’s overridden default of true – which appears to be an oversight, since the resulting behavior (discarding the just-booted container before it’s fully used) contradicts what the method needs to do its job.
Suggested fix
Pass resetContainer: false explicitly in both call sites, matching the other 5 call sites in the same class:
--- a/Classes/Controller/MaintenanceController.php
+++ b/Classes/Controller/MaintenanceController.php
@@ -225,7 +225,7 @@ class MaintenanceController extends AbstractController
*/
public function databaseAnalyzerAnalyzeAction(ServerRequestInterface $request): ResponseInterface
{
- $container = $this->lateBootService->loadExtLocalconfDatabaseAndExtTables();
+ $container = $this->lateBootService->loadExtLocalconfDatabaseAndExtTables(false);
$schemaMigrator = $container->get(SchemaMigrator::class);
$messageQueue = new FlashMessageQueue('install');
@@ -379,7 +379,7 @@ class MaintenanceController extends AbstractController
*/
public function databaseAnalyzerExecuteAction(ServerRequestInterface $request): ResponseInterface
{
- $container = $this->lateBootService->loadExtLocalconfDatabaseAndExtTables();
+ $container = $this->lateBootService->loadExtLocalconfDatabaseAndExtTables(false);
$messageQueue = new FlashMessageQueue('install');
$selectedHashes = $request->getParsedBody()['install']['hashes'] ?? [];
if (empty($selectedHashes)) {
We applied exactly this patch locally (via cweagans/composer-patches) and confirmed it resolves the issue in our environment.
Additional note (separate, related trigger)
We initially also hit the same ArgumentCountError symptom via a different trigger: a third-party extension’s TablesDefinitionIsBeingBuiltEvent listener ran a live DB query during the same (still-being-built) bootstrap phase and only caught \Exception, not the resulting \Error. That is a bug in the third-party extension, not in TYPO3 core, and is unrelated to the core issue described above – mentioned here only because both produced an identical-looking stack trace up to GeneralUtility::makeInstance() and could otherwise cause confusion when searching for this error message.
Environment
- TYPO3 14.3.6, composer-based installation
- PHP 8.4
- Reproducible on a vanilla install; not dependent on any specific third-party extension for the core issue itself.