[BUGFIX] Prevent extbase persistance to try last_insert_id on relations 51/52251/3
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 29 Mar 2017 18:39:02 +0000 (20:39 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Thu, 30 Mar 2017 02:47:36 +0000 (04:47 +0200)
Postgres will fail with an error, if a table sequence is requested for
a table without auto_increment column. MySql will just return '0'.
Test the relation type before trying to persist mm relations to
prevent that error.

Resolves: #80562
Releases: master
Change-Id: Ia429e681a8ec1805996da03bd738b8347a00e40d
Reviewed-on: https://review.typo3.org/52251
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php

index 9a725fd..669bcbb 100644 (file)
@@ -146,9 +146,10 @@ class Typo3DbBackend implements BackendInterface, SingletonInterface
             throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230766);
         }
 
-        $uid = $connection->lastInsertId($tableName);
-
+        $uid = 0;
         if (!$isRelation) {
+            // Relation tables have no auto_increment column, so no retrieval must be tried.
+            $uid = $connection->lastInsertId($tableName);
             $this->clearPageCache($tableName, $uid);
         }
         return (int)$uid;