Project

General

Profile

Actions

Bug #76674

closed

setOrderings is not working correct with 1:m relations and l10n overlays

Added by Thomas Romanek almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2016-06-17
Due date:
% Done:

0%

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

Description

setOrderings is not working correct with 1:m relations and l10n overlays in mode "content fallback".

Scenario for reproducing purposes:
  • Create a simple extension with a product that can be in just one category (1:m relation). Lets call the corresponding tables just "product" (instead auf tx_exampleextension_domain_model_product) and "category"
  • Set the l10 setting to "sys_language_overlay = 1" and "sys_language_overlay = 1"
  • The default language 0 is English, the language with UID 1 is German
  • Create two english (default alng) products and two categories, each with a german overlay
  • The storage PID is 100 and all records are stored there

Want i want to do:
In the productRepository i'm trying to query some products which are ordered first by the category title and seconddly by the product title:

$query->setOrderings(array(
    'category.title' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
    'title' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
));

Result:
This works fine for the default language (English): As a result i do get the two products ordered correctly.
This works even fine if i set the language mode to "strict". Then, i do get only the translated products, as expected.
This does not work (with "sys_language_overlay = 1") for "german". Then the result is empty.

What i could debug:
I had a look at the created SQLs of extbase. In strict mode they make sense (thats the reason why strict mode works ;) ). In mode "content_fallback" there seem to be logical errors.

That is how the SQL is generated for CONTENT FALLBACK MODE for "sys_language_uid=1":
----------

SELECT
    DISTINCT product.*
FROM
    product
    LEFT JOIN category AS category ON product.category = category.uid
WHERE
    1 = 1

    # RESTRICTIONS FOR PRODUCTS:
    AND (
        # GERMAN PRODUCT RECORDS OR FOR ALL LANGUAGES
        product.sys_language_uid IN (1,-1)

        # OR ENGLISH RECORDS (DEFAULT LANG) PRODUCTS WITHOUT OVERLAYS
        OR ( 
            product.sys_language_uid = 0
            AND product.uid NOT IN (
                SELECT
                    product.l10n_parent
                FROM
                    product
                WHERE
                    product.l10n_parent > 0
                    AND product.sys_language_uid = 1
                    AND product.deleted = 0
            )
        )
    )
    AND product.pid IN (100)

    # RESTRICTIONS FOR CATEGORIES:
    AND (
        (
            (
                # GERMAN CATEGORY RECORDS OR FOR ALL LANGUAGES ***
                category.sys_language_uid IN (1,-1)

                # OR ENGLISH (DEFAULT LANG) RECORDS WITHOUT OVERLAYS
                OR (
                    category.sys_language_uid = 0
                    AND category.uid NOT IN (
                        SELECT
                            category.l10n_parent
                        FROM
                            category
                        WHERE
                            category.l10n_parent > 0
                            AND category.sys_language_uid = 1
                            AND category.deleted = 0
                    )
                )
            )
            AND category.pid IN (100)
        )
        OR category.uid IS NULL
    )

    [... MORE RESTRICTIONS FOR ENABLE FIELDS....]

ORDER BY
    category.title ASC,
    product.title ASC, 

I think the logical error here is that the JOIN can only be made on parent records because even the translated products records do have the UID of the english (default lang) category record in the relation column "product.category". So after the JOIN, i do only have ENGLISH (default lang 0) categories. But then, the logic of the SQL tries to restrict (as commented in the query above at the position of "***") to german category records or english records without overlay. This makes no sense for me.


Related issues 1 (0 open1 closed)

Is duplicate of TYPO3 Core - Bug #69210: Translated records are ordered like default languageRejected2015-08-20

Actions
Actions #1

Updated by Geddo no-lastname-given almost 8 years ago

This bug also bugs me a lot :-/ I noticed that it does not appear if you set your base category-record to "all languages" (-1) - but in almost every case IKTO you need translated records so this bug should def. fixed.

Actions #2

Updated by Markus Klein almost 8 years ago

  • Status changed from New to Closed

This is a duplicate of #69210, where I explain why it is not (reasonably) possible to sort on records based on the overlay technique.

Actions

Also available in: Atom PDF