]> git.joonet.de Git - adminer.git/commitdiff
Editor: Fix building links with array parameters
authorPeter Knut <peter@pematon.com>
Wed, 9 Oct 2024 07:19:37 +0000 (09:19 +0200)
committerJakub Vrana <jakub@vrana.cz>
Wed, 19 Feb 2025 10:16:40 +0000 (11:16 +0100)
This solves a situation when enum data type has a foreign key to another table.

adminer/select.inc.php

index d213ae9626a84f954ad620d9ea4b73680956abe4..91c83e1ab1ebdc25f379127f585f6db4f0bd96bc 100644 (file)
@@ -224,14 +224,16 @@ if (is_ajax()) {
 
 $set = null;
 if (isset($rights["insert"]) || !support("table")) {
-       $set = "";
+       $params = [];
        foreach ((array) $_GET["where"] as $val) {
-               if ($foreign_keys[$val["col"]] && count($foreign_keys[$val["col"]]) == 1 && ($val["op"] == "="
-                       || (!$val["op"] && !preg_match('~[_%]~', $val["val"])) // LIKE in Editor
+               if (isset($foreign_keys[$val["col"]]) && count($foreign_keys[$val["col"]]) == 1
+                       && ($val["op"] == "=" || (!$val["op"] && (is_array($val["val"]) || !preg_match('~[_%]~', $val["val"]))) // LIKE in Editor
                )) {
-                       $set .= "&set" . urlencode("[" . bracket_escape($val["col"]) . "]") . "=" . urlencode($val["val"]);
+                       $params["set" . "[" . bracket_escape($val["col"]) . "]"] = $val["val"];
                }
        }
+
+       $set = $params ? "&" . http_build_query($params) : "";
 }
 $adminer->selectLinks($table_status, $set);
 
@@ -430,7 +432,7 @@ if (!$columns && support("table")) {
                                                                $link .= where_link($i++, $k, $v);
                                                        }
                                                }
-                                               
+
                                                $val = select_value($val, $link, $field, $text_length);
                                                $id = h("val[$unique_idf][" . bracket_escape($key) . "]");
                                                $value = $_POST["val"][$unique_idf][bracket_escape($key)];
@@ -491,7 +493,7 @@ if (!$columns && support("table")) {
                                        echo "\n";
                                }
                        }
-                       
+
                        echo "<div class='footer'><div>\n";
                        if ($rows || $page) {
                                if ($pagination) {
@@ -523,7 +525,7 @@ if (!$columns && support("table")) {
                                        }
                                        echo "</fieldset>\n";
                                }
-                               
+
                                echo "<fieldset>";
                                echo "<legend>" . lang('Whole result') . "</legend>";
                                $display_rows = ($exact_count ? "" : "~ ") . $found_rows;