[BUGFIX] Pass language mode to QuerySettings in default language too 51/58351/11
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Thu, 20 Sep 2018 13:35:52 +0000 (15:35 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 22 Sep 2018 19:48:20 +0000 (21:48 +0200)
Introduction of the LanguageAspect changed the Extbase behavior, now it's
reintroduced.
When reviewing this patch please compare new code of
Typo3QuerySettings.php from this patch with state before
patch https://review.typo3.org/57424/ and compare
QueryLocalizedDataTest.php with one from v8 to see that
result is the same.

Resolves: #86332
Related: #85543
Releases: master
Change-Id: Ide9f5e1fe1875b942aac8d1187dc897cc1b20181
Reviewed-on: https://review.typo3.org/58351
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/extbase/Classes/Persistence/Generic/Typo3QuerySettings.php
typo3/sysext/extbase/Tests/Functional/Persistence/QueryLocalizedDataTest.php
typo3/sysext/extbase/Tests/Functional/Persistence/TranslationTest.php

index 6f38178..ca32719 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Context\LanguageAspect;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
+use TYPO3\CMS\Extbase\Service\EnvironmentService;
 
 /**
  * Query settings. This class is NOT part of the TYPO3.Flow API.
@@ -95,6 +96,19 @@ class Typo3QuerySettings implements QuerySettingsInterface
     protected $languageUid = 0;
 
     /**
+     * @var EnvironmentService
+     */
+    protected $environmentService;
+
+    /**
+     * @param EnvironmentService $environmentService
+     */
+    public function injectEnvironmentService(EnvironmentService $environmentService)
+    {
+        $this->environmentService = $environmentService;
+    }
+
+    /**
      * As long as we use a feature flag ignoreAllEnableFieldsInBe to determine the default behavior, the
      * initializeObject is responsible for handling that.
      */
@@ -104,19 +118,21 @@ class Typo3QuerySettings implements QuerySettingsInterface
         $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
         /** @var ConfigurationManagerInterface $configurationManager */
         $configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
-        if (TYPO3_MODE === 'BE' && $configurationManager->isFeatureEnabled('ignoreAllEnableFieldsInBe')) {
+        if ($this->environmentService->isEnvironmentInBackendMode() && $configurationManager->isFeatureEnabled('ignoreAllEnableFieldsInBe')) {
             $this->setIgnoreEnableFields(true);
         }
         /** @var LanguageAspect $languageAspect */
         $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
         $this->setLanguageUid($languageAspect->getContentId());
-        if ($languageAspect->getContentId()) {
-            $this->setLanguageOverlayMode($languageAspect->getLegacyOverlayType() ?: false);
+        $this->setLanguageOverlayMode(false);
+
+        if ($this->environmentService->isEnvironmentInFrontendMode()) {
+            $overlayMode = $languageAspect->getLegacyOverlayType() === 'hideNonTranslated' ? 'hideNonTranslated' : (bool)$languageAspect->getLegacyOverlayType();
+            $this->setLanguageOverlayMode($overlayMode);
             $this->setLanguageMode($languageAspect->getLegacyLanguageMode() ?: null);
-        } else {
-            // Kept for backwards-compatibility
-            $this->setLanguageOverlayMode(false);
-            $this->setLanguageMode(null);
+        } elseif ((int)GeneralUtility::_GP('L')) {
+            // Set language from 'L' parameter
+            $this->setLanguageUid((int)GeneralUtility::_GP('L'));
         }
     }
 
index cda7be4..00837c6 100644 (file)
@@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Context\LanguageAspect;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
 use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
+use TYPO3\CMS\Extbase\Persistence\QueryInterface;
 use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
 use TYPO3\CMS\Extbase\Service\EnvironmentService;
 use TYPO3\CMS\Frontend\Page\PageRepository;
@@ -65,6 +66,7 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
         $this->objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
         $configuration = [
             'persistence' => [
+                'storagePid' => 20,
                 'classes' => [
                     'TYPO3\CMS\Extbase\Domain\Model\Category' => [
                         'mapping' => ['tableName' => 'sys_category']
@@ -75,10 +77,6 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
         $configurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
         $configurationManager->setConfiguration($configuration);
         $this->postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
-        $query = $this->postRepository->createQuery();
-        $querySettings = $query->getQuerySettings();
-        $querySettings->setStoragePageIds([20]);
-        $this->postRepository->setDefaultQuerySettings($querySettings);
         $this->persistenceManager = $this->objectManager->get(PersistenceManager::class);
     }
 
@@ -95,6 +93,9 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
             ->willReturn(true);
         GeneralUtility::setSingletonInstance(EnvironmentService::class, $environmentServiceMock);
 
+        $context = GeneralUtility::makeInstance(Context::class);
+        $context->setAspect('language', new LanguageAspect(0, 0, LanguageAspect::OVERLAYS_ON, []));
+
         $pageRepositoryFixture = new PageRepository();
         $frontendControllerMock = $this->createMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class);
         $frontendControllerMock->sys_page = $pageRepositoryFixture;
@@ -311,18 +312,6 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
         $query->matching($query->equals('uid', 2));
         $post2 = $query->execute()->getFirst();
 
-        $this->assertNull($post2);
-
-        //this is needed because of https://forge.typo3.org/issues/59992
-        $this->persistenceManager->clearState();
-
-        $query = $this->postRepository->createQuery();
-        $querySettings = $query->getQuerySettings();
-        $querySettings->setLanguageUid(1);
-        $querySettings->setLanguageOverlayMode(true);
-        $query->matching($query->equals('uid', 11));
-        $post2 = $query->execute()->getFirst();
-
         $this->assertEquals(['Post 2 - DK', 2, 11, 'Blog 1', 1, 1, 'John', 1, 1], [
             $post2->getTitle(),
             $post2->getUid(),
@@ -334,6 +323,18 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
             $post2->getAuthor()->getUid(),
             $post2->getAuthor()->_getProperty('_localizedUid')
         ]);
+
+        //this is needed because of https://forge.typo3.org/issues/59992
+        $this->persistenceManager->clearState();
+
+        $query = $this->postRepository->createQuery();
+        $querySettings = $query->getQuerySettings();
+        $querySettings->setLanguageUid(1);
+        $querySettings->setLanguageOverlayMode(true);
+        $query->matching($query->equals('uid', 11));
+        $post2 = $query->execute()->getFirst();
+
+        $this->assertNull($post2);
     }
 
     /**
@@ -388,18 +389,6 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
         $query->matching($query->equals('uid', 2));
         $post2 = $query->execute()->getFirst();
 
-        $this->assertNull($post2);
-
-        //this is needed because of https://forge.typo3.org/issues/59992
-        $this->persistenceManager->clearState();
-
-        $query = $this->postRepository->createQuery();
-        $querySettings = $query->getQuerySettings();
-        $querySettings->setLanguageUid(1);
-        $querySettings->setLanguageOverlayMode(false);
-        $query->matching($query->equals('uid', 11));
-        $post2 = $query->execute()->getFirst();
-
         //the john is not translated but it should, see next query in this test
         $this->assertEquals(['Post 2 - DK', 2, 11, 'Blog 1', 1, 1, 'John', 1, 1], [
             $post2->getTitle(),
@@ -413,6 +402,18 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
             $post2->getAuthor()->_getProperty('_localizedUid')
         ]);
 
+        //this is needed because of https://forge.typo3.org/issues/59992
+        $this->persistenceManager->clearState();
+
+        $query = $this->postRepository->createQuery();
+        $querySettings = $query->getQuerySettings();
+        $querySettings->setLanguageUid(1);
+        $querySettings->setLanguageOverlayMode(false);
+        $query->matching($query->equals('uid', 11));
+        $post2 = $query->execute()->getFirst();
+
+        $this->assertNull($post2);
+
         //We're setting global context here to show that the result is different then one above.
         //this means that language which is set in global context influences overlays of relations
         $context = GeneralUtility::makeInstance(Context::class);
@@ -428,17 +429,7 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
         $query->matching($query->equals('uid', 11));
         $post2 = $query->execute()->getFirst();
 
-        $this->assertEquals(['Post 2 - DK', 2, 11, 'Blog 1 DK', 1, 2, 'Translated John', 1, 2], [
-            $post2->getTitle(),
-            $post2->getUid(),
-            $post2->_getProperty('_localizedUid'),
-            $post2->getBlog()->getTitle(),
-            $post2->getBlog()->getUid(),
-            $post2->getBlog()->_getProperty('_localizedUid'),
-            $post2->getAuthor()->getFirstname(),
-            $post2->getAuthor()->getUid(),
-            $post2->getAuthor()->_getProperty('_localizedUid')
-        ]);
+        $this->assertNull($post2);
     }
 
     public function queryFirst5PostsDataProvider()
@@ -553,24 +544,9 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                 'overlay' => true,
                 'expected' => [
                     [
-                        'title' => 'Post 5 - DK',
-                        'uid' => 5,
-                        '_localizedUid' => 13,
-                        'blog.title' => 'Blog 1',
-                        'blog.uid' => 1,
-                        'blog._localizedUid' => 1,
-                        'author.firstname' => 'John',
-                        'author.uid' => 1,
-                        'author._localizedUid' => 1,
-                        'secondAuthor.firstname' => 'John',
-                        'secondAuthor.uid' => 1,
-                        'secondAuthor._localizedUid' => 1,
-                        'tags' => [],
-                    ],
-                    [
-                        'title' => 'Post DK only',
-                        'uid' => 15,
-                        '_localizedUid' => 15,
+                        'title' => 'Post 4 - DK',
+                        'uid' => 4,
+                        '_localizedUid' => 12,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
@@ -606,9 +582,9 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                         'tags.2._localizedUid' => 4,
                     ],
                     [
-                        'title' => 'Post 6',
-                        'uid' => 6,
-                        '_localizedUid' => 6,
+                        'title' => 'Post DK only',
+                        'uid' => 15,
+                        '_localizedUid' => 15,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
@@ -619,37 +595,22 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                         'secondAuthor.uid' => 1,
                         'secondAuthor._localizedUid' => 1,
                         'tags' => [],
-
                     ],
                     [
-                        'title' => 'Post 1 - not translated',
-                        'uid' => 1,
-                        '_localizedUid' => 1,
+                        'title' => 'Post 7 - DK',
+                        'uid' => 7,
+                        '_localizedUid' => 14,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
                         'author.firstname' => 'John',
                         'author.uid' => 1,
                         'author._localizedUid' => 1,
-                        'secondAuthor.firstname' => 'Never translate me henry',
-                        'secondAuthor.uid' => 3,
-                        'secondAuthor._localizedUid' => 3,
-                        'tags.0.name' => 'Tag1',
-                        'tags.0.uid' => 1,
-                        'tags.0._localizedUid' => 1,
-                        'tags.1.name' => 'Tag2',
-                        'tags.1.uid' => 2,
-                        'tags.1._localizedUid' => 2,
-                        'tags.2.name' => 'Tag3',
-                        'tags.2.uid' => 3,
-                        'tags.2._localizedUid' => 3,
+                        'secondAuthor.firstname' => 'John',
+                        'secondAuthor.uid' => 1,
+                        'secondAuthor._localizedUid' => 1,
+                        'tags' => [],
                     ],
-                ],
-            ],
-            [
-                'language' => 1,
-                'overlay' => 'hideNonTranslated',
-                'expected' => [
                     [
                         'title' => 'Post 5 - DK',
                         'uid' => 5,
@@ -665,10 +626,16 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                         'secondAuthor._localizedUid' => 1,
                         'tags' => [],
                     ],
+                ],
+            ],
+            [
+                'language' => 1,
+                'overlay' => 'hideNonTranslated',
+                'expected' => [
                     [
-                        'title' => 'Post DK only',
-                        'uid' => 15,
-                        '_localizedUid' => 15,
+                        'title' => 'Post 4 - DK',
+                        'uid' => 4,
+                        '_localizedUid' => 12,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
@@ -704,9 +671,9 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                         'tags.2._localizedUid' => 4,
                     ],
                     [
-                        'title' => 'Post 6',
-                        'uid' => 6,
-                        '_localizedUid' => 6,
+                        'title' => 'Post DK only',
+                        'uid' => 15,
+                        '_localizedUid' => 15,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
@@ -719,34 +686,21 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                         'tags' => [],
                     ],
                     [
-                        'title' => 'Post 1 - not translated',
-                        'uid' => 1,
-                        '_localizedUid' => 1,
+                        'title' => 'Post 7 - DK',
+                        'uid' => 7,
+                        '_localizedUid' => 14,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
                         'author.firstname' => 'John',
                         'author.uid' => 1,
                         'author._localizedUid' => 1,
-                        'secondAuthor.firstname' => 'Never translate me henry',
-                        'secondAuthor.uid' => 3,
-                        'secondAuthor._localizedUid' => 3,
-                        'tags.0.name' => 'Tag1',
-                        'tags.0.uid' => 1,
-                        'tags.0._localizedUid' => 1,
-                        'tags.1.name' => 'Tag2',
-                        'tags.1.uid' => 2,
-                        'tags.1._localizedUid' => 2,
-                        'tags.2.name' => 'Tag3',
-                        'tags.2.uid' => 3,
-                        'tags.2._localizedUid' => 3,
+                        'secondAuthor.firstname' => 'John',
+                        'secondAuthor.uid' => 1,
+                        'secondAuthor._localizedUid' => 1,
+                        'tags' => [],
+
                     ],
-                ],
-            ],
-            [
-                'language' => 1,
-                'overlay' => false,
-                'expected' => [
                     [
                         'title' => 'Post 5 - DK',
                         'uid' => 5,
@@ -762,10 +716,16 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                         'secondAuthor._localizedUid' => 1,
                         'tags' => [],
                     ],
+                ],
+            ],
+            [
+                'language' => 1,
+                'overlay' => false,
+                'expected' => [
                     [
-                        'title' => 'Post DK only',
-                        'uid' => 15,
-                        '_localizedUid' => 15,
+                        'title' => 'Post 4 - DK',
+                        'uid' => 4,
+                        '_localizedUid' => 12,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
@@ -801,9 +761,24 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                         'tags.2._localizedUid' => 4,
                     ],
                     [
-                        'title' => 'Post 6',
-                        'uid' => 6,
-                        '_localizedUid' => 6,
+                        'title' => 'Post DK only',
+                        'uid' => 15,
+                        '_localizedUid' => 15,
+                        'blog.title' => 'Blog 1',
+                        'blog.uid' => 1,
+                        'blog._localizedUid' => 1,
+                        'author.firstname' => 'John',
+                        'author.uid' => 1,
+                        'author._localizedUid' => 1,
+                        'secondAuthor.firstname' => 'John',
+                        'secondAuthor.uid' => 1,
+                        'secondAuthor._localizedUid' => 1,
+                        'tags' => [],
+                    ],
+                    [
+                        'title' => 'Post 7 - DK',
+                        'uid' => 7,
+                        '_localizedUid' => 14,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
@@ -816,27 +791,19 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                         'tags' => [],
                     ],
                     [
-                        'title' => 'Post 1 - not translated',
-                        'uid' => 1,
-                        '_localizedUid' => 1,
+                        'title' => 'Post 5 - DK',
+                        'uid' => 5,
+                        '_localizedUid' => 13,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
                         'author.firstname' => 'John',
                         'author.uid' => 1,
                         'author._localizedUid' => 1,
-                        'secondAuthor.firstname' => 'Never translate me henry',
-                        'secondAuthor.uid' => 3,
-                        'secondAuthor._localizedUid' => 3,
-                        'tags.0.name' => 'Tag1',
-                        'tags.0.uid' => 1,
-                        'tags.0._localizedUid' => 1,
-                        'tags.1.name' => 'Tag2',
-                        'tags.1.uid' => 2,
-                        'tags.1._localizedUid' => 2,
-                        'tags.2.name' => 'Tag3',
-                        'tags.2.uid' => 3,
-                        'tags.2._localizedUid' => 3,
+                        'secondAuthor.firstname' => 'John',
+                        'secondAuthor.uid' => 1,
+                        'secondAuthor._localizedUid' => 1,
+                        'tags' => [],
                     ],
                 ],
             ],
@@ -862,7 +829,10 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
         $querySettings->setLanguageUid($languageUid);
         $querySettings->setLanguageOverlayMode($overlay);
 
-        $query->setOrderings(['content' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING]);
+        $query->setOrderings([
+            'content' => QueryInterface::ORDER_ASCENDING,
+            'uid' => QueryInterface::ORDER_ASCENDING
+        ]);
         $query->setLimit(5);
         $query->setOffset(0);
         $posts = $query->execute()->toArray();
@@ -875,6 +845,20 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
     {
         $lang0Expected = [
             [
+                'title' => 'Post 5',
+                'uid' => 5,
+                '_localizedUid' => 5,
+                'blog.title' => 'Blog 1',
+                'blog.uid' => 1,
+                'blog._localizedUid' => 1,
+                'author.firstname' => 'John',
+                'author.uid' => 1,
+                'author._localizedUid' => 1,
+                'secondAuthor.firstname' => 'John',
+                'secondAuthor.uid' => 1,
+                'secondAuthor._localizedUid' => 1,
+            ],
+            [
                 'title' => 'Post 6',
                 'uid' => 6,
                 '_localizedUid' => 6,
@@ -890,25 +874,11 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                 'tags' => [],
             ]
         ];
-        return [
-            [
-                'language' => 0,
-                'overlay' => true,
-                'expected' => $lang0Expected
-            ],
-            [
-                'language' => 0,
-                'overlay' => false,
-                'expected' => $lang0Expected
-            ],
-            [
-                'language' => 1,
-                'overlay' => true,
-                'expected' => [
+        $lang1Expected = [
                     [
-                        'title' => 'Post 6',
-                        'uid' => 6,
-                        '_localizedUid' => 6,
+                        'title' => 'Post 5 - DK',
+                        'uid' => 5,
+                        '_localizedUid' => 13,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
@@ -918,19 +888,11 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                         'secondAuthor.firstname' => 'John',
                         'secondAuthor.uid' => 1,
                         'secondAuthor._localizedUid' => 1,
-                        'tags' => []
-
                     ],
-                ],
-            ],
-            [
-                'language' => 1,
-                'overlay' => 'hideNonTranslated',
-                'expected' => [
                     [
-                        'title' => 'Post 6',
-                        'uid' => 6,
-                        '_localizedUid' => 6,
+                        'title' => 'Post DK only',
+                        'uid' => 15,
+                        '_localizedUid' => 15,
                         'blog.title' => 'Blog 1',
                         'blog.uid' => 1,
                         'blog._localizedUid' => 1,
@@ -940,36 +902,51 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
                         'secondAuthor.firstname' => 'John',
                         'secondAuthor.uid' => 1,
                         'secondAuthor._localizedUid' => 1,
-                        'tags' => [],
-                    ]
-                ],
+                    ],
+
+        ];
+        return [
+            [
+                'language' => 0,
+                'overlay' => true,
+                'expected' => $lang0Expected
+            ],
+            [
+                'language' => 0,
+                'overlay' => 'hideNonTranslated',
+                'expected' => $lang0Expected
+            ],
+                    [
+                'language' => 0,
+                'overlay' => false,
+                'expected' => $lang0Expected
+            ],
+            [
+                'language' => 1,
+                'overlay' => true,
+                'expected' => $lang1Expected
+            ],
+            [
+                'language' => 1,
+                'overlay' => 'hideNonTranslated',
+                'expected' => $lang1Expected,
             ],
             [
                 'language' => 1,
                 'overlay' => false,
-                'expected' => [
-                    [
-                        'title' => 'Post 6',
-                        'uid' => 6,
-                        '_localizedUid' => 6,
-                        'blog.title' => 'Blog 1',
-                        'blog.uid' => 1,
-                        'blog._localizedUid' => 1,
-                        'author.firstname' => 'John',
-                        'author.uid' => 1,
-                        'author._localizedUid' => 1,
-                        'secondAuthor.firstname' => 'John',
-                        'secondAuthor.uid' => 1,
-                        'secondAuthor._localizedUid' => 1,
-                        'tags' => [],
-                    ]
-                ],
+                'expected' => $lang1Expected,
             ],
         ];
     }
 
     /**
-     * This test check posts returned by repository, when changing language and languageOverlayMode
+     * This test check posts returned by repository, when filtering by property
+     *
+     * "Post 6" is not translated
+     * "Post 5" is translated as "Post 5 - DK"
+     * "Post DK only" has no translation parent
+     *
+     *
      *
      * @test
      * @dataProvider queryPostsByPropertyDataProvider
@@ -986,8 +963,13 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
         $querySettings->setLanguageOverlayMode($overlay);
 
         $query->matching(
-            $query->equals('title', 'Post 6')
+            $query->logicalOr(
+                $query->like('title', 'Post 5%'),
+                $query->like('title', 'Post 6%'),
+                $query->like('title', 'Post DK only')
+            )
         );
+        $query->setOrderings(['uid' => QueryInterface::ORDER_ASCENDING]);
         $posts = $query->execute()->toArray();
 
         $this->assertCount(count($expected), $posts);
@@ -1084,9 +1066,10 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
      * @dataProvider postsWithoutRespectingSysLanguageDataProvider
      * @param int $languageUid
      * @param string|bool $overlay
+     * @param string $languageMode
      * @param array $expected
      */
-    public function postsWithoutRespectingSysLanguage($languageUid, $overlay, $LanguageMode, $expected)
+    public function postsWithoutRespectingSysLanguage($languageUid, $overlay, $languageMode, $expected)
     {
         $context = GeneralUtility::makeInstance(Context::class);
         $context->setAspect('language', new LanguageAspect($languageUid, $languageUid, $overlay));
@@ -1094,8 +1077,7 @@ class QueryLocalizedDataTest extends \TYPO3\TestingFramework\Core\Functional\Fun
         $blogRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository::class);
         $query = $blogRepository->createQuery();
         $querySettings = $query->getQuerySettings();
-        $querySettings->setStoragePageIds([20]);
-        $querySettings->setLanguageMode($LanguageMode);
+        $querySettings->setLanguageMode($languageMode);
         $querySettings->setRespectSysLanguage(false);
 
         $posts = $query->execute()->toArray();
index 2aaed9f..bcfabdb 100644 (file)
@@ -15,6 +15,8 @@ namespace TYPO3\CMS\Extbase\Tests\Functional\Persistence;
  */
 
 use ExtbaseTeam\BlogExample\Domain\Model\Post;
+use TYPO3\CMS\Core\Context\Context;
+use TYPO3\CMS\Core\Context\LanguageAspect;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Persistence\QueryInterface;
 use TYPO3\CMS\Frontend\Page\PageRepository;
@@ -70,10 +72,15 @@ class TranslationTest extends \TYPO3\TestingFramework\Core\Functional\Functional
     }
 
     /**
-     * Minimal frontent environment to satisfy Extbase Typo3DbBackend
+     * Minimal frontend environment to satisfy Extbase Typo3DbBackend
      */
     protected function setUpBasicFrontendEnvironment()
     {
+        // in v9 overlay and language mode has different default values, so we need to set them here explicitely
+        // to match v8 behaviour
+        $context = GeneralUtility::makeInstance(Context::class);
+        $context->setAspect('language', new LanguageAspect(0, 0, LanguageAspect::OVERLAYS_OFF, ['off']));
+
         $environmentServiceMock = $this->createMock(\TYPO3\CMS\Extbase\Service\EnvironmentService::class);
         $environmentServiceMock
             ->expects($this->atLeast(1))