1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Notices: Store maria into a declared variable

This commit is contained in:
Jakub Vrana
2025-03-24 05:58:35 +01:00
parent b89f628e40
commit 3dd1b41472
16 changed files with 27 additions and 23 deletions

View 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() {

View 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] : "");

View 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;

View 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)
;
}

View 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:");

View 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'" : "")) . ");"
);
}

View 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]));
}
}

View 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']));
}

View 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;

View 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'

View 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;

View 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;
/**

View File

@@ -14,6 +14,7 @@ if (isset($_GET["firebird"])) {
class Db {
public
$extension = "Firebird",
$flavor = '',
$server_info,
$affected_rows,
$errno,

View 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;

View 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;

View 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) {