Merge branch '5.3'
authorMatthias Schmidt <gravatronics@live.com>
Sat, 12 Dec 2020 14:08:25 +0000 (15:08 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 12 Dec 2020 14:08:25 +0000 (15:08 +0100)
1  2 
wcfsetup/install/files/lib/system/database/table/DatabaseTableChangeProcessor.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 54436c8eca908eb43f3d3a94c9f9899a9265e3a3,fb83829dd2b5be0a902d0a85f33a4b8ff912a13d..f4f8b2c67baa57bb23ac277a058f18c898d42d61
@@@ -1128,55 -1081,57 +1137,64 @@@ class DatabaseTableChangeProcessor 
                                                                        ];
                                                                }
                                                        }
-                                                       else if ($columnPackageID !== $this->package->packageID) {
++                                                      else if ($column->getNewName()) {
 +                                                              $errors[] = [
 +                                                                      'columnName' => $column->getName(),
 +                                                                      'tableName' => $table->getName(),
-                                                                       'type' => 'foreignColumnChange'
++                                                                      'type' => 'renameNonexistingColumn'
 +                                                              ];
 +                                                      }
                                                }
-                                               else if ($column->getNewName()) {
-                                                       $errors[] = [
-                                                               'columnName' => $column->getName(),
-                                                               'tableName' => $table->getName(),
-                                                               'type' => 'renameNonexistingColumn'
-                                                       ];
-                                               }
-                                       }
-                                       
-                                       foreach ($table->getIndices() as $index) {
-                                               foreach ($existingIndices as $existingIndex) {
-                                                       if (empty(array_diff($index->getData(), $existingIndex->getData()))) {
-                                                               if ($index->willBeDropped()) {
-                                                                       if ($this->getIndexPackageID($table, $index) !== $this->package->packageID) {
-                                                                               $errors[] = [
-                                                                                       'columnNames' => implode(',', $existingIndex->getColumns()),
-                                                                                       'tableName' => $table->getName(),
-                                                                                       'type' => 'foreignIndexDrop'
-                                                                               ];
+                                               
+                                               foreach ($table->getIndices() as $index) {
+                                                       foreach ($existingIndices as $existingIndex) {
+                                                               if (empty(array_diff($index->getData(), $existingIndex->getData()))) {
+                                                                       if ($index->willBeDropped()) {
+                                                                               if ($this->getIndexPackageID($table, $index) !== $this->package->packageID) {
+                                                                                       $errors[] = [
+                                                                                               'columnNames' => implode(',', $existingIndex->getColumns()),
+                                                                                               'tableName' => $table->getName(),
+                                                                                               'type' => 'foreignIndexDrop',
+                                                                                       ];
+                                                                               }
                                                                        }
+                                                                       
+                                                                       continue 2;
                                                                }
-                                                               
-                                                               continue 2;
                                                        }
                                                }
-                                       }
-                                       
-                                       foreach ($table->getForeignKeys() as $foreignKey) {
-                                               foreach ($existingForeignKeys as $existingForeignKey) {
-                                                       if (empty(array_diff($foreignKey->getData(), $existingForeignKey->getData()))) {
-                                                               if ($foreignKey->willBeDropped()) {
-                                                                       if ($this->getForeignKeyPackageID($table, $foreignKey) !== $this->package->packageID) {
-                                                                               $errors[] = [
-                                                                                       'columnNames' => implode(',', $existingForeignKey->getColumns()),
-                                                                                       'tableName' => $table->getName(),
-                                                                                       'type' => 'foreignForeignKeyDrop'
-                                                                               ];
+                                               
+                                               foreach ($table->getForeignKeys() as $foreignKey) {
+                                                       foreach ($existingForeignKeys as $existingForeignKey) {
+                                                               if (empty(array_diff($foreignKey->getData(), $existingForeignKey->getData()))) {
+                                                                       if ($foreignKey->willBeDropped()) {
+                                                                               if ($this->getForeignKeyPackageID($table, $foreignKey) !== $this->package->packageID) {
+                                                                                       $errors[] = [
+                                                                                               'columnNames' => implode(',', $existingForeignKey->getColumns()),
+                                                                                               'tableName' => $table->getName(),
+                                                                                               'type' => 'foreignForeignKeyDrop',
+                                                                                       ];
+                                                                               }
                                                                        }
+                                                                       
+                                                                       continue 2;
                                                                }
-                                                               
-                                                               continue 2;
+                                                       }
+                                               }
+                                       }
+                               }
+                               
+                               foreach ($table->getIndices() as $index) {
+                                       if ($index->getType() === DatabaseTableIndex::PRIMARY_TYPE && !$index->willBeDropped()) {
+                                               foreach ($index->getColumns() as $indexColumn) {
+                                                       $column = $this->getColumnByName($indexColumn, $table, $existingTable);
+                                                       if ($column !== null && !$column->isNotNull()) {
+                                                               $errors[] = [
+                                                                       'columnName' => $indexColumn,
+                                                                       'columnNames' => implode(',', $index->getColumns()),
+                                                                       'tableName' => $table->getName(),
+                                                                       'type' => 'nullColumnInPrimaryIndex',
+                                                               ];
                                                        }
                                                }
                                        }
index 5dedd9206ad18339a765ec0c4675d9ef904ba36d,b44b0e263de7ed95c4aaaaa146598e07b1a53ae0..0d1557f8ef75ded88ddca9cffc65ec364e16de22
@@@ -1962,10 -1970,10 +1961,12 @@@ Die Datenbestände werden sorgfältig g
                Die Spalte {$error[tableName]}.{$error[columnName]} gehört zu einem anderen Paket und kann deshalb nicht gelöscht werden.
        {else if $error[type] === 'foreignColumnChange'}
                Die Spalte {$error[tableName]}.{$error[columnName]} gehört zu einem anderen Paket und kann deshalb nicht gelöscht werden.
 +      {else if $error[type] === 'renameNonexistingColumn'}
 +              Die Spalte {$error[tableName]}.{$error[columnName]} existiert nicht und kann deshalb nicht umbenannt werden.
        {else if $error[type] === 'foreignIndexDrop'}
                Der Index {$error[tableName]} ({$error[columnNames]}) gehört zu einem anderen Paket und kann deshalb nicht gelöscht werden.
+       {else if $error[type] === 'nullColumnInPrimaryIndex'}
+               Der Primärindex {$error[tableName]} ({$error[columnNames]}) enthält die Spalte {$error[columnName]}, deren Werte NULL sein können.
        {else if $error[type] === 'foreignForeignKeyDrop'}
                Der Fremdschlüssel {$error[tableName]} ({$error[columnNames]}) gehört zu einem anderen Paket und kann deshalb nicht gelöscht werden.
        {else}
index 37111834813810ff7b37fabc4c9bbe9485374be5,cb11df0c22ca228f4a9626b249711618eaee2fb6..18ae70978f40dd9c2ac248fd4a066cce9e16135a
@@@ -1946,10 -1954,10 +1945,12 @@@ If you have <strong>already bought the 
                The column {$error[tableName]}.{$error[columnName]} belongs to a different package and thus cannot be dropped.
        {else if $error[type] === 'foreignColumnChange'}
                The column {$error[tableName]}.{$error[columnName]} belongs to a different package and thus cannot be dropped.
 +      {else if $error[type] === 'renameNonexistingColumn'}
 +              The column {$error[tableName]}.{$error[columnName]} does not exist and thus cannot be renamed.
        {else if $error[type] === 'foreignIndexDrop'}
                The index {$error[tableName]} ({$error[columnNames]}) belongs to a different package and thus cannot be dropped.
+       {else if $error[type] === 'nullColumnInPrimaryIndex'}
+               The primary index {$error[tableName]} ({$error[columnNames]}) contains the column {$error[columnName]} whose values can be NULL.
        {else if $error[type] === 'foreignForeignKeyDrop'}
                The foreign key {$error[tableName]} ({$error[columnNames]}) belongs to a different package and thus cannot be dropped.
        {else}