$privileges
* @return Result|bool
*/
-function grant(string $grant, array $privileges, string $columns, string $on) {
+function grant(string $grant, array $privileges, ?string $columns, string $on) {
if (!$privileges) {
return true;
}
diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php
index 050b579c..1ea224f1 100644
--- a/adminer/include/functions.inc.php
+++ b/adminer/include/functions.inc.php
@@ -57,7 +57,7 @@ function escape_string(string $val): string {
/** Get a possibly missing item from a possibly missing array
* idx($row, $key) is better than $row[$key] ?? null because PHP will report error for undefined $row
* @param ?mixed[] $array
-* @param string|int $key
+* @param array-key $key
* @param mixed $default
* @return mixed
*/
@@ -142,7 +142,7 @@ function sid(): bool {
}
/** Set password to session */
-function set_password(string $vendor, string $server, string $username, ?string $password): void {
+function set_password(string $vendor, ?string $server, string $username, ?string $password): void {
$_SESSION["pwds"][$vendor][$server][$username] = ($_COOKIE["adminer_key"] && is_string($password)
? array(encrypt_string($password, $_COOKIE["adminer_key"]))
: $password
@@ -391,7 +391,7 @@ function set_session(string $key, $val) {
}
/** Get authenticated URL */
-function auth_url(string $vendor, string $server, string $username, string $db = null): string {
+function auth_url(string $vendor, ?string $server, string $username, string $db = null): string {
global $drivers;
$uri = remove_from_uri(implode("|", array_keys($drivers))
. "|username|ext|"
@@ -562,7 +562,7 @@ function repeat_pattern(string $pattern, int $length): string {
}
/** Check whether the string is in UTF-8 */
-function is_utf8(string $val): bool {
+function is_utf8(?string $val): bool {
// don't print control chars except \t\r\n
return (preg_match('~~u', $val) && !preg_match('~[\0-\x8\xB\xC\xE-\x1F]~', $val));
}
@@ -771,9 +771,10 @@ function rand_string(): string {
/** Format value to use in select
* @param string|string[] $val
* @param Field $field
+* @param ?numeric-string $text_length
* @return string HTML
*/
-function select_value($val, string $link, array $field, int $text_length): string {
+function select_value($val, string $link, array $field, ?string $text_length): string {
global $adminer;
if (is_array($val)) {
$return = "";
diff --git a/adminer/include/html.inc.php b/adminer/include/html.inc.php
index c17fe1b2..9f3deda6 100644
--- a/adminer/include/html.inc.php
+++ b/adminer/include/html.inc.php
@@ -191,7 +191,7 @@ function enum_input(string $type, string $attrs, array $field, $value, string $e
* @param Field|RoutineField $field
* @param mixed $value
*/
-function input(array $field, $value, string $function, bool $autofocus = false): void {
+function input(array $field, $value, string $function, ?bool $autofocus = false): void {
global $driver, $adminer;
$name = h(bracket_escape($field["field"]));
echo "";
diff --git a/adminer/include/pdo.inc.php b/adminer/include/pdo.inc.php
index cf9f2d19..30e6dda9 100644
--- a/adminer/include/pdo.inc.php
+++ b/adminer/include/pdo.inc.php
@@ -68,11 +68,11 @@ if (extension_loaded('pdo')) {
class PdoResult extends \PDOStatement {
public $_offset = 0, $num_rows;
- function fetch_assoc(): array {
+ function fetch_assoc() {
return $this->fetch(\PDO::FETCH_ASSOC);
}
- function fetch_row(): array {
+ function fetch_row() {
return $this->fetch(\PDO::FETCH_NUM);
}
diff --git a/adminer/select.inc.php b/adminer/select.inc.php
index b6f7f03a..ae939deb 100644
--- a/adminer/select.inc.php
+++ b/adminer/select.inc.php
@@ -13,7 +13,7 @@ $rights = array(); // privilege => 0
$columns = array(); // selectable columns
$search_columns = array(); // searchable columns
$order_columns = array(); // searchable columns
-$text_length = null;
+$text_length = "";
foreach ($fields as $key => $field) {
$name = $adminer->fieldName($field);
$name_plain = html_entity_decode(strip_tags($name), ENT_QUOTES);
diff --git a/adminer/trigger.inc.php b/adminer/trigger.inc.php
index ed103d41..7b7f5b03 100644
--- a/adminer/trigger.inc.php
+++ b/adminer/trigger.inc.php
@@ -2,7 +2,7 @@
namespace Adminer;
$TABLE = $_GET["trigger"];
-$name = $_GET["name"];
+$name = "$_GET[name]";
$trigger_options = trigger_options();
$row = (array) trigger($name, $TABLE) + array("Trigger" => $TABLE . "_bi");
diff --git a/adminer/user.inc.php b/adminer/user.inc.php
index 3a70f3b2..a74b2431 100644
--- a/adminer/user.inc.php
+++ b/adminer/user.inc.php
@@ -23,7 +23,7 @@ foreach ($privileges["Tables"] as $key => $val) {
$new_grants = array();
if ($_POST) {
foreach ($_POST["objects"] as $key => $val) {
- $new_grants[$val] = (array) $new_grants[$val] + (array) $_POST["grants"][$key];
+ $new_grants[$val] = (array) $new_grants[$val] + idx($_POST["grants"], $key, array());
}
}
$grants = array();
diff --git a/phpstan.neon b/phpstan.neon
index 4769dde5..80deae6b 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -56,7 +56,7 @@ parameters:
- adminer/sqlite.php
phpVersion:
- min: 70400
+ min: 70100
max: 80499
typeAliases:
diff --git a/plugins/drivers/clickhouse.php b/plugins/drivers/clickhouse.php
index b7ca723a..6b94e8cf 100644
--- a/plugins/drivers/clickhouse.php
+++ b/plugins/drivers/clickhouse.php
@@ -91,13 +91,13 @@ if (isset($_GET["clickhouse"])) {
reset($this->rows);
}
- function fetch_assoc(): array {
+ function fetch_assoc() {
$row = current($this->rows);
next($this->rows);
return $row === false ? false : array_combine($this->columns, $row);
}
- function fetch_row(): array {
+ function fetch_row() {
$row = current($this->rows);
next($this->rows);
return $row;
diff --git a/plugins/drivers/elastic.php b/plugins/drivers/elastic.php
index 3fafcd8e..2eb7ad0c 100644
--- a/plugins/drivers/elastic.php
+++ b/plugins/drivers/elastic.php
@@ -49,26 +49,19 @@ if (isset($_GET["elastic"])) {
return $return;
}
- /** Perform query relative to actual selected DB
- * @return array|false
- */
- function query(string $path, ?array $content = null, string $method = 'GET') {
+ /** Perform query relative to actual selected DB */
+ function query(string $query, bool $unbuffered = false) {
// Support for global search through all tables
- if ($path != "" && $path[0] == "S" && preg_match('/SELECT 1 FROM ([^ ]+) WHERE (.+) LIMIT ([0-9]+)/', $path, $matches)) {
- $driver = driver();
-
+ if ($query[0] == "S" && preg_match('/SELECT 1 FROM ([^ ]+) WHERE (.+) LIMIT ([0-9]+)/', $query, $matches)) {
$where = explode(" AND ", $matches[2]);
-
- return $driver->select($matches[1], array("*"), $where, array(), array(), $matches[3]);
+ return driver()->select($matches[1], array("*"), $where, array(), array(), $matches[3]);
}
-
- return $this->rootQuery($path, $content, $method);
}
function connect(string $server, string $username, string $password): bool {
preg_match('~^(https?://)?(.*)~', $server, $match);
$this->url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
- $return = $this->query('');
+ $return = $this->rootQuery('');
if ($return) {
$this->server_info = $return['version']['number'];
}
@@ -94,13 +87,13 @@ if (isset($_GET["elastic"])) {
reset($this->rows);
}
- function fetch_assoc(): array {
+ function fetch_assoc() {
$return = current($this->rows);
next($this->rows);
return $return;
}
- function fetch_row(): array {
+ function fetch_row() {
$row = $this->fetch_assoc();
return $row ? array_values($row) : false;
}
@@ -228,7 +221,7 @@ if (isset($_GET["elastic"])) {
$id = trim($parts[1]);
$query = "$type/$id";
- return $this->conn->query($query, $record, 'POST');
+ return $this->conn->rootQuery($query, $record, 'POST');
}
return false;
@@ -245,7 +238,7 @@ if (isset($_GET["elastic"])) {
unset($record[$key]);
}
}
- $response = $this->conn->query($query, $record, 'POST');
+ $response = $this->conn->rootQuery($query, $record, 'POST');
if ($response == false) {
return false;
}
@@ -273,7 +266,7 @@ if (isset($_GET["elastic"])) {
foreach ($ids as $id) {
$query = "$table/_doc/$id";
- $response = $this->conn->query($query, null, 'DELETE');
+ $response = $this->conn->rootQuery($query, null, 'DELETE');
if (isset($response['result']) && $response['result'] == 'deleted') {
$this->conn->affected_rows++;
}
@@ -532,7 +525,7 @@ if (isset($_GET["elastic"])) {
$properties = array('properties' => $properties);
}
- return connection()->query("_mapping/$name", $properties, 'PUT');
+ return connection()->rootQuery("_mapping/$name", $properties, 'PUT');
}
/** Drop types
@@ -541,7 +534,7 @@ if (isset($_GET["elastic"])) {
function drop_tables(array $tables): bool {
$return = true;
foreach ($tables as $table) { //! convert to bulk api
- $return = $return && connection()->query(urlencode($table), null, 'DELETE');
+ $return = $return && connection()->rootQuery(urlencode($table), null, 'DELETE');
}
return $return;
diff --git a/plugins/drivers/firebird.php b/plugins/drivers/firebird.php
index 75522b87..36c86296 100644
--- a/plugins/drivers/firebird.php
+++ b/plugins/drivers/firebird.php
@@ -60,11 +60,11 @@ if (isset($_GET["firebird"])) {
// $this->num_rows = ibase_num_rows($result);
}
- function fetch_assoc(): array {
+ function fetch_assoc() {
return ibase_fetch_assoc($this->result);
}
- function fetch_row(): array {
+ function fetch_row() {
return ibase_fetch_row($this->result);
}
diff --git a/plugins/drivers/imap.php b/plugins/drivers/imap.php
index 85357eae..2063bcab 100644
--- a/plugins/drivers/imap.php
+++ b/plugins/drivers/imap.php
@@ -123,13 +123,13 @@ if (isset($_GET["imap"])) {
$this->fields = array_keys(idx($result, 0, array()));
}
- function fetch_assoc(): array {
+ function fetch_assoc() {
$row = current($this->result);
next($this->result);
return $row;
}
- function fetch_row(): array {
+ function fetch_row() {
$row = $this->fetch_assoc();
return ($row ? array_values($row) : false);
}
diff --git a/plugins/drivers/mongo.php b/plugins/drivers/mongo.php
index f9fca199..d64527f7 100644
--- a/plugins/drivers/mongo.php
+++ b/plugins/drivers/mongo.php
@@ -97,7 +97,7 @@ if (isset($_GET["mongo"])) {
$this->num_rows = count($this->rows);
}
- function fetch_assoc(): array {
+ function fetch_assoc() {
$row = current($this->rows);
if (!$row) {
return $row;
@@ -110,7 +110,7 @@ if (isset($_GET["mongo"])) {
return $return;
}
- function fetch_row(): array {
+ function fetch_row() {
$return = $this->fetch_assoc();
if (!$return) {
return $return;
diff --git a/plugins/drivers/simpledb.php b/plugins/drivers/simpledb.php
index 1eb14d27..1d6630c6 100644
--- a/plugins/drivers/simpledb.php
+++ b/plugins/drivers/simpledb.php
@@ -76,7 +76,7 @@ if (isset($_GET["simpledb"])) {
return (is_object($element) && $element['encoding'] == 'base64' ? base64_decode($element) : (string) $element);
}
- function fetch_assoc(): array {
+ function fetch_assoc() {
$row = current($this->rows);
if (!$row) {
return $row;
@@ -89,7 +89,7 @@ if (isset($_GET["simpledb"])) {
return $return;
}
- function fetch_row(): array {
+ function fetch_row() {
$return = $this->fetch_assoc();
if (!$return) {
return $return;
diff --git a/plugins/slugify.php b/plugins/slugify.php
index 2d5f99a4..07691f1d 100644
--- a/plugins/slugify.php
+++ b/plugins/slugify.php
@@ -20,7 +20,7 @@ class AdminerSlugify {
function editInput($table, $field, $attrs, $value) {
static $slugify;
- if (!$_GET["select"] && !$_GET["where"]) {
+ if (!$_GET["select"] && !$_GET["where"] && $table) {
if ($slugify === null) {
$slugify = array();
$prev = null;
|