Issue Bug Closed

#88955Language restriction is not automatically taken in account with queryBuilder

Florian Rival 08/13/19, 16:21 updated 05/31/21, 16:08

Description

Create a request to get data from a table in a repository :

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_myext_domain_model_table');
$result = $queryBuilder->select('*')
        ->from('tx_myext_domain_model_table')
        ->where(...$conditions)
        ->execute()
        ->fetchAll();

if the table ‘tx_myext_domain_model_table’ contains translations for other languages (i.e. sys_language_uid > 0) the result returned include the records for all languages while ‘sys_language_uid’ should have been automatically filtered for the current language.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 5

  1. Frank Nägler commented and changed category status New Closed Is Regression 1 0 10/09/19, 09:34

    Thank you for your report, but the issue you describe is not a bug nor a regression.
    The QueryBuilder contains the DefaultRestrictionContainer which contains restrictions for deleted and hidden flags and time-based restrictions.
    So the language was never taken into account, changing this behavior would be a big breaking change.

    For these reasons, I will close the issue. If you think I am wrong please add a comment or open a new issue.

  2. Florian Rival commented 10/09/19, 12:47

    Ok, but in that case it should exist a language restriction that can be added in order to get data only for current language.
    This is a feature that we always need when working with QueryBuilder on a multi-language website.

  3. Sybille Peters commented 01/14/20, 14:48

    I expected the DefaultRestriction to include a language restriction as well. This might also trip up people migrating from Extbase query building.

    We might want to add the information to the documentation, at least. I added an issue: https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/issues/720

  4. Anonymous commented 04/12/21, 10:20

    Sybille Peters wrote in #note-3:
    > This might also trip up people migrating from Extbase query building.

    and makes people really mad as well. Riot like mad.

  5. Johannes Rebhan commented 05/31/21, 16:08

    Agreed. LanguageRestriction would be very, very useful.