Project

General

Profile

Actions

Bug #75810

closed

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

Added by Nicola Heisch over 8 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase + l10n
Start date:
2016-04-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.6
Tags:
extbase localization
Complexity:
Is Regression:
No
Sprint Focus:

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();

Files

test_0.0.0_201604201200.zip (510 KB) test_0.0.0_201604201200.zip Extension which demonstrates the issue Nicola Heisch, 2016-04-20 12:19
Actions #1

Updated by Nicole Cordes over 8 years ago

  • Status changed from New to On Hold

I can understand and verify your problem. But currently it seems, as this issue is not solvable in Extbase as it doesn't check the l10n_mode defined in the TCA settings of the table. And respecting this setting is not that easy as you can insert a nested property in the query clause.

I would suggest to use your example query as you know the state of the l10n_mode of that field.

Actions #2

Updated by Helmut Hummel over 8 years ago

Thanks for the detailed report!

Nicola Heisch wrote:

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.

We cannot do so, because this will break ordering statements on translated properties.

My suggestion would be to add a DataHandler hook, which keeps translated fields in sync with the translation parent, if they are configured as l10n_mode exclude.

This would also be the only possible fix we could incorporate without blowing up the SQL statement

Actions #3

Updated by Benni Mack over 8 years ago

  • Target version changed from 7.6.5 to Candidate for patchlevel
Actions #4

Updated by Riccardo De Contardi about 7 years ago

  • Category changed from Extbase to Extbase + l10n
Actions #5

Updated by Benni Mack about 7 years ago

  • Status changed from On Hold to Needs Feedback

With the new data synchronization logic in v8 LTS this is now possible to solve this conceptual issue. Can you please confirm if this also solves your problem?

Actions #6

Updated by Wouter Wolters almost 7 years ago

  • Status changed from Needs Feedback to Closed

Closed for lack of feedback after more than 3 months. Should be solved according to Benni.

Actions

Also available in: Atom PDF