[BUGFIX] Respect SQL table names max length in install tool
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Database / Schema / ConnectionMigrator.php
index 9b097a0..c74d39a 100644 (file)
@@ -41,6 +41,11 @@ class ConnectionMigrator
      */
     protected $deletedPrefix = 'zzz_deleted_';
 
+    /**
+     * @var int
+     */
+    protected $maxTableNameLength = 64;
+
     /**
      * @var Connection
      */
@@ -876,6 +881,13 @@ class ConnectionMigrator
             );
 
             $tableDiff->newName = $this->deletedPrefix . $removedTable->getName();
+            if (strlen($tableDiff->newName) > $this->maxTableNameLength) {
+                $shortTableName = substr(
+                    $removedTable->getName(),
+                    strlen($removedTable->getName()) + strlen($this->deletedPrefix) - $this->maxTableNameLength
+                );
+                $tableDiff->newName = $this->deletedPrefix . $shortTableName;
+            }
             $schemaDiff->changedTables[$index] = $tableDiff;
             unset($schemaDiff->removedTables[$index]);
         }