[BUGFIX] Determine default language as origin correctly 76/57676/2
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 25 Jul 2018 06:53:42 +0000 (08:53 +0200)
committerNicole Cordes <typo3@cordes.co>
Fri, 27 Jul 2018 11:25:20 +0000 (13:25 +0200)
Resolves: #85638
Releases: master, 8.7
Change-Id: I98ecaef360d5a27e965cbb67c5719729054b9c37
Reviewed-on: https://review.typo3.org/57676
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/backend/Classes/Domain/Repository/Localization/LocalizationRepository.php
typo3/sysext/backend/Tests/Functional/Controller/Page/Fixtures/tt_content-danish-language.xml
typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php
typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/LocalizationRepositoryTest.php

index cc4142a..0d69f8a 100644 (file)
@@ -66,7 +66,7 @@ class LocalizationRepository
                     $queryBuilder->quoteIdentifier('tt_content_orig.uid')
                 )
             )
-            ->join(
+            ->leftJoin(
                 'tt_content_orig',
                 'sys_language',
                 'sys_language',
index 9c08795..6369d79 100644 (file)
@@ -5,6 +5,7 @@
                <pid>1</pid>
                <sys_language_uid>1</sys_language_uid>
                <l18n_parent>1</l18n_parent>
+               <l10n_source>1</l10n_source>
                <deleted>0</deleted>
                <t3ver_oid>0</t3ver_oid>
                <t3ver_wsid>0</t3ver_wsid>
@@ -17,6 +18,7 @@
                <pid>1</pid>
                <sys_language_uid>1</sys_language_uid>
                <l18n_parent>2</l18n_parent>
+               <l10n_source>2</l10n_source>
                <deleted>0</deleted>
                <t3ver_oid>0</t3ver_oid>
                <t3ver_wsid>0</t3ver_wsid>
@@ -29,6 +31,7 @@
                <pid>1</pid>
                <sys_language_uid>1</sys_language_uid>
                <l18n_parent>3</l18n_parent>
+               <l10n_source>3</l10n_source>
                <deleted>0</deleted>
                <t3ver_oid>0</t3ver_oid>
                <t3ver_wsid>0</t3ver_wsid>
index ef8b789..6a7018d 100644 (file)
@@ -72,8 +72,7 @@ class LocalizationControllerTest extends \TYPO3\TestingFramework\Core\Functional
 
         $this->subject = $this->getMockBuilder(LocalizationController::class)
             ->setMethods(['getPageColumns'])
-            ->getMock()
-        ;
+            ->getMock();
     }
 
     /**
@@ -191,6 +190,38 @@ class LocalizationControllerTest extends \TYPO3\TestingFramework\Core\Functional
     /**
      * @test
      */
+    public function defaultLanguageIsFoundAsOriginLanguage(): void
+    {
+        $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Controller/Page/Fixtures/tt_content-danish-language.xml');
+
+        // Create another content element in default language
+        $data = [
+            'tt_content' => [
+                'NEW123456' => [
+                    'sys_language_uid' => 0,
+                    'header' => 'New content element',
+                    'pid' => 1,
+                    'colPos' => 0,
+                ],
+            ],
+        ];
+        $dataHandler = new DataHandler();
+        $dataHandler->start($data, []);
+        $dataHandler->process_datamap();
+        $dataHandler->process_cmdmap();
+
+        $request = (new ServerRequest())->withQueryParams([
+            'pageId'         => 1, // page uid, the records are stored on
+            'languageId'     => 1  // current language id
+        ]);
+
+        $usedLanguages = (string)$this->subject->getUsedLanguagesInPage($request)->getBody();
+        $this->assertThat($usedLanguages, $this->stringContains('"uid":0'));
+    }
+
+    /**
+     * @test
+     */
     public function recordLocalizeSummaryRespectsWorkspaceEncapsulationForDeletedRecords(): void
     {
         // Delete record 2 within workspace 1
index 9dbffed..c11a604 100644 (file)
@@ -50,7 +50,7 @@ class LocalizationRepositoryTest extends \TYPO3\TestingFramework\Core\Functional
     public function fetchOriginLanguageDataProvider(): array
     {
         return [
-            'default language returns false' => [
+            'default language returns empty array' => [
                 1,
                 0,
                 []
@@ -58,7 +58,9 @@ class LocalizationRepositoryTest extends \TYPO3\TestingFramework\Core\Functional
             'connected mode translated from default language' => [
                 1,
                 1,
-                []
+                [
+                    'sys_language_uid' => 0
+                ]
             ],
             'connected mode translated from non default language' => [
                 1,
@@ -70,7 +72,9 @@ class LocalizationRepositoryTest extends \TYPO3\TestingFramework\Core\Functional
             'free mode translated from default language' => [
                 2,
                 1,
-                []
+                [
+                    'sys_language_uid' => 0
+                ]
             ],
             'free mode translated from non default language' => [
                 2,
@@ -82,7 +86,9 @@ class LocalizationRepositoryTest extends \TYPO3\TestingFramework\Core\Functional
             'free mode copied from another page translated from default language' => [
                 3,
                 1,
-                []
+                [
+                    'sys_language_uid' => 0
+                ]
             ],
             'free mode copied from another page translated from non default language' => [
                 3,