From 0268aba85a06274cdfb96a559e1f401fe27023fc Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 16 Jan 2018 16:22:24 +0100 Subject: [PATCH] Avoid count(null) --- adminer/db.inc.php | 2 +- adminer/edit.inc.php | 2 +- adminer/include/adminer.inc.php | 3 +++ adminer/select.inc.php | 2 +- changes.txt | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/adminer/db.inc.php b/adminer/db.inc.php index 55f64bd9..671c232f 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -4,7 +4,7 @@ $tables_views = array_merge((array) $_POST["tables"], (array) $_POST["views"]); if ($tables_views && !$error && !$_POST["search"]) { $result = true; $message = ""; - if ($jush == "sql" && count($_POST["tables"]) > 1 && ($_POST["drop"] || $_POST["truncate"] || $_POST["copy"])) { + if ($jush == "sql" && $_POST["tables"] && count($_POST["tables"]) > 1 && ($_POST["drop"] || $_POST["truncate"] || $_POST["copy"])) { queries("SET foreign_key_checks = 0"); // allows to truncate or drop several tables at once } diff --git a/adminer/edit.inc.php b/adminer/edit.inc.php index b95dcfd3..c2ffc98c 100644 --- a/adminer/edit.inc.php +++ b/adminer/edit.inc.php @@ -1,7 +1,7 @@ $field) { if (!isset($field["privileges"][$update ? "update" : "insert"]) || $adminer->fieldName($field) == "") { diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 777cc324..2d7f8821 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -592,6 +592,9 @@ class Adminer { global $jush; restart_session(); $history = &get_session("queries"); + if (!$history[$_GET["db"]]) { + $history[$_GET["db"]] = array(); + } $id = "sql-" . count($history[$_GET["db"]]); if (strlen($query) > 1e6) { $query = preg_replace('~[\x80-\xFF]+$~', '', substr($query, 0, 1e6)) . "\n..."; // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 8dfdc65a..79a0a455 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -226,7 +226,7 @@ $set = null; if (isset($rights["insert"]) || !support("table")) { $set = ""; foreach ((array) $_GET["where"] as $val) { - if (count($foreign_keys[$val["col"]]) == 1 && ($val["op"] == "=" + if ($foreign_keys[$val["col"]] && count($foreign_keys[$val["col"]]) == 1 && ($val["op"] == "=" || (!$val["op"] && !preg_match('~[_%]~', $val["val"])) // LIKE in Editor )) { $set .= "&set" . urlencode("[" . bracket_escape($val["col"]) . "]") . "=" . urlencode($val["val"]); diff --git a/changes.txt b/changes.txt index 8f728b92..bbeb52e5 100644 --- a/changes.txt +++ b/changes.txt @@ -5,6 +5,7 @@ Rate limit password-less login attempts from the same IP address Disallow connecting to privileged ports Add nosniff header PHP 7.1: Prevent warning when using empty limit +PHP 7.2: Prevent warning when searching in select MySQL: Remove dedicated view for replication status (added in 4.3.0) PostgreSQL: Sort table names (regression from 4.3.1) Editor: Don't set time zone from PHP, fixes DST