Bug #82127
closedSetting QuerySettings->LanguageUid to other than default causes Exception in BE Context
0%
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.
Updated by Frederik Holz over 7 years ago
- Related to Bug #57272: Extbase doesn't handle FAL translations correctly added
Updated by Frederik Holz over 7 years ago
- Priority changed from -- undefined -- to Should have
I think this is probably related to https://forge.typo3.org/issues/57272 becuase without using the translate mechanic and just creating a Record in another language, it works.
Updated by Tymoteusz Motylewski about 6 years ago
- Status changed from New to Needs Feedback
Please check if the patch https://review.typo3.org/#/c/53974/ solves the issue for you.
Updated by Riccardo De Contardi almost 6 years ago
- Status changed from Needs Feedback to Closed
No feedback since the last 90 days => closing this issue.
If you think that this is the wrong decision or experience the issue again and have more information about how to reproduce your problem, please reopen it or open a new issue with a reference to this one.
Thank you and best regards