]> git.joonet.de Git - adminer.git/commitdiff
Notices: Store maria into a declared variable
authorJakub Vrana <jakub@vrana.cz>
Mon, 24 Mar 2025 04:58:35 +0000 (05:58 +0100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 24 Mar 2025 06:30:22 +0000 (07:30 +0100)
16 files changed:
adminer/drivers/mssql.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/oracle.inc.php
adminer/drivers/pgsql.inc.php
adminer/drivers/sqlite.inc.php
adminer/include/adminer.inc.php
adminer/include/auth.inc.php
adminer/include/editing.inc.php
adminer/include/pdo.inc.php
plugins/codemirror.php
plugins/drivers/clickhouse.php
plugins/drivers/elastic.php
plugins/drivers/firebird.php
plugins/drivers/imap.php
plugins/drivers/mongo.php
plugins/drivers/simpledb.php

index 80742ccc90e170e08401ddb2659f210ef1c99d21..71035a0147a5d479d7487fb7473ae47f9d4e042a 100644 (file)
@@ -13,7 +13,7 @@ if (isset($_GET["mssql"])) {
        define('Adminer\DRIVER', "mssql");
        if (extension_loaded("sqlsrv") && $_GET["ext"] != "pdo") {
                class Db {
-                       public $extension = "sqlsrv", $server_info, $affected_rows, $errno, $error;
+                       public $extension = "sqlsrv", $flavor = '', $server_info, $affected_rows, $errno, $error;
                        private $link, $result;
 
                        private function get_error() {
index e4389aa87d45dbc15074b15456f738f3d21a83b6..0346553261b81bd1e2f3b58eb89a1ce73be53f70 100644 (file)
@@ -8,7 +8,7 @@ if (!defined('Adminer\DRIVER')) {
        // MySQLi supports everything, MySQL doesn't support multiple result sets, PDO_MySQL doesn't support orgtable
        if (extension_loaded("mysqli") && $_GET["ext"] != "pdo") {
                class Db extends \MySQLi {
-                       public $extension = "MySQLi";
+                       public $extension = "MySQLi", $flavor = '';
 
                        function __construct() {
                                parent::init();
@@ -63,6 +63,7 @@ if (!defined('Adminer\DRIVER')) {
                class Db {
                        public
                                $extension = "MySQL", ///< @var string extension name
+                               $flavor = '', ///< @var string different vendor with the same API, e.g. MariaDB, usually stays empty
                                $server_info, ///< @var string server version
                                $affected_rows, ///< @var int number of affected rows
                                $errno, ///< @var int last error code
@@ -369,7 +370,7 @@ if (!defined('Adminer\DRIVER')) {
 
                function slowQuery($query, $timeout) {
                        if (min_version('5.7.8', '10.1.2')) {
-                               if ($this->conn->maria) {
+                               if ($this->conn->flavor == 'maria') {
                                        return "SET STATEMENT max_statement_time=$timeout FOR $query";
                                } elseif (preg_match('~^(SELECT\b)(.+)~is', $query, $match)) {
                                        return "$match[1] /*+ MAX_EXECUTION_TIME(" . ($timeout * 1000) . ") */ $match[2]";
@@ -394,7 +395,7 @@ if (!defined('Adminer\DRIVER')) {
                }
 
                function tableHelp($name, $is_view = false) {
-                       $maria = $this->conn->maria;
+                       $maria = ($this->conn->flavor == 'maria');
                        if (information_schema(DB)) {
                                return strtolower("information-schema-" . ($maria ? "$name-table/" : str_replace("_", "-", $name) . "-table.html"));
                        }
@@ -451,8 +452,8 @@ if (!defined('Adminer\DRIVER')) {
                if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
                        $connection->set_charset(charset($connection));
                        $connection->query("SET sql_quote_show_create = 1, autocommit = 1");
-                       $connection->maria = preg_match('~MariaDB~', $connection->server_info);
-                       $drivers[DRIVER] = ($connection->maria ? "MariaDB" : "MySQL");
+                       $connection->flavor = (preg_match('~MariaDB~', $connection->server_info) ? 'maria' : '');
+                       $drivers[DRIVER] = ($connection->flavor == 'maria' ? "MariaDB" : "MySQL");
                        return $connection;
                }
                $return = $connection->error;
@@ -599,7 +600,7 @@ if (!defined('Adminer\DRIVER')) {
        */
        function fields($table) {
                global $connection;
-               $maria = $connection->maria;
+               $maria = ($connection->flavor == 'maria');
                $return = array();
                foreach (get_rows("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = " . q($table) . " ORDER BY ORDINAL_POSITION") as $row) {
                        $field = $row["COLUMN_NAME"];
@@ -824,7 +825,7 @@ if (!defined('Adminer\DRIVER')) {
                                $default = $field[1][3];
                                if (preg_match('~ GENERATED~', $default)) {
                                        // swap default and null
-                                       $field[1][3] = ($connection->maria ? "" : $field[1][2]); // MariaDB doesn't support NULL on virtual columns
+                                       $field[1][3] = ($connection->flavor == 'maria' ? "" : $field[1][2]); // MariaDB doesn't support NULL on virtual columns
                                        $field[1][2] = $default;
                                }
                                $alter[] = ($table != "" ? ($field[0] != "" ? "CHANGE " . idf_escape($field[0]) : "ADD") : " ") . " " . implode($field[1]) . ($table != "" ? $field[2] : "");
index cb07fcb2dee9217ba3137a756851d1f2f43c77be..e8b95f60a33d72a2c978c7a830477d7cd4e6a679 100644 (file)
@@ -7,7 +7,7 @@ if (isset($_GET["oracle"])) {
        define('Adminer\DRIVER', "oracle");
        if (extension_loaded("oci8") && $_GET["ext"] != "pdo") {
                class Db {
-                       public $extension = "oci8", $server_info, $affected_rows, $errno, $error;
+                       public $extension = "oci8", $flavor = '', $server_info, $affected_rows, $errno, $error;
                        public $_current_db;
                        private $link, $result;
 
index 9fd74c2389e1ef47fc1c67f76e3124d2f63218de..cf86b8d7151c7ebb11929973081d5bc52ad994c4 100644 (file)
@@ -7,7 +7,7 @@ if (isset($_GET["pgsql"])) {
        define('Adminer\DRIVER', "pgsql");
        if (extension_loaded("pgsql") && $_GET["ext"] != "pdo") {
                class Db {
-                       public $extension = "PgSQL", $server_info, $affected_rows, $error, $timeout;
+                       public $extension = "PgSQL", $flavor = '', $server_info, $affected_rows, $error, $timeout;
                        private $link, $result, $string, $database = true;
 
                        function _error($errno, $error) {
@@ -333,9 +333,9 @@ if (isset($_GET["pgsql"])) {
                                $connection->query("SET application_name = 'Adminer'");
                        }
                        $version = $connection->result("SELECT version()");
-                       $connection->cockroach = preg_match('~CockroachDB~', $version);
+                       $connection->flavor = (preg_match('~CockroachDB~', $version) ? 'cockroach' : '');
                        $connection->server_info = preg_replace('~^\D*([\d.]+[-\w]*).*~', '\1', $version);
-                       if ($connection->cockroach) { // we don't use "PostgreSQL / CockroachDB" by default because it's too long
+                       if ($connection->flavor == 'cockroach') { // we don't use "PostgreSQL / CockroachDB" by default because it's too long
                                $drivers[DRIVER] = "CockroachDB";
                        }
                        return $connection;
@@ -962,7 +962,7 @@ AND typelem = 0"
        function support($feature) {
                global $connection;
                return preg_match('~^(check|database|table|columns|sql|indexes|descidx|comment|view|' . (min_version(9.3) ? 'materializedview|' : '') . 'scheme|' . (min_version(11) ? 'procedure|' : '') . 'routine|sequence|trigger|type|variables|drop_col'
-                       . ($connection->cockroach ? '' : '|processlist') // https://github.com/cockroachdb/cockroach/issues/24745
+                       . ($connection->flavor == 'cockroach' ? '' : '|processlist') // https://github.com/cockroachdb/cockroach/issues/24745
                        . '|kill|dump)$~', $feature)
                ;
        }
index a50921d2e790f22c8fbafb04cd299ec7356a2407..63bed4036143713d36571de3b0339f39c383d5e7 100644 (file)
@@ -100,6 +100,7 @@ if (isset($_GET["sqlite"])) {
 
        if (class_exists('Adminer\SqliteDb')) {
                class Db extends SqliteDb {
+                       public $flavor = '';
 
                        function __construct() {
                                parent::__construct(":memory:");
index fdd8050760e82f7bcf0cc4ee81663acc2e1104fc..1ca4c8de15678fbc3866a25f0bec72e3f22f74b6 100644 (file)
@@ -1076,7 +1076,7 @@ class Adminer {
                        echo "</script>\n";
                }
                echo script("syntaxHighlighting('" . (is_object($connection) ? preg_replace('~^(\d\.?\d).*~s', '\1', $connection->server_info) : "") . "'"
-                       . ($connection->maria ? ", 'maria'" : ($connection->cockroach ? ", 'cockroach'" : "")) . ");"
+                       . ($connection->flavor == 'maria' ? ", 'maria'" : ($connection->flavor == 'cockroach' ? ", 'cockroach'" : "")) . ");"
                );
        }
 
index a3c72b618abc0df39a80d0dcc015f2c502f052e7..df1ecf932918fea244e96b8bb8d9901d7a1abbe3 100644 (file)
@@ -187,7 +187,7 @@ if (isset($_GET["username"]) && is_string(get_password())) {
                if ($adminer->operators === null) {
                        $adminer->operators = $driver->operators;
                }
-               if (isset($connection->maria) || $connection->cockroach) {
+               if (Driver::$jush == 'sql' || $connection->flavor == 'cockroach') {
                        save_settings(array("vendor-" . DRIVER . "-" . SERVER => $drivers[DRIVER]));
                }
        }
index ebdfb75761bbdba3919070a0aee6bb0070a758fa..f91765177ee3201a111905327f602577d5b8244f 100644 (file)
@@ -596,11 +596,11 @@ function doc_link($paths, $text = "<sup>?</sup>") {
        $urls = array(
                'sql' => "https://dev.mysql.com/doc/refman/$version/en/",
                'sqlite' => "https://www.sqlite.org/",
-               'pgsql' => "https://www.postgresql.org/docs/" . ($connection->cockroach ? "current" : $version) . "/",
+               'pgsql' => "https://www.postgresql.org/docs/" . ($connection->flavor == 'cockroach' ? "current" : $version) . "/",
                'mssql' => "https://learn.microsoft.com/en-us/sql/",
                'oracle' => "https://www.oracle.com/pls/topic/lookup?ctx=db" . preg_replace('~^.* (\d+)\.(\d+)\.\d+\.\d+\.\d+.*~s', '\1\2', $server_info) . "&id=",
        );
-       if ($connection->maria) {
+       if ($connection->flavor == 'maria') {
                $urls['sql'] = "https://mariadb.com/kb/en/";
                $paths['sql'] = (isset($paths['mariadb']) ? $paths['mariadb'] : str_replace(".html", "/", $paths['sql']));
        }
index e8fb0d12d8c7edd239131a4bddc17492fcb7a246..f6fa0a6fa5031470596f05a04e5117ae062d9fc8 100644 (file)
@@ -4,7 +4,7 @@ namespace Adminer;
 // PDO can be used in several database drivers
 if (extension_loaded('pdo')) {
        abstract class PdoDb {
-               public $server_info, $affected_rows, $errno, $error;
+               public $flavor = '', $server_info, $affected_rows, $errno, $error;
                protected $pdo;
                private $result;
 
index 62c2472ff70e8cf24c23d05203af0424869f0ff5..6d108a6544e443b0b0334c7b4fec5cad20cc4413 100644 (file)
@@ -44,7 +44,7 @@ function getCmMode(el) {
        if (match) {
                const modes = {
                        js: 'application/json',
-                       sql: 'text/x-<?php echo ($connection->maria ? "mariadb" : "mysql"); ?>',
+                       sql: 'text/x-<?php echo ($connection->flavor == "maria" ? "mariadb" : "mysql"); ?>',
                        oracle: 'text/x-sql',
                        clickhouse: 'text/x-sql',
                        firebird: 'text/x-sql'
index c37335a295e8df143365bc59dfa663e1d58a489b..f0a925799e918dafca95a5b5b47a42022d8bba66 100644 (file)
@@ -8,7 +8,7 @@ if (isset($_GET["clickhouse"])) {
 
        if (ini_bool('allow_url_fopen')) {
                class Db {
-                       public $extension = "JSON", $server_info, $errno, $error;
+                       public $extension = "JSON", $flavor = '', $server_info, $errno, $error;
                        public $_db = 'default';
                        private $result, $url;
 
index dd66077f932d3268ea5e3912d8858b7693388776..bb927dbdd915b1e0e646317cddca1aa84b699e6d 100644 (file)
@@ -9,7 +9,7 @@ if (isset($_GET["elastic"])) {
        if (ini_bool('allow_url_fopen')) {
 
                class Db {
-                       public $extension = "JSON", $server_info, $errno, $error;
+                       public $extension = "JSON", $flavor = '', $server_info, $errno, $error;
                        private $url;
 
                        /**
index 969347762279c822b0aba807ec0104970d63fe6c..3720930bdab0834446862d8afcb2aa5f6bd11e70 100644 (file)
@@ -14,6 +14,7 @@ if (isset($_GET["firebird"])) {
                class Db {
                        public
                                $extension = "Firebird",
+                               $flavor = '',
                                $server_info,
                                $affected_rows,
                                $errno,
index a9fa71054a5240228ccbc5dcc381b806f81ff1c6..16d7bf6731820ea60c0e3a831bc725f76c0191c4 100644 (file)
@@ -20,6 +20,7 @@ if (isset($_GET["imap"])) {
        if (extension_loaded("imap")) {
                class Db {
                        public $extension = "IMAP";
+                       public $flavor = '';
                        public $error;
                        public $server_info = "?"; // imap_mailboxmsginfo() or imap_check() don't return anything useful
                        private $mailbox;
index 8d9d8d8d990f058739e3715246139bcd3e7b9e28..603130ab172aebe2b7c49eab245e1502d70955b7 100644 (file)
@@ -8,7 +8,7 @@ if (isset($_GET["mongo"])) {
 
        if (class_exists('MongoDB\Driver\Manager')) {
                class Db {
-                       public $extension = "MongoDB", $server_info = MONGODB_VERSION, $affected_rows, $error, $last_id;
+                       public $extension = "MongoDB", $flavor = '', $server_info = MONGODB_VERSION, $affected_rows, $error, $last_id;
                        /** @var MongoDB\Driver\Manager */
                        public $_link;
                        public $_db, $_db_name;
index e7fec2b361589097946f5edddf19019ce650c813..8d9c67b2eb96eed23e67e0185beb34472fbf1ca3 100644 (file)
@@ -8,7 +8,7 @@ if (isset($_GET["simpledb"])) {
 
        if (class_exists('SimpleXMLElement') && ini_bool('allow_url_fopen')) {
                class Db {
-                       public $extension = "SimpleXML", $server_info = '2009-04-15', $error, $timeout, $next, $affected_rows;
+                       public $extension = "SimpleXML", $flavor = '', $server_info = '2009-04-15', $error, $timeout, $next, $affected_rows;
                        private $result;
 
                        function select_db($database) {