[BUGFIX] allowLanguageSynchronization flaws with pages_language_overlay 71/51671/2
authorOliver Hader <oliver@typo3.org>
Tue, 14 Feb 2017 14:03:14 +0000 (15:03 +0100)
committerBenni Mack <benni@typo3.org>
Tue, 14 Feb 2017 14:28:35 +0000 (15:28 +0100)
The allowLanguageSynchronization does not work correctly with the tables
pages and pages_language_overlay. This change at least provides the basic
functionality for regular non-relational values (which might work, but are
not verified with tests properly).

Resolves: #79809
Releases: master
Change-Id: Ia8402799828490e695fd7bfed1d1df51c6c43f3e
Reviewed-on: https://review.typo3.org/51671
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/DataHandling/Localization/DataMapProcessor.php
typo3/sysext/core/Tests/Functional/DataHandling/IRRE/ForeignField/DataSet/LiveDefaultPages.csv
typo3/sysext/core/Tests/Functional/DataHandling/Regular/AbstractActionTestCase.php
typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/ActionTest.php
typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/DataSet/localizePageWSynchronization.csv [new file with mode: 0644]

index 01dd6b0..2654a61 100644 (file)
@@ -38,6 +38,10 @@ use TYPO3\CMS\Core\Utility\StringUtility;
  * the data-map directly, which ensures proper history entries as a side-effect.
  * For inline relational record editing, this processor either triggers the copy
  * or localize actions by instantiation a new local DataHandler instance.
+ *
+ * Namings in this class:
+ * + forTableName, forId always refers to dependencies data is provided *for*
+ * + fromTableName, fromId always refers to ancestors data is retrieved *from*
  */
 class DataMapProcessor
 {
@@ -108,28 +112,37 @@ class DataMapProcessor
      */
     protected function collectItems(string $tableName, array $idValues)
     {
-        if (!$this->isApplicable($tableName)) {
+        $forTableName = $tableName;
+        if ($forTableName === 'pages') {
+            $forTableName = 'pages_language_overlay';
+        }
+
+        if (!$this->isApplicable($forTableName)) {
             return;
         }
 
         $fieldNames = [
             'uid' => 'uid',
             'l10n_state' => 'l10n_state',
-            'language' => $GLOBALS['TCA'][$tableName]['ctrl']['languageField'],
-            'parent' => $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'],
+            'language' => $GLOBALS['TCA'][$forTableName]['ctrl']['languageField'],
+            'parent' => $GLOBALS['TCA'][$forTableName]['ctrl']['transOrigPointerField'],
         ];
-        if (!empty($GLOBALS['TCA'][$tableName]['ctrl']['translationSource'])) {
-            $fieldNames['source'] = $GLOBALS['TCA'][$tableName]['ctrl']['translationSource'];
+        if (!empty($GLOBALS['TCA'][$forTableName]['ctrl']['translationSource'])) {
+            $fieldNames['source'] = $GLOBALS['TCA'][$forTableName]['ctrl']['translationSource'];
         }
 
-        $translationValues = $this->fetchTranslationValues(
-            $tableName,
-            $fieldNames,
-            $this->filterNumericIds(array_keys($idValues))
-        );
+        $translationValues = [];
+        // Fetching parent/source pointer values does not make sense for pages
+        if ($tableName !== 'pages') {
+            $translationValues = $this->fetchTranslationValues(
+                $tableName,
+                $fieldNames,
+                $this->filterNumericIds(array_keys($idValues))
+            );
+        }
 
         $dependencies = $this->fetchDependencies(
-            $tableName,
+            $forTableName,
             $this->filterNumericIds(array_keys($idValues))
         );
 
@@ -559,7 +572,7 @@ class DataMapProcessor
     }
 
     /**
-     * Create arary of dependent records
+     * Fetches translation dependencies for a given parent/source record ids.
      *
      * @param string $tableName
      * @param array $ids
index 335d96c..198fc67 100644 (file)
@@ -1,6 +1,6 @@
 "pages",,,,,,,,,,,
-,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title"
-,1,0,256,0,0,0,0,0,0,0,"FunctionalTest"
-,88,1,256,0,0,0,0,0,0,0,"DataHandlerTest"
-,89,88,256,0,0,0,0,0,0,0,"Relations"
-,90,88,512,0,0,0,0,0,0,0,"Target"
+,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title","media"
+,1,0,256,0,0,0,0,0,0,0,"FunctionalTest",0
+,88,1,256,0,0,0,0,0,0,0,"DataHandlerTest",0
+,89,88,256,0,0,0,0,0,0,0,"Relations",0
+,90,88,512,0,0,0,0,0,0,0,"Target",0
index 145a75b..6662fbf 100644 (file)
@@ -259,7 +259,16 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
      */
     public function localizePage()
     {
-        $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
+        $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
+        $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
+    }
+
+    public function localizePageWithLanguageSynchronization()
+    {
+        $GLOBALS['TCA']['pages_language_overlay']['columns']['title']['config']['behaviour']['allowLanguageSynchronization'] = true;
+        $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
+        $this->recordIds['localizedPageId'] = $localizedTableIds[self::TABLE_Page][self::VALUE_PageId];
+        $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, ['title' => 'Testing #1']);
     }
 
     /**
index 133a6b3..3959ea2 100644 (file)
@@ -365,6 +365,20 @@ class ActionTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\A
 
     /**
      * @test
+     * @see DataSet/localizePageWSynchronization.csv
+     */
+    public function localizePageWithLanguageSynchronization()
+    {
+        parent::localizePageWithLanguageSynchronization();
+        $this->assertAssertionDataSet('localizePageWSynchronization');
+
+        $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
+        $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
+            ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
+    }
+
+    /**
+     * @test
      * @see DataSet/changePageRecordSorting.csv
      */
     public function changePageSorting()
diff --git a/typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/DataSet/localizePageWSynchronization.csv b/typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/DataSet/localizePageWSynchronization.csv
new file mode 100644 (file)
index 0000000..9e3a944
--- /dev/null
@@ -0,0 +1,17 @@
+pages
+,uid,pid,sorting,deleted,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title
+,1,0,256,0,0,0,0,0,0,0,FunctionalTest
+,88,1,256,0,0,0,0,0,0,0,DataHandlerTest
+,89,88,256,0,0,0,0,0,0,0,Testing #1
+,90,88,512,0,0,0,0,0,0,0,Target
+pages_language_overlay
+,uid,pid,deleted,sys_language_uid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,title
+,1,89,0,1,0,0,0,0,Testing #1
+tt_content
+,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,l10n_source,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header
+,297,89,256,0,0,0,0,0,0,0,0,0,0,Regular Element #1
+,298,89,512,0,0,0,0,0,0,0,0,0,0,Regular Element #2
+,299,89,768,0,0,0,0,0,0,0,0,0,0,Regular Element #3
+,300,89,1024,0,1,299,299,299,0,0,0,0,0,[Translate to Dansk:] Regular Element #3
+,301,89,384,0,1,297,297,297,0,0,0,0,0,[Translate to Dansk:] Regular Element #1
+,302,89,448,0,2,297,301,301,0,0,0,0,0,[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1