]> git.joonet.de Git - adminer.git/commitdiff
Fix dropping foreign keys linking to other database
authorJakub Vrana <jakub@vrana.cz>
Mon, 20 Feb 2017 15:59:13 +0000 (16:59 +0100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 20 Feb 2017 15:59:13 +0000 (16:59 +0100)
adminer/foreign.inc.php

index ef0dd6bc5ca4efc0820fdcf37dc964501a607615..07602db404c02cada94e3bf5f63306586054637d 100644 (file)
@@ -7,13 +7,15 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-
        $message = ($_POST["drop"] ? lang('Foreign key has been dropped.') : ($name != "" ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
        $location = ME . "table=" . urlencode($TABLE);
        
-       $row["source"] = array_filter($row["source"], 'strlen');
-       ksort($row["source"]); // enforce input order
-       $target = array();
-       foreach ($row["source"] as $key => $val) {
-               $target[$key] = $row["target"][$key];
+       if (!$_POST["drop"]) {
+               $row["source"] = array_filter($row["source"], 'strlen');
+               ksort($row["source"]); // enforce input order
+               $target = array();
+               foreach ($row["source"] as $key => $val) {
+                       $target[$key] = $row["target"][$key];
+               }
+               $row["target"] = $target;
        }
-       $row["target"] = $target;
        
        if ($jush == "sqlite") {
                queries_redirect($location, $message, recreate_table($TABLE, $TABLE, array(), array(), array(" $name" => ($_POST["drop"] ? "" : " " . format_foreign_key($row)))));