From 862e5b4aa4ba8dfa53db652837458e05c130bf3a Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sat, 8 Mar 2025 21:45:21 +0100 Subject: [PATCH] Move variable initialization --- adminer/drivers/mongo.inc.php | 4 ++-- adminer/include/functions.inc.php | 5 ++--- adminer/select.inc.php | 5 ++--- adminer/user.inc.php | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/adminer/drivers/mongo.inc.php b/adminer/drivers/mongo.inc.php index ebacdc1f..2029f08b 100644 --- a/adminer/drivers/mongo.inc.php +++ b/adminer/drivers/mongo.inc.php @@ -328,9 +328,9 @@ if (isset($_GET["mongo"])) { $limit = min(200, max(1, (int) $limit)); $skip = $page * $limit; try { - return new Result($this->_conn->_link->executeQuery("$connection->_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) { - $connection->error = $e->getMessage(); + $this->_conn->error = $e->getMessage(); return false; } } diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index e8bedb07..070bfe64 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -1311,6 +1311,7 @@ function slow_query($query) { $db = $adminer->database(); $timeout = $adminer->queryTimeout(); $slow_query = $driver->slowQuery($query, $timeout); + $connection2 = null; if (!$slow_query && support("kill") && is_object($connection2 = connect($adminer->credentials())) && ($db == "" || $connection2->select_db($db))) { $kill = $connection2->result(connection_id()); // MySQL and MySQLi can use thread_id but it's not in PDO_MySQL ?> @@ -1321,8 +1322,6 @@ var timeout = setTimeout(function () { }, );
" . lang('You have no privileges to update this table.') . "\n"; } else { echo "" . script("qsl('table').onkeydown = editingKeydown;"); - $first = 0; foreach ($fields as $name => $field) { echo "
" . $adminer->fieldName($field); $default = $_GET["set"][bracket_escape($name)]; diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 23658290..ab94ce7e 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -81,9 +81,8 @@ if ($_POST && !$error) { . convert_fields($columns, $fields, $select) . "\nFROM " . table($TABLE); $group_by = ($group && $is_group ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : ""); - if (!is_array($_POST["check"]) || $primary) { - $query = "SELECT $from$where_check$group_by"; - } else { + $query = "SELECT $from$where_check$group_by"; + if (is_array($_POST["check"]) && !$primary) { $union = array(); foreach ($_POST["check"] as $val) { // where is not unique so OR can't be used diff --git a/adminer/user.inc.php b/adminer/user.inc.php index 5243ea3b..8dd50289 100644 --- a/adminer/user.inc.php +++ b/adminer/user.inc.php @@ -120,8 +120,8 @@ if ($_POST && !$error) { page_header((isset($_GET["host"]) ? lang('Username') . ": " . h("$USER@$_GET[host]") : lang('Create user')), $error, array("privileges" => array('', lang('Privileges')))); -if ($_POST) { - $row = $_POST; +$row = $_POST; +if ($row) { $grants = $new_grants; } else { $row = $_GET + array("host" => get_val("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)")); // create user on the same domain by default