]> git.joonet.de Git - adminer.git/commitdiff
Notices: Use idx()
authorJakub Vrana <jakub@vrana.cz>
Wed, 26 Mar 2025 06:55:30 +0000 (07:55 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 26 Mar 2025 09:21:36 +0000 (10:21 +0100)
adminer/include/auth.inc.php
adminer/include/functions.inc.php
adminer/sql.inc.php
plugins/codemirror.php
plugins/drivers/imap.php

index 66abb11144edd40061dacd75ad22fde1b818c751..ebf3b63fa6e489fa23f54f06248aa3b45d54f011 100644 (file)
@@ -61,8 +61,8 @@ function check_invalid_login() {
                        break;
                }
        }
-       $invalid = ($invalids ? $invalids[$adminer->bruteForceKey()] : array());
-       $next_attempt = (idx($invalid, 1) > 29 ? $invalid[0] - time() : 0); // allow 30 invalid attempts
+       $invalid = idx($invalids, $adminer->bruteForceKey(), array());
+       $next_attempt = ($invalid[1] > 29 ? $invalid[0] - time() : 0); // allow 30 invalid attempts
        if ($next_attempt > 0) { //! do the same with permanent login
                auth_error(lang('Too many unsuccessful logins, try again in %d minute(s).', ceil($next_attempt / 60)));
        }
index 95cdde8338941a136cd731037e42ff41e6021ebe..7292c4afbab59a513c42d242d28e4ab05ee7fa3c 100644 (file)
@@ -66,6 +66,7 @@ function escape_string($val) {
 }
 
 /** Get a possibly missing item from a possibly missing array
+* idx($row, $key) is better than $row[$key] ?? null because it reports error for undefined $row
 * @param array|null
 * @param string|int
 * @param mixed
@@ -312,7 +313,7 @@ function where($where, $fields = array()) {
        foreach ((array) $where["where"] as $key => $val) {
                $key = bracket_escape($key, 1); // 1 - back
                $column = escape_key($key);
-               $field = ($fields ? $fields[$key] : array());
+               $field = idx($fields, $key, array());
                $field_type = $field["type"];
                $return[] = $column
                        . (JUSH == "sql" && $field_type == "json" ? " = CAST(" . q($val) . " AS JSON)"
index 3bce84d125fcddbb7780bcc6c324eba5111f45c2..6fdc849e13d190ee0b1a0ce508f3c1890629e6a2 100644 (file)
@@ -230,7 +230,7 @@ if (!isset($_GET["import"])) {
        } elseif ($_GET["history"] == "all") {
                $q = $history;
        } elseif ($_GET["history"] != "") {
-               $q = $history[$_GET["history"]][0];
+               $q = idx($history[$_GET["history"]], 0);
        }
        echo "<p>";
        textarea("query", $q, 20);
index 6d108a6544e443b0b0334c7b4fec5cad20cc4413..f7c05070cd3fe237164147c0437e3cfc688100a4 100644 (file)
@@ -72,7 +72,7 @@ for (const el of qsa('textarea')) {
                        hintOptions: {
                                completeSingle: false,
                                tables: <?php echo json_encode($tables); ?>,
-                               defaultTable: <?php echo json_encode($_GET["trigger"] ? $_GET["trigger"] : ($_GET["check"] ? $_GET["check"] : null)); ?>
+                               defaultTable: <?php echo json_encode($_GET["trigger"] ? $_GET["trigger"] : ($_GET["check"] ?: null)); ?>
                        }
                });
                cm.setSize(width, height);
index 0d236a32175d1daee83a8a361bb0565932469527..9583ac69134e9d983a50ad05b480dfa04da97adf 100644 (file)
@@ -122,7 +122,7 @@ if (isset($_GET["imap"])) {
                        function __construct($result) {
                                $this->result = $result;
                                $this->num_rows = count($result);
-                               $this->fields = ($result ? array_keys(reset($result)) : array());
+                               $this->fields = array_keys(idx($result, 0,  array()));
                        }
 
                        function fetch_assoc() {