diff --git a/adminer/call.inc.php b/adminer/call.inc.php index 90d28596..236ae3b4 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -19,6 +19,7 @@ foreach ($routine["fields"] as $i => $field) { if (!$error && $_POST) { $call = array(); foreach ($routine["fields"] as $key => $field) { + $val = ""; if (in_array($key, $in)) { $val = process_input($field); if ($val === false) { diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index d6833bfd..c9302cf3 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -316,7 +316,7 @@ if (isset($_GET["mssql"])) { return $connection->error; } - function get_databases() { + function get_databases($flush) { return get_vals("SELECT name FROM sys.databases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')"); } @@ -598,7 +598,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table), $connection2) as $row return apply_queries("ALTER SCHEMA " . idf_escape($target) . " TRANSFER", array_merge($tables, $views)); } - function trigger($name) { + function trigger($name, $table) { if ($name == "") { return array(); } @@ -707,7 +707,7 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)) as $row function trigger_sql($table) { $return = ""; foreach (triggers($table) as $name => $trigger) { - $return .= create_trigger(" ON " . table($table), trigger($name)) . ";"; + $return .= create_trigger(" ON " . table($table), trigger($name, $table)) . ";"; } return $return; } diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index a44da959..423b0a4e 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -961,10 +961,11 @@ if (!defined('Adminer\DRIVER')) { /** Get information about trigger * @param string trigger name + * @param string * @return Trigger * @phpstan-type Trigger array{Trigger:string, Timing:string, Event:string, Of:string, Type:string, Statement:string} */ - function trigger($name) { + function trigger($name, $table) { if ($name == "") { return array(); } diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index 4c8d490c..21edace3 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -221,7 +221,7 @@ if (isset($_GET["oracle"])) { return $connection->error; } - function get_databases() { + function get_databases($flush) { return get_vals( "SELECT DISTINCT tablespace_name FROM ( SELECT tablespace_name FROM user_tablespaces diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 3e278b15..a699126e 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -338,7 +338,7 @@ if (isset($_GET["pgsql"])) { return $connection->error; } - function get_databases() { + function get_databases($flush) { return get_vals("SELECT datname FROM pg_database WHERE datallowconn = TRUE AND has_database_privilege(datname, 'CONNECT') ORDER BY datname"); diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index 76a3d47d..252873b8 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -200,7 +200,7 @@ if (isset($_GET["sqlite"])) { return new Db; } - function get_databases() { + function get_databases($flush) { return array(); } @@ -567,7 +567,7 @@ if (isset($_GET["sqlite"])) { } $triggers = array(); foreach (triggers($table) as $trigger_name => $timing_event) { - $trigger = trigger($trigger_name); + $trigger = trigger($trigger_name, $table); $triggers[] = "CREATE TRIGGER " . idf_escape($trigger_name) . " " . implode(" ", $timing_event) . " ON " . table($name) . "\n$trigger[Statement]"; } $auto_increment = $auto_increment ? 0 : get_val("SELECT seq FROM sqlite_sequence WHERE name = " . q($table)); // if $auto_increment is set then it will be updated later @@ -633,7 +633,7 @@ if (isset($_GET["sqlite"])) { return false; } - function trigger($name) { + function trigger($name, $table) { if ($name == "") { return array("Statement" => "BEGIN\n\t;\nEND"); } diff --git a/adminer/dump.inc.php b/adminer/dump.inc.php index 16a3c8f3..0284c655 100644 --- a/adminer/dump.inc.php +++ b/adminer/dump.inc.php @@ -93,6 +93,7 @@ SET foreign_key_checks = 0; $table = (DB == "" || in_array($name, (array) $_POST["tables"])); $data = (DB == "" || in_array($name, (array) $_POST["data"])); if ($table || $data) { + $tmp_file = null; if ($ext == "tar") { $tmp_file = new TmpFile; ob_start(array($tmp_file, 'write'), 1e5); diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 948aaafb..1d457bbc 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -1050,8 +1050,10 @@ function lzw_decompress($binary) { } } // decompression + /** @var list */ $dictionary = range("\0", "\xFF"); $return = ""; + $word = ""; foreach ($codes as $i => $code) { $element = $dictionary[$code]; if (!isset($element)) { diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 1cbb0683..d0dba925 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -118,9 +118,7 @@ if ($_POST && !$error) { } } if ($_POST["delete"] || $set) { - if ($_POST["clone"]) { - $query = "INTO " . table($TABLE) . " (" . implode(", ", array_keys($set)) . ")\nSELECT " . implode(", ", $set) . "\nFROM " . table($TABLE); - } + $query = ($_POST["clone"] ? "INTO " . table($TABLE) . " (" . implode(", ", array_keys($set)) . ")\nSELECT " . implode(", ", $set) . "\nFROM " . table($TABLE) : ""); if ($_POST["all"] || ($primary && is_array($_POST["check"])) || $is_group) { $result = ($_POST["delete"] ? $driver->delete($TABLE, $where_check) @@ -484,6 +482,7 @@ if (!$columns && support("table")) { if (!is_ajax()) { if ($rows || $page) { $exact_count = true; + $found_rows = null; if ($_GET["page"] != "last") { if ($limit == "" || (count($rows) < $limit && ($rows || !$page))) { $found_rows = ($page ? $page * $limit : 0) + count($rows); @@ -507,10 +506,8 @@ if (!$columns && support("table")) { ); echo "\n"; } - } - echo "\n"; - if ($adminer->selectImportPrint()) { echo "
"; echo "" . lang('Import') . ""; diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index 6fdc849e..67ded633 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -152,6 +152,7 @@ if (!$error && $_POST) { $time .= ", " . lang('Warnings') . "" . script("qsl('a').onclick = partial(toggle, '$warnings_id');", ""); } $explain = null; + $orgtables = null; $explain_id = "explain-$commands"; if (is_object($result)) { $limit = $_POST["limit"]; diff --git a/compile.php b/compile.php index 47a95dfd..24f98f5e 100755 --- a/compile.php +++ b/compile.php @@ -219,7 +219,7 @@ function minify_js($file) { return lzw_compress($file); } -function compile_file($match) { +function compile_file($match, $callback) { // $callback only to match signature global $project; $file = ""; list(, $filenames, $callback) = $match; diff --git a/phpstan.neon b/phpstan.neon index 3a9be1bb..df336bbd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,10 +1,11 @@ parameters: - level: 0 + level: 1 ignoreErrors: - identifier: include.fileNotFound # relative includes - identifier: includeOnce.fileNotFound # ./adminer-plugins.php - "~^Function (set_magic_quotes_runtime|mysql_)~" # PHP < 7 functions - "~^Instantiated class Adminer\\w~" # no support for classes defined inside function + - "~^Variable \\$(adminer|connection|driver|drivers|error|HTTPS|LANG|langs|permanent|has_token|token|translations|VERSION) might not be defined~" # declared in bootstrap.inc.php paths: - . phpVersion: diff --git a/plugins/drivers/elastic.php b/plugins/drivers/elastic.php index 2369d0e8..55f3ff06 100644 --- a/plugins/drivers/elastic.php +++ b/plugins/drivers/elastic.php @@ -207,9 +207,7 @@ if (isset($_GET["elastic"])) { if (empty($search)) { return false; } - if ($select == array("*")) { - $tableFields = array_keys(fields($table)); - } + $tableFields = ($select == array("*") ? array_keys(fields($table)) : array()); $return = array(); foreach ($search["hits"]["hits"] as $hit) { @@ -332,7 +330,7 @@ if (isset($_GET["elastic"])) { return $credentials[1]; } - function get_databases() { + function get_databases($flush) { return array("elastic"); } @@ -445,7 +443,7 @@ if (isset($_GET["elastic"])) { return h(connection()->error); } - function information_schema() { + function information_schema($db) { // } diff --git a/plugins/drivers/mongo.php b/plugins/drivers/mongo.php index 55abb3f1..bbe925df 100644 --- a/plugins/drivers/mongo.php +++ b/plugins/drivers/mongo.php @@ -478,7 +478,7 @@ if (isset($_GET["mongo"])) { function db_collation($db, $collations) { } - function information_schema() { + function information_schema($db) { } function is_view($table_status) { diff --git a/plugins/drivers/simpledb.php b/plugins/drivers/simpledb.php index b154c675..ead12be8 100644 --- a/plugins/drivers/simpledb.php +++ b/plugins/drivers/simpledb.php @@ -274,7 +274,7 @@ if (isset($_GET["simpledb"])) { return $credentials[1]; } - function get_databases() { + function get_databases($flush) { return array("domain"); } @@ -329,7 +329,7 @@ if (isset($_GET["simpledb"])) { return h($connection->error); } - function information_schema() { + function information_schema($db) { } function indexes($table, $connection2 = null) {