[BUGFIX] Make extbase language handling consistent with TYPO3 v7 20/53820/2
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Wed, 23 Aug 2017 19:05:56 +0000 (21:05 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Mon, 28 Aug 2017 10:13:43 +0000 (12:13 +0200)
During doctrine migration a change of behaviour was introduced.
In v7 when a translated record is hidden, it's not shown,
while before this patch, a record from default language was shown.

Resolves: #82161
Releases: master, 8.7
Change-Id: Ib8127eff7218f9dd064febbab4956af44f3164b9
Reviewed-on: https://review.typo3.org/53820
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php
typo3/sysext/extbase/Tests/Functional/Persistence/TranslatedContentTest.php

index ab16e6d..444b6cd 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
+use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Persistence\Generic\Exception\InconsistentQuerySettingsException;
 use TYPO3\CMS\Extbase\Persistence\Generic\Exception\InvalidRelationConfigurationException;
@@ -752,6 +753,7 @@ class Typo3DbQueryParser
 
                     if ($mode === 'strict') {
                         $queryBuilderForSubselect = $this->queryBuilder->getConnection()->createQueryBuilder();
+                        $queryBuilderForSubselect->getRestrictions()->removeAll()->add(new DeletedRestriction());
                         $queryBuilderForSubselect
                             ->select($tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
                             ->from($tableName)
@@ -778,6 +780,7 @@ class Typo3DbQueryParser
                         );
                     }
                     $queryBuilderForSubselect = $this->queryBuilder->getConnection()->createQueryBuilder();
+                    $queryBuilderForSubselect->getRestrictions()->removeAll()->add(new DeletedRestriction());
                     $queryBuilderForSubselect
                             ->select($tableAlias . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
                             ->from($tableName)
index d018946..f6c995e 100644 (file)
@@ -446,17 +446,17 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode =',
-                'visibleRecordHeaders' => ['Regular Element #2', 'Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
+                'visibleRecordHeaders' => ['Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = content_fallback',
-                'visibleRecordHeaders' => ['Regular Element #2', 'Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
+                'visibleRecordHeaders' => ['Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = content_fallback;1,0',
-                'visibleRecordHeaders' => ['Regular Element #2', 'Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
+                'visibleRecordHeaders' => ['Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
@@ -466,19 +466,19 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = ignore',
-                'visibleRecordHeaders' => ['Regular Element #2', 'Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
+                'visibleRecordHeaders' => ['Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
             ],
             5 => [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode =',
-                'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
+                'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #3'],
             ],
             // Expected behaviour:
             // Not translated element #2 is shown because sys_language_overlay = 1 (with sys_language_overlay = hideNonTranslated, it would be hidden)
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = content_fallback',
-                'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
+                'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #3'],
             ],
 //             Expected behaviour:
 //             Element #3 is not translated in PL and it is translated in DK. It's not shown as content_fallback is not related to single CE level
@@ -486,7 +486,7 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = content_fallback;1,0',
-                'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
+                'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #3'],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 1
@@ -496,24 +496,24 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = ignore',
-                'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
+                'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #3'],
             ],
             // Expected behaviour:
             // Non translated default language elements are not shown, because of hideNonTranslated
             10 => [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode =',
-                'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #2', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
+                'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = content_fallback',
-                'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #2', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
+                'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = content_fallback;1,0',
-                'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #2', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
+                'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
@@ -523,7 +523,7 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = ignore',
-                'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #2', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
+                'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
             ]
         ];
     }