[BUGFIX] Extbase: Make transOrigDiffSourceField available in DataMap 54/42654/4
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 26 Aug 2015 15:20:23 +0000 (17:20 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Fri, 28 Aug 2015 12:22:43 +0000 (14:22 +0200)
The transOrigDiffSourceField needs to be available in the DataMap so
that the persistence layer can properly initialize that field when
inserting new objects into the database. This field is often set to
NOT NULL in the schema which leads to SQL errors when it's not included
in the records, for example with MySQL in strict mode.

Resolves: #69085
Releases: master
Change-Id: I021ac695ab495d3d7257dfae27bd596d49551ccf
Reviewed-on: http://review.typo3.org/42654
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/extbase/Classes/Persistence/Generic/Backend.php
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMap.php
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php

index eb008da..408f8b9 100644 (file)
@@ -671,6 +671,9 @@ class Backend implements \TYPO3\CMS\Extbase\Persistence\Generic\BackendInterface
                if ($dataMap->getTranslationOriginColumnName() !== NULL) {
                        $row[$dataMap->getTranslationOriginColumnName()] = 0;
                }
+               if ($dataMap->getTranslationOriginDiffSourceName() !== NULL) {
+                       $row[$dataMap->getTranslationOriginDiffSourceName()] = '';
+               }
                if ($parentObject !== NULL && $parentPropertyName) {
                        $parentColumnDataMap = $this->dataMapper->getDataMap(get_class($parentObject))->getColumnMap($parentPropertyName);
                        $relationTableMatchFields = $parentColumnDataMap->getRelationTableMatchFields();
index 963b8b5..c16e81c 100644 (file)
@@ -72,6 +72,11 @@ class DataMap {
        /**
         * @var string
         */
+       protected $translationOriginDiffSourceName;
+
+       /**
+        * @var string
+        */
        protected $modificationDateColumnName;
 
        /**
@@ -303,6 +308,25 @@ class DataMap {
        }
 
        /**
+        * Sets the name of a column holding the the diff data for the record which this record is a translation of.
+        *
+        * @param string $translationOriginDiffSourceName The field name
+        * @return void
+        */
+       public function setTranslationOriginDiffSourceName($translationOriginDiffSourceName) {
+               $this->translationOriginDiffSourceName = $translationOriginDiffSourceName;
+       }
+
+       /**
+        * Returns the name of a column holding the diff data for the record which this record is a translation of.
+        *
+        * @return string The field name
+        */
+       public function getTranslationOriginDiffSourceName() {
+               return $this->translationOriginDiffSourceName;
+       }
+
+       /**
         * Sets the name of a column holding the timestamp the record was modified
         *
         * @param string $modificationDateColumnName The field name
index d56e851..210a42b 100644 (file)
@@ -255,6 +255,9 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface {
                if (isset($controlSection['transOrigPointerField'])) {
                        $dataMap->setTranslationOriginColumnName($controlSection['transOrigPointerField']);
                }
+               if (isset($controlSection['transOrigDiffSourceField'])) {
+                       $dataMap->setTranslationOriginDiffSourceName($controlSection['transOrigDiffSourceField']);
+               }
                if (isset($controlSection['type'])) {
                        $dataMap->setRecordTypeColumnName($controlSection['type']);
                }