]> git.joonet.de Git - adminer.git/commitdiff
Move $enum_length to Driver
authorJakub Vrana <jakub@vrana.cz>
Thu, 6 Mar 2025 13:51:24 +0000 (14:51 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 6 Mar 2025 13:51:24 +0000 (14:51 +0100)
adminer/drivers/mysql.inc.php
adminer/include/bootstrap.inc.php
adminer/include/driver.inc.php
adminer/include/editing.inc.php
adminer/index.php

index 1a3d765e74fa22d13c331bf5ef0e26318f036213..9b9aefae365feb47a7e423316df7f637a9f288e1 100644 (file)
@@ -955,10 +955,10 @@ if (!defined("DRIVER")) {
        * @return array ["fields" => ["field" => , "type" => , "length" => , "unsigned" => , "inout" => , "collation" => ], "returns" => , "definition" => , "language" => ]
        */
        function routine($name, $type) {
-               global $connection, $enum_length, $driver;
+               global $connection, $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,]+)['\"]?)?";
+               $type_pattern = "((" . implode("|", array_merge(array_keys($driver->types()), $aliases)) . ")\\b(?:\\s*\\(((?:[^'\")]|$driver->enumLength)++)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s,]+)['\"]?)?";
                $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);
@@ -968,7 +968,7 @@ if (!defined("DRIVER")) {
                        $fields[] = array(
                                "field" => str_replace("``", "`", $param[2]) . $param[3],
                                "type" => strtolower($param[5]),
-                               "length" => preg_replace_callback("~$enum_length~s", 'Adminer\normalize_enum', $param[6]),
+                               "length" => preg_replace_callback("~$driver->enumLength~s", 'Adminer\normalize_enum', $param[6]),
                                "unsigned" => strtolower(preg_replace('~\s+~', ' ', trim("$param[8] $param[7]"))),
                                "null" => 1,
                                "full_type" => $param[4],
index f2a57fe5995f7390e9906a82c48c0234d8b5d342..86a63240762174fea3d2923e279df8c7f7772e0c 100644 (file)
@@ -35,7 +35,7 @@ if ($_GET["script"] == "version") {
        exit;
 }
 
-global $adminer, $connection, $driver, $drivers, $enum_length, $error, $HTTPS, $jush, $LANG, $langs, $permanent, $has_token, $token, $translations, $VERSION; // allows including Adminer inside a function
+global $adminer, $connection, $driver, $drivers, $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"];
index 102f118dc01e6c81f658646a712f96ef22798739..0b8bd91b647145cb6c6e1603494a50c791a0596e 100644 (file)
@@ -35,6 +35,7 @@ abstract class SqlDriver {
        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";
+       var $enumLength = "'(?:''|[^'\\\\]|\\\\.)*'";
 
        /** Create object for performing database operations
        * @param Db
index d9686d4e1a08e060370399f3b7c3722c740d1155..3d16d35ce1cd1fdce859bec1e945d5b2eb3447b7 100644 (file)
@@ -256,8 +256,8 @@ function get_partitions_info($table) {
 * @return string
 */
 function process_length($length) {
-       global $enum_length;
-       return (preg_match("~^\\s*\\(?\\s*$enum_length(?:\\s*,\\s*$enum_length)*+\\s*\\)?\\s*\$~", $length) && preg_match_all("~$enum_length~", $length, $matches)
+       global $driver;
+       return (preg_match("~^\\s*\\(?\\s*$driver->enumLength(?:\\s*,\\s*$enum_length)*+\\s*\\)?\\s*\$~", $length) && preg_match_all("~$enum_length~", $length, $matches)
                ? "(" . implode(",", $matches[0]) . ")"
                : preg_replace('~^[0-9].*~', '(\0)', preg_replace('~[^-0-9,+()[\]]~', '', $length))
        );
index c2f40800e6d00d7f01c5ddd164e7217423068312..780652309517e8e52cd95fefccc71a67c7853920 100644 (file)
@@ -12,8 +12,6 @@ namespace Adminer;
 include "./include/bootstrap.inc.php";
 include "./include/tmpfile.inc.php";
 
-$enum_length = "'(?:''|[^'\\\\]|\\\\.)*'";
-
 if (isset($_GET["select"]) && ($_POST["edit"] || $_POST["clone"]) && !$_POST["save"]) {
        $_GET["edit"] = $_GET["select"];
 }