Project

General

Profile

Actions

Bug #62061

closed

QueryBuilder with set LIMIT returns wrong number of records in multi-language installations

Added by Viktor Livakivskyi over 9 years ago. Updated almost 8 years ago.

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

0%

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

Description

Basicly, this is a regression, introduced by fix of #60613.

A more detailed description:

This commit changes behavior of query selection.

Was
Either records from requested language or non-translated records are fetched.

Now
Either records from requested language or non-translated to requested language records are fetched.

So far so good, until we use ->setLimit() in queryBuilder and config.sys_language_mode = strict in TS.

Real life example: we have a lazy-loading feature on a website, where records are loaded by portions of 6. Six records are shown and when user scrolls the window down, next 6 are requested and so on. We don't have any language fallbacks and always show records from requested language (config.sys_language_mode = strict).
With TYPO3 6.1.10 this was working like a charm, but with TYPO3 6.1.11 it broke, because now all the records, that are not translated, are fetched as well, but later they are cut down by doLanguageAndWorkspaceOverlay(), so instead of 6 records, only 2 are shown (sure, this number may vary between 0 and 6).

This is treated as major bug, which blocks us from further 6.1 updates, and I assume will block us on 6.2.4 as well, since same fix was applied to 6.2.5.

More side notes: in commit notes following is written:
Currently when TYPO3 is configured to do language fallback
and a record is translated in language A, but not
in language B and language B is requested, then this
record is excluded.

But this is not really truth. In our case we don't have any language fallback and that huge $additionalWhereClause in addSysLanguageStatement() is added by checking following condition:

if (isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
    && $querySettings->getSysLanguageUid() > 0
)

If a TCA has 'transOrigPointerField' and requested language is not 0, then we add something, like: OR (tx_record.sys_language_uid=0 AND tx_record.uid NOT IN (SELECT tx_record.l10n_parent FROM tx_record WHERE tx_record.l10n_parent>0 AND tx_record.sys_language_uid=2 AND tx_record.deleted=0)))
As you can see, it has nothing to do with "TYPO3 is configured to do language fallback", but with TCA field, which exists for almost any table.

To be honest, even TYPO3 6.1.10 is affected by this, but probability of this bug to appear is much lower: record needs to exist in default language only (has no translations) - then the record will be fetched as well. And in my example above doLanguageAndWorkspaceOverlay() will cut it down.

Possible fixes:
1. (fast and dirty) revert fix of #60613.
2. change condition:

if (isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
    && $querySettings->getSysLanguageUid() > 0
)

to:
if (isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
    && $querySettings->getSysLanguageUid() > 0
    && $GLOBALS['TSFE']->sys_language_mode != 'strict'
)

TYPO3 6.1.11


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #60613: Extbase Persistence has wrong language fallback when records are translated in any other languageClosedHelmut Hummel2014-07-27

Actions
Actions #1

Updated by Helmut Hummel almost 8 years ago

  • Status changed from New to Needs Feedback

In TYPO3 versions starting from 6.2 we have a different language query for config.sys_language_mode = strict

Can you verify if this is still an issue for you in 6.2 or 7.6?

If not, I'd close this report

Actions #2

Updated by Helmut Hummel almost 8 years ago

  • Status changed from Needs Feedback to Closed
  • Is Regression changed from Yes to No

This is fixed in 6.2 as we indeed have special strict handling.
The regression mentioned also isn't one, as the problem (wrong or missing strict handling) was present in 6.1 with or without the mentioned change.

The following scenario:

tt_news: { 
    uid: 1,
    sys_language_uid: 0,
}
tt_news: { 
    uid: 2,
    sys_language_uid: 1,
}
tt_news: { 
    uid: 3,
    sys_language_uid: 0,
}

Given config.sys_language_uid = 2

  • before the mentioned change the following uid(s) were selected with the query: 3
  • after the mentioned change the following uid(s) were selected with the query: 1,3

Both, records 1 and 3 are discarded during doLanguageAndWorkspaceOverlay(), which means, that the query count already fails if records are available which have no translation and was only correct in the edge case, where records had translations but not in the requested language.

Since TYPO3 6.2 we introduced a dedicated query for config.sys_language_mode = strict which makes all the mentioned issues go away.

Actions

Also available in: Atom PDF