]> git.joonet.de Git - adminer.git/commitdiff
Don't display warnings for failed queries
authorJakub Vrana <jakub@vrana.cz>
Thu, 1 Feb 2018 12:12:05 +0000 (13:12 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 1 Feb 2018 12:16:37 +0000 (13:16 +0100)
adminer/call.inc.php
adminer/drivers/elastic.inc.php
adminer/include/adminer.inc.php
adminer/include/driver.inc.php
adminer/include/functions.inc.php
editor/include/adminer.inc.php
plugins/master-slave.php
plugins/plugin.php
plugins/sql-log.php

index 3f639a0c75cbcf99b5fb84514cde3ae011ecf061..69d963be5a03298bbafafb8a884fa6805946fbcf 100644 (file)
@@ -32,7 +32,7 @@ if (!$error && $_POST) {
        $query = (isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . table($PROCEDURE) . "(" . implode(", ", $call) . ")";
        $start = microtime(true);
        $result = $connection->multi_query($query);
-       echo $adminer->selectQuery($query, $start);
+       echo $adminer->selectQuery($query, $start, !$result);
        
        if (!$result) {
                echo "<p class='error'>" . error() . "\n";
index 00be43258db991984a73dc1cc97a6dd00efc081f..5bb600f932521724c8ee9fc4e77ce21395e606d0 100644 (file)
@@ -148,7 +148,7 @@ if (isset($_GET["elastic"])) {
                        $start = microtime(true);
                        $search = $this->_conn->query($query, $data);
                        if ($print) {
-                               echo $adminer->selectQuery("$query: " . print_r($data, true), $start);
+                               echo $adminer->selectQuery("$query: " . print_r($data, true), $start, !$search);
                        }
                        if (!$search) {
                                return false;
index 519a526ab034b6958b5e695ca5296f76763377be..82918d003b6912a38cca5fdef6ff6a979e83179a 100644 (file)
@@ -203,13 +203,13 @@ class Adminer {
        /** Query printed in select before execution
        * @param string query to be executed
        * @param float start time of the query
+       * @param bool
        * @return string
        */
-       function selectQuery($query, $start) {
+       function selectQuery($query, $start, $failed = false) {
                global $jush, $driver;
                $return = "</p>\n"; // required for IE9 inline edit
-               $warnings = $driver->warnings();
-               if ($warnings) {
+               if (!$failed && ($warnings = $driver->warnings())) {
                        $id = "warnings";
                        $return = ", <a href='#$id'>" . lang('Warnings') . "</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "")
                                . "$return<div id='$id' class='hidden'>\n$warnings</div>\n"
@@ -609,9 +609,10 @@ class Adminer {
        /** Query printed after execution in the message
        * @param string executed query
        * @param string elapsed time
+       * @param bool
        * @return string
        */
-       function messageQuery($query, $time) {
+       function messageQuery($query, $time, $failed = false) {
                global $jush, $driver;
                restart_session();
                $history = &get_session("queries");
@@ -624,8 +625,7 @@ class Adminer {
                $history[$_GET["db"]][] = array($query, time(), $time); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
                $sql_id = "sql-" . count($history[$_GET["db"]]);
                $return = "<a href='#$sql_id' class='toggle'>" . lang('SQL command') . "</a>\n";
-               $warnings = $driver->warnings();
-               if ($warnings) {
+               if (!$failed && ($warnings = $driver->warnings())) {
                        $id = "warnings-" . count($history[$_GET["db"]]);
                        $return = "<a href='#$id' class='toggle'>" . lang('Warnings') . "</a>, $return<div id='$id' class='hidden'>\n$warnings</div>\n";
                }
index 1963390aa1f2a9b6e3d0ed6fcdd993e603ea960a..543894bbf7c27cdeef9f5edab10f2966b7de34e9 100644 (file)
@@ -37,7 +37,7 @@
                $start = microtime(true);
                $return = $this->_conn->query($query);
                if ($print) {
-                       echo $adminer->selectQuery($query, $start);
+                       echo $adminer->selectQuery($query, $start, !$return);
                }
                return $return;
        }
index 30eb1e91f36f740c2df5b76af961ba2a2d5c2699..9f78c205a5e327138680d226d8f87f693bcba2f3 100644 (file)
@@ -647,7 +647,7 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
        }
        $sql = "";
        if ($query) {
-               $sql = $adminer->messageQuery($query, $time);
+               $sql = $adminer->messageQuery($query, $time, $failed);
        }
        if ($failed) {
                $error = error() . $sql . script("messagesPrint();");
index 4fec8a90ae22f6ac3d799dcd6f77aa573b2ddcfc..535c7943610bf00fa6720c6006efd13745b094a6 100644 (file)
@@ -140,7 +140,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
                }
        }
 
-       function selectQuery($query, $start) {
+       function selectQuery($query, $start, $failed = false) {
                return "<!--\n" . str_replace("--", "--><!-- ", $query) . "\n(" . format_time($start) . ")\n-->\n";
        }
 
@@ -440,7 +440,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
                return "";
        }
 
-       function messageQuery($query, $time) {
+       function messageQuery($query, $time, $failed = false) {
                return " <span class='time'>" . @date("H:i:s") . "</span><!--\n" . str_replace("--", "--><!-- ", $query) . "\n" . ($time ? "($time)\n" : "") . "-->";
        }
 
index 7b3adbbd96dd2415a58a41a02d153ecb5ca655f9..4798c65c33988cafd39d212d20d50e74ca3e2f4c 100644 (file)
@@ -30,7 +30,7 @@ class AdminerMasterSlave {
                }
        }
 
-       function messageQuery($query, $time) {
+       function messageQuery($query, $time, $failed = false) {
                //! doesn't work with sql.inc.php
                $connection = connection();
                $result = $connection->query('SHOW MASTER STATUS');
index 9617fe5bceb06e1ad8047ef05635cef6a964f2c2..fec581e33fece647e57553c35d067c36b61a374d 100644 (file)
@@ -182,7 +182,7 @@ class AdminerPlugin extends Adminer {
                return $this->_applyPlugin(__FUNCTION__, $args);
        }
 
-       function selectQuery($query, $start) {
+       function selectQuery($query, $start, $failed = false) {
                $args = func_get_args();
                return $this->_applyPlugin(__FUNCTION__, $args);
        }
@@ -307,7 +307,7 @@ class AdminerPlugin extends Adminer {
                return $this->_applyPlugin(__FUNCTION__, $args);
        }
 
-       function messageQuery($query, $time) {
+       function messageQuery($query, $time, $failed = false) {
                $args = func_get_args();
                return $this->_applyPlugin(__FUNCTION__, $args);
        }
index 778fb9eeae964c2f879664895e60c5724d4b321f..584fe3ef0dcc6e3efc6277374d67b1768380c041 100644 (file)
@@ -17,7 +17,7 @@ class AdminerSqlLog {
                $this->filename = $filename;
        }
        
-       function messageQuery($query, $time) {
+       function messageQuery($query, $time, $failed = false) {
                $this->_log($query);
        }