From c454ea84307374b4a29fae6c9e9507d8cb6aa4ef Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 11 Mar 2025 07:49:10 +0100 Subject: [PATCH] Use protected visibility --- adminer/drivers/mongo.inc.php | 16 ++++++++-------- adminer/drivers/mysql.inc.php | 10 +++++----- adminer/drivers/pgsql.inc.php | 10 +++++----- adminer/drivers/sqlite.inc.php | 2 +- adminer/include/driver.inc.php | 10 +++++----- plugins/drivers/elastic.php | 16 ++++++++-------- plugins/drivers/simpledb.php | 2 +- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/adminer/drivers/mongo.inc.php b/adminer/drivers/mongo.inc.php index a400c2e1..177c90de 100644 --- a/adminer/drivers/mongo.inc.php +++ b/adminer/drivers/mongo.inc.php @@ -331,15 +331,15 @@ if (isset($_GET["mongo"])) { $limit = min(200, max(1, (int) $limit)); $skip = $page * $limit; try { - return new Result($this->_conn->_link->executeQuery($this->_conn->_db_name . ".$table", new \MongoDB\Driver\Query($where, array('projection' => $select, 'limit' => $limit, 'skip' => $skip, 'sort' => $sort)))); + return new Result($this->conn->_link->executeQuery($this->conn->_db_name . ".$table", new \MongoDB\Driver\Query($where, array('projection' => $select, 'limit' => $limit, 'skip' => $skip, 'sort' => $sort)))); } catch (Exception $e) { - $this->_conn->error = $e->getMessage(); + $this->conn->error = $e->getMessage(); return false; } } function update($table, $set, $queryWhere, $limit = 0, $separator = "\n") { - $db = $this->_conn->_db_name; + $db = $this->conn->_db_name; $where = sql_query_where_parser($queryWhere); $bulk = new \MongoDB\Driver\BulkWrite(array()); if (isset($set['_id'])) { @@ -357,25 +357,25 @@ if (isset($_GET["mongo"])) { $update['$unset'] = $removeFields; } $bulk->update($where, $update, array('upsert' => false)); - return $this->_conn->executeBulkWrite("$db.$table", $bulk, 'getModifiedCount'); + return $this->conn->executeBulkWrite("$db.$table", $bulk, 'getModifiedCount'); } function delete($table, $queryWhere, $limit = 0) { - $db = $this->_conn->_db_name; + $db = $this->conn->_db_name; $where = sql_query_where_parser($queryWhere); $bulk = new \MongoDB\Driver\BulkWrite(array()); $bulk->delete($where, array('limit' => $limit)); - return $this->_conn->executeBulkWrite("$db.$table", $bulk, 'getDeletedCount'); + return $this->conn->executeBulkWrite("$db.$table", $bulk, 'getDeletedCount'); } function insert($table, $set) { - $db = $this->_conn->_db_name; + $db = $this->conn->_db_name; $bulk = new \MongoDB\Driver\BulkWrite(array()); if ($set['_id'] == '') { unset($set['_id']); } $bulk->insert($set); - return $this->_conn->executeBulkWrite("$db.$table", $bulk, 'getInsertedCount'); + return $this->conn->executeBulkWrite("$db.$table", $bulk, 'getInsertedCount'); } } diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 560848fb..d4c67ce3 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -356,7 +356,7 @@ if (!defined('Adminer\DRIVER')) { function slowQuery($query, $timeout) { if (min_version('5.7.8', '10.1.2')) { - if (preg_match('~MariaDB~', $this->_conn->server_info)) { + if (preg_match('~MariaDB~', $this->conn->server_info)) { 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]"; @@ -366,13 +366,13 @@ if (!defined('Adminer\DRIVER')) { function convertSearch($idf, $val, $field) { return (preg_match('~char|text|enum|set~', $field["type"]) && !preg_match("~^utf8~", $field["collation"]) && preg_match('~[\x80-\xFF]~', $val['val']) - ? "CONVERT($idf USING " . charset($this->_conn) . ")" + ? "CONVERT($idf USING " . charset($this->conn) . ")" : $idf ); } function warnings() { - $result = $this->_conn->query("SHOW WARNINGS"); + $result = $this->conn->query("SHOW WARNINGS"); if ($result && $result->num_rows) { ob_start(); select($result); // select() usually needs to print a big table progressively @@ -381,7 +381,7 @@ if (!defined('Adminer\DRIVER')) { } function tableHelp($name, $is_view = false) { - $maria = preg_match('~MariaDB~', $this->_conn->server_info); + $maria = preg_match('~MariaDB~', $this->conn->server_info); if (information_schema(DB)) { return strtolower("information-schema-" . ($maria ? "$name-table/" : str_replace("_", "-", $name) . "-table.html")); } @@ -393,7 +393,7 @@ if (!defined('Adminer\DRIVER')) { function hasCStyleEscapes() { static $c_style; if ($c_style === null) { - $sql_mode = $this->_conn->result("SHOW VARIABLES LIKE 'sql_mode'", 1); + $sql_mode = $this->conn->result("SHOW VARIABLES LIKE 'sql_mode'", 1); $c_style = (strpos($sql_mode, 'NO_BACKSLASH_ESCAPES') === false); } return $c_style; diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index a805a3c8..4d96cb5e 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -267,8 +267,8 @@ if (isset($_GET["pgsql"])) { } function slowQuery($query, $timeout) { - $this->_conn->query("SET statement_timeout = " . (1000 * $timeout)); - $this->_conn->timeout = 1000 * $timeout; + $this->conn->query("SET statement_timeout = " . (1000 * $timeout)); + $this->conn->timeout = 1000 * $timeout; return $query; } @@ -282,11 +282,11 @@ if (isset($_GET["pgsql"])) { } function quoteBinary($s) { - return $this->_conn->quoteBinary($s); + return $this->conn->quoteBinary($s); } function warnings() { - return $this->_conn->warnings(); + return $this->conn->warnings(); } function tableHelp($name, $is_view = false) { @@ -308,7 +308,7 @@ if (isset($_GET["pgsql"])) { function hasCStyleEscapes() { static $c_style; if ($c_style === null) { - $c_style = ($this->_conn->result("SHOW standard_conforming_strings") == "off"); + $c_style = ($this->conn->result("SHOW standard_conforming_strings") == "off"); } return $c_style; } diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index eb0a8b97..da29f02e 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -177,7 +177,7 @@ if (isset($_GET["sqlite"])) { } function checkConstraints($table) { - preg_match_all('~ CHECK *(\( *(((?>[^()]*[^() ])|(?1))*) *\))~', $this->_conn->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table)), $matches); //! could be inside a comment + preg_match_all('~ CHECK *(\( *(((?>[^()]*[^() ])|(?1))*) *\))~', $this->conn->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table)), $matches); //! could be inside a comment return array_combine($matches[2], $matches[2]); } } diff --git a/adminer/include/driver.inc.php b/adminer/include/driver.inc.php index 2bf48a25..9dca7e00 100644 --- a/adminer/include/driver.inc.php +++ b/adminer/include/driver.inc.php @@ -26,7 +26,7 @@ abstract class SqlDriver { static $possibleDrivers = array(); static $jush; ///< @var string JUSH identifier - var $_conn; + protected $conn; protected $types = array(); ///< @var array [$description => [$type => $maximum_unsigned_length, ...], ...] var $editFunctions = array(); ///< @var array of ["$type|$type2" => "$function/$function2"] functions used in editing, [0] - edit and insert, [1] - edit only var $unsigned = array(); ///< @var array number variants @@ -42,7 +42,7 @@ abstract class SqlDriver { * @param Db */ function __construct($connection) { - $this->_conn = $connection; + $this->conn = $connection; } /** Get all types @@ -91,7 +91,7 @@ abstract class SqlDriver { ); } $start = microtime(true); - $return = $this->_conn->query($query); + $return = $this->conn->query($query); if ($print) { echo $adminer->selectQuery($query, $start, !$return); } @@ -201,8 +201,8 @@ abstract class SqlDriver { * @return string */ function value($val, $field) { - return (method_exists($this->_conn, 'value') - ? $this->_conn->value($val, $field) + return (method_exists($this->conn, 'value') + ? $this->conn->value($val, $field) : (is_resource($val) ? stream_get_contents($val) : $val) ); } diff --git a/plugins/drivers/elastic.php b/plugins/drivers/elastic.php index 9ee0257e..691f3687 100644 --- a/plugins/drivers/elastic.php +++ b/plugins/drivers/elastic.php @@ -199,7 +199,7 @@ if (isset($_GET["elastic"])) { $query = "$table/_search"; $start = microtime(true); - $search = $this->_conn->rootQuery($query, $data); + $search = $this->conn->rootQuery($query, $data); if ($print) { echo adminer()->selectQuery("$query: " . json_encode($data), $start, !$search); @@ -245,7 +245,7 @@ if (isset($_GET["elastic"])) { $id = trim($parts[1]); $query = "$type/$id"; - return $this->_conn->query($query, $record, 'POST'); + return $this->conn->query($query, $record, 'POST'); } return false; @@ -262,11 +262,11 @@ if (isset($_GET["elastic"])) { unset($record[$key]); } } - $response = $this->_conn->query($query, $record, 'POST'); + $response = $this->conn->query($query, $record, 'POST'); if ($response == false) { return false; } - $this->_conn->last_id = $response['_id']; + $this->conn->last_id = $response['_id']; return $response['result']; } @@ -286,17 +286,17 @@ if (isset($_GET["elastic"])) { } } - $this->_conn->affected_rows = 0; + $this->conn->affected_rows = 0; foreach ($ids as $id) { $query = "$table/_doc/$id"; - $response = $this->_conn->query($query, null, 'DELETE'); + $response = $this->conn->query($query, null, 'DELETE'); if (isset($response['result']) && $response['result'] == 'deleted') { - $this->_conn->affected_rows++; + $this->conn->affected_rows++; } } - return $this->_conn->affected_rows; + return $this->conn->affected_rows; } function convertOperator($operator) { diff --git a/plugins/drivers/simpledb.php b/plugins/drivers/simpledb.php index 56a8eb81..392c1e48 100644 --- a/plugins/drivers/simpledb.php +++ b/plugins/drivers/simpledb.php @@ -246,7 +246,7 @@ if (isset($_GET["simpledb"])) { } function slowQuery($query, $timeout) { - $this->_conn->timeout = $timeout; + $this->conn->timeout = $timeout; return $query; } }