[BUGFIX] Extbase: Cast sys_language_uid to integer in updateObject() 53/42653/3
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Sat, 15 Aug 2015 20:21:40 +0000 (22:21 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 15 Aug 2015 23:31:13 +0000 (01:31 +0200)
Inserting a new object into the database is a two step process in
extbase where the first step is creating a mostly blank record to obtain
the uid for the new record and the second step is creating all related
objects updating the initial record with the final values afterwards.
Due to this process the languageUid in the freshly created object can be
NULL, which is then used without a cast in updateObject(). If the
database enforces not inserting NULL values into columns defined as NOT
NULL this leads to SQL errors.

This is fixed by casting the languageUid to int before using it.

Resolves: #69088
Releases: master
Change-Id: I0c4519520ccc312f68a025a21d3b040c07446992
Reviewed-on: http://review.typo3.org/42653
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>

index b2b79b0..3e03cbc 100644 (file)
@@ -872,7 +872,7 @@ class Backend implements \TYPO3\CMS\Extbase\Persistence\Generic\BackendInterface
                $this->addCommonFieldsToRow($object, $row);
                $row['uid'] = $object->getUid();
                if ($dataMap->getLanguageIdColumnName() !== NULL) {
-                       $row[$dataMap->getLanguageIdColumnName()] = $object->_getProperty('_languageUid');
+                       $row[$dataMap->getLanguageIdColumnName()] = (int)$object->_getProperty('_languageUid');
                        if ($object->_getProperty('_localizedUid') !== NULL) {
                                $row['uid'] = $object->_getProperty('_localizedUid');