Bug #86877
closedrefindex:update does not work in CLI-Context
100%
Description
Hi,
while updating the referenceindex on the commandline I get the following error:
me@mymachine:/path/to/typo3# php typo3/sysext/core/bin/typo3 referenceindex:update ******************************************* Reference Index being Updated ******************************************* Uncaught TYPO3 Exception Argument 1 passed to TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::update() must be of the type string, null given, called in /path/to/typo3/typo3_src-9.5.1/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php on line 1277 thrown in file /path/to/typo3/typo3_src-9.5.1/typo3/sysext/core/Classes/Session/Backend/DatabaseSessionBackend.php in line 159
It looks like this is caused by typo3/sysext/core/Classes/Database/ReferenceIndex.php
Around line 1480 a FlashMessage is created, but the current context is not taken into account. Since there is no backend-session in the CLI context, this fails:
$flashMessage = GeneralUtility::makeInstance(
FlashMessage::class,
$errorCount ? implode('##LF##', $errors) : 'Index Integrity was perfect!',
$recordsCheckedString,
$errorCount ? FlashMessage::ERROR : FlashMessage::OK
);
/** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
/** @var \TYPO3\CMS\Core\Messaging\FlashMessageQueue $defaultFlashMessageQueue */
$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$defaultFlashMessageQueue->enqueue($flashMessage);
$bodyContent = $defaultFlashMessageQueue->renderFlashMessages();
According to https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/FlashMessages/Index.html I would assume, that FlashMessageRendererResolver should be used?
The referenceindex seems to be updated nontheless, but in environments where you determine the success of the referenceindex update based on the exit code (which is 1 in this case), you can only assume that it failed (thereby preventing further steps to be taken, unless you do not care about errors at all).
Initially i tested this on a fresh installation with the introductionpackage (installed via preconfigured distribution). The error also persists after deinstalling both bootstrap_package as well as introduction. So i assume that it is a core-issue.
I was able to reproduce this in different environments, including a Ubuntu 16.04.2 LTS with Plesk 17.8 on and PHP 7.2.11 with TYPO3 9.5.1 (non-composer)