]> git.joonet.de Git - adminer.git/commitdiff
Notices: Add helper for reset() with expression
authorJakub Vrana <jakub@vrana.cz>
Sun, 23 Mar 2025 20:38:36 +0000 (21:38 +0100)
committerJakub Vrana <jakub@vrana.cz>
Sun, 23 Mar 2025 20:39:25 +0000 (21:39 +0100)
adminer/drivers/pgsql.inc.php
adminer/drivers/sqlite.inc.php
adminer/include/functions.inc.php
adminer/select.inc.php
adminer/sql.inc.php

index a05b1dc41e359e322ce4b80af28d7b36fe003aa5..9fd74c2389e1ef47fc1c67f76e3124d2f63218de 100644 (file)
@@ -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, "-- "));
index 3b9fc0a9538d1de42252a65ea18f2cd654a3da80..a50921d2e790f22c8fbafb04cd299ec7356a2407 100644 (file)
@@ -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)) . "'"
                                );
                        }
 
index d9988f333077287b506db1e5c34ca9c2887f3708..f1b468e7b8c9d74e75ed2aeaa4bd144149f0ca16 100644 (file)
@@ -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
index d814ac18abd66f78582caae1ebb1eb0da41ae158..9092d520f303bce1408a73b97193a123b4f53f02 100644 (file)
@@ -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;
                                                }
index 02db018a7d3921fba308c5362a1f6ecc51a8bf65..60f9f5525349af501dd7548600212ec04f192109 100644 (file)
@@ -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()