Project

General

Profile

Actions

Bug #91682

open

Extbase Repository returns not correct translated data if using several languages

Added by Ralf Schlömer almost 4 years ago.

Status:
New
Priority:
Should have
Category:
Extbase + l10n
Target version:
-
Start date:
2020-06-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I have to provide data from a repository in different languages in an action and a task. Therefore i call a function in my repository and submit the languageID i want to use. If i use separate requests for each languageId anything works fine. If i use a foreach loop to submit different languageIDs i allways get the data of the first submitted languageID.

Example

/**
 * Action in controller: Returns for any language the data of the first submitted languageID.
 *
 * I'm also using this setup with small changes in execute() of a scheduler-task to create json-files.
 * If I use a separate task for each language (providing a single languageID instead using $site->geLanguages() and the foreach loop)
 * anything works fine - but using foreach with different languageIDs will always return the data of the first submitted languageID
 */
public function createLanguageDataAction() {
    $site      = $GLOBALS['TYPO3_REQUEST']->getAttribute('site');
    $languages = $site->getLanguages();
    $data      = [];

    foreach($languages as $language) {
        $languageID = $language->getLanguageId();
        $data[] = $dataRepository->getDataForLanguage($languageID);
    }

    $this->view->assign('data', $data);
}

/**
 * Function in repository
 * Minimal setup.
 * I tried several combinations of the commented lines
 * but if the function is called in loop with different languageIDs none of them returned the correct data
 */
public function getDataForLanguage($languageID) {
    $query = $this->createQuery();
    $query->getQuerySettings()->setLanguageUid($languageID);

    //$query->getQuerySettings()->setRespectSysLanguage(TRUE);
    //$query->getQuerySettings()->setLanguageMode(NULL);
    //$query->getQuerySettings()->setLanguageOverlayMode(NULL);

    //$query->matching(
    //    $query->logicalAnd(
    //        $query->equals('sys_language_uid', $languageID)
    //    )
    //);

    return $query->execute();
}

No data to display

Actions

Also available in: Atom PDF