Bug #90991
closedBackendUser authentication fails for DataHandler in symfony command on command line
0%
Description
I use this in my symfony command as described on https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Typo3CoreEngine/UsingDataHandler/Index.html
TYPO3 dev-master 10.4 typo3/cms-core commit b4192d6
public function execute(InputInterface $input, OutputInterface $output)
{
// authenticate CommandLineUserAuthentication user for DataHandler usage
Bootstrap::initializeBackendAuthentication(); // is marked @internal, so use GLOBALS directly
// $GLOBALS['BE_USER']->backendCheckLogin();
// TYPO3 9 < 9.5.14 commands do not support method injection
$this->dataHandler = GeneralUtility::makeInstance(DataHandler::class);
// here*
$this->dataHandler->clear_cacheCmd('pages');
This works in TYPO3 9.5.14
TYPO3 10.4-dev shows if the command is called from command line:
Uncaught TYPO3 Exception Call to a member function getTSConfig() on null thrown in file /var/www/html/web/typo3/sysext/core/Classes/DataHandling/DataHandler.php in line 8130
This is caused by $this->dataHandler->BE_USER is null.
As workaround I insert this to //here*:
if ($this->dataHandler->BE_USER === null) {
// Bug workaround: DataHandler BE_USER is not correct initialized on command line in TYPO3 10.4-dev
$this->dataHandler->BE_USER = $GLOBALS['BE_USER'];
}
It looks like the authentication fails for DataHandler.
Updated by Jürgen Venne over 4 years ago
- Subject changed from BackendUser authentication fails in symfony command on command line to BackendUser authentication fails for DataHandler in symfony command on command line
Updated by Benni Mack over 4 years ago
- Status changed from New to Needs Feedback
Hey Jürgen.
I wonder why this has ever worked. When instantiating DataHandler you always need to call start() before doing anything. This is mainly related since DataHandler-> clear_cacheCmd() now needs a valid BackendUser to validate PageTS (done the proper way), so I recommend you add this line of code in your v9 code already to be easily forward compatible.
Updated by Benni Mack over 4 years ago
- Target version changed from 10 LTS to Candidate for patchlevel
Updated by Jürgen Venne over 4 years ago
It works now as you described.
Thank you Benni.
Updated by Benni Mack over 4 years ago
- Status changed from Needs Feedback to Closed