Project

General

Profile

Actions

Bug #82127

closed

Setting QuerySettings->LanguageUid to other than default causes Exception in BE Context

Added by Frederik Holz over 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase + l10n
Target version:
-
Start date:
2017-08-17
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Using the BE Hook

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['list']

to show something the user has selected in a Plugin, I got a Exception that the second value of explode needs to be string, null given.

What I do:
Create a Repository via Objectmanager to get the Model of the selected Value of the Plugin.
For Example, the User selects Products in this Plugin which will be displayed in the frontend as a list. With this hook, I want to show the User, which Products he has selected without opening/editing the plugin.
While trying to get the Model via the Repository, I wrote an own function „findByUids“. Because the flexform returns ids as a list, which the user selected.
Function looks like this:

$query = $this->createQuery();
    $query->getQuerySettings()->setRespectStoragePage(FALSE);
    $query->getQuerySettings()->setLanguageUid(1); // Just an Example, probably something like $row['sys_language_uid']
    return $query
        ->matching(
            $query->in('uid', $uids)
        )
        ->execute();
}

Without setting the Language Uid, the SQL Query is wrong and only asks for sys_language_uid IN (-1,0). But I got up to 7 Languages, so the preview only works for the default language. So I took the Values from $row in the hook and set the Language Uid via

$query->getQuerySettings()->setLanguageUid($row['sys_language_uid']); // $row holds the data of the plugin in this hook

The Query is correct (if I debug the query and set it in SQL directly) but Typo3 goes on and tries to get the RecordOverlay in the Pagerepository, Line 539 is checked if sys_language_content > 0 and than starts creating FrontendGroupRestriction which tries to use the TSFE in the constructor. This causes the exception because the TSFE is not available, so explodes seconds variable is null.

PageRepo:

if ($sys_language_content > 0) {
                        // Must be default language, otherwise no overlaying
                        if ((int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === 0) {
                            // Select overlay record:
                            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
                                ->getQueryBuilderForTable($table);
                            $queryBuilder->setRestrictions(
                                GeneralUtility::makeInstance(FrontendRestrictionContainer::class)
                            );

FrontendGroupRestriction:

public function __construct(array $frontendGroupIds = null)
    {
        $this->frontendGroupIds = $frontendGroupIds === null ? explode(',', $GLOBALS['TSFE']->gr_list) : $frontendGroupIds;
    }

Without setting LanguageUid, I get an EmptyQueryResult because the default check of sys_language_uid IN (0,-1) only works for the default language. With setting the languageUid in the query settings I get this exception.

Maybe check if we are in the BE Context and don't check for FE User Restrictions? I am not that deep into the core, sorry.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #57272: Extbase doesn't handle FAL translations correctlyClosed2014-03-25

Actions
Actions

Also available in: Atom PDF