Skip to content

Commit

Permalink
refactor: cast the foreign field to an array prior to using it
Browse files Browse the repository at this point in the history
right now, there is no way to select multiple columns for an index, even though mysql allows it. Since the destination_foreign_column will always be a string at the moment, I am casting it to an array prior to using it, as the code expects it to be one.

we were passing a string into the function to create sql to create a foreign key constraint. This function expects an array, since foreign keys can reference multiple columns.

Fixes Issue phpmyadmin#13941

Signed-off-by: Leonid Sklyut <lsklyut@kbra.com>
  • Loading branch information
philly-php committed Feb 23, 2018
1 parent a3b1e80 commit 5809951
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libraries/classes/Table.php
Expand Up @@ -2286,7 +2286,7 @@ public function updateForeignKeys(array $destination_foreign_db,
$master_field = $multi_edit_columns_name[$master_field_md5];

$foreign_table = $destination_foreign_table[$master_field_md5];
$foreign_field = $destination_foreign_column[$master_field_md5];
$foreign_field = (array) $destination_foreign_column[$master_field_md5];

if (isset($existrel_foreign[$master_field_md5]['ref_db_name'])) {
$ref_db_name = $existrel_foreign[$master_field_md5]['ref_db_name'];
Expand Down Expand Up @@ -2378,7 +2378,7 @@ public function updateForeignKeys(array $destination_foreign_db,
}

$create_query = $this->_getSQLToCreateForeignKey(
$table, $master_field, $foreign_db, $foreign_table, (array) $foreign_field,
$table, $master_field, $foreign_db, $foreign_table, $foreign_field,
$_REQUEST['constraint_name'][$master_field_md5],
$options_array[$_REQUEST['on_delete'][$master_field_md5]],
$options_array[$_REQUEST['on_update'][$master_field_md5]]
Expand Down

0 comments on commit 5809951

Please sign in to comment.