From 49eefa2585da26218b57572fef69a6cb7b69fbb5 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Thu, 3 Apr 2025 10:23:31 +0200 Subject: [PATCH] Call credentials() from connect() --- adminer/call.inc.php | 2 +- adminer/include/functions.inc.php | 9 ++++----- adminer/sql.inc.php | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/adminer/call.inc.php b/adminer/call.inc.php index aae0012a..404ec52a 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -41,7 +41,7 @@ if (!$error && $_POST) { if (!$result) { echo "

" . error() . "\n"; } else { - $connection2 = connect(adminer()->credentials()); + $connection2 = connect(); if ($connection2) { $connection2->select_db(DB); } diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index a2882a6e..1a945c38 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -24,10 +24,9 @@ function driver(): Driver { return Driver::$instance; } -/** Connect to the database -* @param array{?string, string, string} $credentials [$server, $username, $password] -*/ -function connect(array $credentials): ?Db { +/** Connect to the database */ +function connect(): ?Db { + $credentials = adminer()->credentials(); $return = Driver::connect($credentials[0], $credentials[1], $credentials[2]); return (is_object($return) ? $return : null); } @@ -831,7 +830,7 @@ function slow_query(string $query): array { $slow_query = driver()->slowQuery($query, $timeout); $connection2 = null; if (!$slow_query && support("kill")) { - $connection2 = connect(adminer()->credentials()); + $connection2 = connect(); if ($connection2 && ($db == "" || $connection2->select_db($db))) { $kill = get_val(connection_id(), 0, $connection2); // MySQL and MySQLi can use thread_id but it's not in PDO_MySQL echo script("const timeout = setTimeout(() => { ajax('" . js_escape(ME) . "script=kill', function () {}, 'kill=$kill&token=" . get_token() . "'); }, 1000 * $timeout);"); diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index 790aff0c..f0833d7f 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -55,7 +55,7 @@ if (!$error && $_POST) { $delimiter = ";"; $offset = 0; $empty = true; - $connection2 = connect(adminer()->credentials()); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error + $connection2 = connect(); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error if ($connection2 && DB != "") { $connection2->select_db(DB); if ($_GET["ns"] != "") { -- 2.39.5