Project

General

Profile

Actions

Bug #83179

open

Epic #86307: Extbase allows to fetch deleted/hidden records (respects ignoreEnableFields)

getSysLanguageStatement builder does not respect enable fields

Added by Andi Peh over 6 years ago. Updated over 5 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase + l10n
Target version:
-
Start date:
2017-11-30
Due date:
% Done:

0%

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

Description

I stumbled upon a problem while listing translated rows from a custom table with config.sys_language_mode=strict

Steps to reproduce:
  • create a new repository, with [ctrl] transOrigPointerField, languageField and enablecolumns
  • add some records to the repository in the default language
  • add a new language
  • create translated entries for the existing records
  • hide/disable the second last translated entry
  • list those entries in the frontend limited to count(*)-1 (so if you have created 5 records, limit it to 4)
  • switch to the new language
what happends:
  • a findAll in the repository will return the first 4 records from the default language
  • the language overlay will query each uid to check if there is a translated record available
  • typo3 correctly excludes the one hidden record (the second last)
  • the problem: the list does not show 4 items as requests and available, but only 3

the generated queries look something like this:

SELECT tx_test_domain_model_item.* FROM tx_test_domain_model_item 
WHERE 1=1 AND 
(tx_test_domain_model_item.sys_language_uid=-1 OR 
    (tx_test_domain_model_item.sys_language_uid = 2 AND tx_test_domain_model_item.l10n_parent=0) OR 
    (tx_test_domain_model_item.sys_language_uid=0 AND tx_test_domain_model_item.uid IN 
        (SELECT tx_test_domain_model_item.l10n_parent 
        FROM tx_test_domain_model_item 
        WHERE tx_test_domain_model_item.l10n_parent>0 AND 
        tx_test_domain_model_item.sys_language_uid=2 AND 
        tx_test_domain_model_item.deleted=0
        )
    )
) AND tx_test_domain_model_item.pid IN (37) AND tx_test_domain_model_item.deleted=0 
AND tx_test_domain_model_item.hidden=0
ORDER BY tx_test_domain_model_item.sorting ASC
LIMIT 4;

-- followed by this for each found record:

SELECT * FROM tx_test_domain_model_item
WHERE pid=37 AND sys_language_uid=2 AND l10n_parent=1 AND 
tx_test_domain_model_item.deleted=0 AND tx_test_domain_model_item.hidden=0 
LIMIT 1

the problem goes down to:

Typo3DbQueryParser->getSysLanguageStatement

there the generator does only respected deleted fields in the subquery, but not hidden or outdated fields.

https://git.typo3.org/Packages/TYPO3.CMS.git/blob/dea1e9643567e99a6f7cee6edda6d8000893b743:/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php#l705

therefor this

// Add delete clause to ensure all entries are loaded
if (isset($GLOBALS['TCA'][$tableName]['ctrl']['delete'])) {
    $additionalWhereClause .= ' AND ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['delete'] . '=0';
}

should be replaced by this:

// Add visibility constraints to ensure all entries are loaded and enabled
$enableFields = $this->getVisibilityConstraintStatement($querySettings, $tableName, $tableName);
if(!empty($enableFields)) {
    $additionalWhereClause .= ' AND '. $enableFields;
}


Related issues 2 (2 open0 closed)

Related to TYPO3 Core - Feature #82986: Extbase Model - includeDeleted and ignoreEnableFieldsNew2017-11-13

Actions
Related to TYPO3 Core - Bug #76054: Extbase ignores parent record's enableFields when using ContentFallbackNew2016-05-05

Actions
Actions

Also available in: Atom PDF