From f711135574865184de91a525b6f6a7915247399a Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Thu, 6 Mar 2025 14:49:08 +0100 Subject: [PATCH] Move $inout to Driver --- adminer/drivers/mysql.inc.php | 4 ++-- adminer/include/bootstrap.inc.php | 2 +- adminer/include/driver.inc.php | 1 + adminer/include/editing.inc.php | 8 ++++---- adminer/index.php | 1 - 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index a4336a19..1a3d765e 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -955,11 +955,11 @@ if (!defined("DRIVER")) { * @return array ["fields" => ["field" => , "type" => , "length" => , "unsigned" => , "inout" => , "collation" => ], "returns" => , "definition" => , "language" => ] */ function routine($name, $type) { - global $connection, $enum_length, $inout, $driver; + global $connection, $enum_length, $driver; $aliases = array("bool", "boolean", "integer", "double precision", "real", "dec", "numeric", "fixed", "national char", "national varchar"); $space = "(?:\\s|/\\*[\s\S]*?\\*/|(?:#|-- )[^\n]*\n?|--\r?\n)"; $type_pattern = "((" . implode("|", array_merge(array_keys($driver->types()), $aliases)) . ")\\b(?:\\s*\\(((?:[^'\")]|$enum_length)++)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s,]+)['\"]?)?"; - $pattern = "$space*(" . ($type == "FUNCTION" ? "" : $inout) . ")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$type_pattern"; + $pattern = "$space*(" . ($type == "FUNCTION" ? "" : $driver->inout) . ")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$type_pattern"; $create = $connection->result("SHOW CREATE $type " . idf_escape($name), 2); preg_match("~\\(((?:$pattern\\s*,?)*)\\)\\s*" . ($type == "FUNCTION" ? "RETURNS\\s+$type_pattern\\s+" : "") . "(.*)~is", $create, $match); $fields = array(); diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index 8a23fe73..f2a57fe5 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -35,7 +35,7 @@ if ($_GET["script"] == "version") { exit; } -global $adminer, $connection, $driver, $drivers, $enum_length, $error, $HTTPS, $inout, $jush, $LANG, $langs, $permanent, $has_token, $token, $translations, $VERSION; // allows including Adminer inside a function +global $adminer, $connection, $driver, $drivers, $enum_length, $error, $HTTPS, $jush, $LANG, $langs, $permanent, $has_token, $token, $translations, $VERSION; // allows including Adminer inside a function if (!$_SERVER["REQUEST_URI"]) { // IIS 5 compatibility $_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"]; diff --git a/adminer/include/driver.inc.php b/adminer/include/driver.inc.php index ad25c444..102f118d 100644 --- a/adminer/include/driver.inc.php +++ b/adminer/include/driver.inc.php @@ -34,6 +34,7 @@ abstract class SqlDriver { var $functions = array(); ///< @var array functions used in select var $grouping = array(); ///< @var array grouping functions used in select var $onActions = "RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT"; ///< @var string used in foreign_keys() + var $inout = "IN|OUT|INOUT"; /** Create object for performing database operations * @param Db diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index f738d2da..d9686d4e 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -338,7 +338,7 @@ function type_class($type) { * @return null */ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = array()) { - global $inout; + global $driver; $fields = array_values($fields); $default_class = (($_POST ? $_POST["defaults"] : adminer_setting("defaults")) ? "" : " class='hidden'"); $comment_class = (($_POST ? $_POST["comments"] : adminer_setting("comments")) ? "" : " class='hidden'"); @@ -372,7 +372,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra $display = (isset($_POST["add"][$i-1]) || (isset($field["field"]) && !$_POST["drop_col"][$i])) && (support("drop_col") || $orig == ""); ?> > -" . html_select("fields[$i][inout]", explode("|", $inout), $field["inout"]) : "") . ""; ?> +" . html_select("fields[$i][inout]", explode("|", $driver->inout), $field["inout"]) : "") . ""; ?> " data-maxlength="64" autocapitalize="off" aria-labelledby="label-name"> @@ -521,13 +521,13 @@ function create_trigger($on, $row) { * @return string */ function create_routine($routine, $row) { - global $inout, $jush; + global $driver, $jush; $set = array(); $fields = (array) $row["fields"]; ksort($fields); // enforce fields order foreach ($fields as $field) { if ($field["field"] != "") { - $set[] = (preg_match("~^($inout)\$~", $field["inout"]) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET"); + $set[] = (preg_match("~^($driver->inout)\$~", $field["inout"]) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET"); } } $definition = rtrim($row["definition"], ";"); diff --git a/adminer/index.php b/adminer/index.php index 8e004ea9..c2f40800 100644 --- a/adminer/index.php +++ b/adminer/index.php @@ -13,7 +13,6 @@ include "./include/bootstrap.inc.php"; include "./include/tmpfile.inc.php"; $enum_length = "'(?:''|[^'\\\\]|\\\\.)*'"; -$inout = "IN|OUT|INOUT"; if (isset($_GET["select"]) && ($_POST["edit"] || $_POST["clone"]) && !$_POST["save"]) { $_GET["edit"] = $_GET["select"];