Issue Bug Closed

#75810Extbase fails to properly matching a value against a non-translated property

Nicola Heisch 04/20/16, 12:19 updated 02/08/18, 22:30

Description

Description

If you create an Extbase query (\TYPO3\CMS\Extbase\Persistence\Generic\Query) and filter by a property which has “l10n_mode” => exclude it will still try to match the property to the translated records instead of the parents.

Extbase should filter out records with a language parent at this stage of the query, since it does the record overlay afterwards in any case.

Steps to reproduce

(I’ve attached an extension which demonstrates the issue)

  • Have a TYPO3 installation with at least 2 languages
  • Install the provided extension (attached to the ticket)
  • Create a record with the value “test” in the field “Nontranslatedproperty”
  • Translate that record
  • Add the plugin on any page
  • Run the plugin on any sys_language other than default

Expected result

Example 1:

        $query = $this->testMasterRepository->createQuery();
        $query->matching(
            $query->equals('nontranslatedproperty', 'test')
        );
        $test = $query->execute();

Should return the record with “nontranslatedproperty” => “test”

Actual result

Doesn’t return the expected record in any sys_language other than 0/-1

Example which returns the expected result

        $query = $this->testMasterRepository->createQuery();
        $querySettings = $query->getQuerySettings();
        $querySettings->setRespectSysLanguage(false);
        $query->setQuerySettings($querySettings);

        $query->matching(
            $query->logicalAnd(
                $query->logicalOr(
                    $query->in('sys_language_uid', [0, -1]),
                    $query->logicalAnd(
                        $query->equals('sys_language_uid', $querySettings->getLanguageUid()),
                        $query->equals('l10n_parent', 0)
                    )
                ),
                $query->equals('nontranslatedproperty', 'test')
            )
        );

        $test = $query->execute();

Reviews 0

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