diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index a05b1dc4..9fd74c23 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -876,7 +876,7 @@ AND typelem = 0" // sequences for fields if (preg_match('~nextval\(\'([^\']+)\'\)~', $field['default'], $matches)) { $sequence_name = $matches[1]; - $sq = reset(get_rows((min_version(10) + $sq = first(get_rows((min_version(10) ? "SELECT *, cache_size AS cache_value FROM pg_sequences WHERE schemaname = current_schema() AND sequencename = " . q(idf_unescape($sequence_name)) : "SELECT * FROM $sequence_name" ), null, "-- ")); diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index 3b9fc0a9..a50921d2 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -34,7 +34,7 @@ if (isset($_GET["sqlite"])) { function quote($string) { return (is_utf8($string) ? "'" . $this->link->escapeString($string) . "'" - : "x'" . reset(unpack('H*', $string)) . "'" + : "x'" . first(unpack('H*', $string)) . "'" ); } diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index d9988f33..f1b468e7 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -847,6 +847,15 @@ function file_unlock($fp) { fclose($fp); } +/** Get first element of an array +* @param array +* @return mixed or false if not found +*/ +function first($array) { + // reset(f()) triggers a notice + return reset($array); +} + /** Read password from file adminer.key in temporary directory or create one * @param bool * @return string or false if the file can not be created diff --git a/adminer/select.inc.php b/adminer/select.inc.php index d814ac18..9092d520 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -491,7 +491,7 @@ if (!$columns && support("table")) { $found_rows = ($is_group ? false : found_rows($table_status, $where)); if ($found_rows < max(1e4, 2 * ($page + 1) * $limit)) { // slow with big tables - $found_rows = reset(slow_query(count_rows($TABLE, $where, $is_group, $group))); + $found_rows = first(slow_query(count_rows($TABLE, $where, $is_group, $group))); } else { $exact_count = false; } diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index 02db018a..60f9f552 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -42,7 +42,7 @@ if (!$error && $_POST) { if ($query != "" && strlen($query) < 1e6) { // don't add big queries $q = $query . (preg_match("~;[ \t\r\n]*\$~", $query) ? "" : ";"); //! doesn't work with DELIMITER | - if (!$history || reset(end($history)) != $q) { // no repeated queries + if (!$history || first(end($history)) != $q) { // no repeated queries restart_session(); $history[] = array($q, time()); //! add elapsed time set_session("queries", $history_all); // required because reference is unlinked by stop_session()