Project

General

Profile

Actions

Bug #90991

closed

BackendUser authentication fails for DataHandler in symfony command on command line

Added by Jürgen Venne over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
CLI
Start date:
2020-04-09
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.

Actions

Also available in: Atom PDF