Don't display warnings for failed queries

This commit is contained in:
Jakub Vrana 2018-02-01 13:12:05 +01:00
parent 51a574926d
commit ae91088cb3
9 changed files with 16 additions and 16 deletions

View file

@ -32,7 +32,7 @@ if (!$error && $_POST) {
$query = (isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . table($PROCEDURE) . "(" . implode(", ", $call) . ")"; $query = (isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . table($PROCEDURE) . "(" . implode(", ", $call) . ")";
$start = microtime(true); $start = microtime(true);
$result = $connection->multi_query($query); $result = $connection->multi_query($query);
echo $adminer->selectQuery($query, $start); echo $adminer->selectQuery($query, $start, !$result);
if (!$result) { if (!$result) {
echo "<p class='error'>" . error() . "\n"; echo "<p class='error'>" . error() . "\n";

View file

@ -148,7 +148,7 @@ if (isset($_GET["elastic"])) {
$start = microtime(true); $start = microtime(true);
$search = $this->_conn->query($query, $data); $search = $this->_conn->query($query, $data);
if ($print) { if ($print) {
echo $adminer->selectQuery("$query: " . print_r($data, true), $start); echo $adminer->selectQuery("$query: " . print_r($data, true), $start, !$search);
} }
if (!$search) { if (!$search) {
return false; return false;

View file

@ -203,13 +203,13 @@ class Adminer {
/** Query printed in select before execution /** Query printed in select before execution
* @param string query to be executed * @param string query to be executed
* @param float start time of the query * @param float start time of the query
* @param bool
* @return string * @return string
*/ */
function selectQuery($query, $start) { function selectQuery($query, $start, $failed = false) {
global $jush, $driver; global $jush, $driver;
$return = "</p>\n"; // required for IE9 inline edit $return = "</p>\n"; // required for IE9 inline edit
$warnings = $driver->warnings(); if (!$failed && ($warnings = $driver->warnings())) {
if ($warnings) {
$id = "warnings"; $id = "warnings";
$return = ", <a href='#$id'>" . lang('Warnings') . "</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "") $return = ", <a href='#$id'>" . lang('Warnings') . "</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "")
. "$return<div id='$id' class='hidden'>\n$warnings</div>\n" . "$return<div id='$id' class='hidden'>\n$warnings</div>\n"
@ -609,9 +609,10 @@ class Adminer {
/** Query printed after execution in the message /** Query printed after execution in the message
* @param string executed query * @param string executed query
* @param string elapsed time * @param string elapsed time
* @param bool
* @return string * @return string
*/ */
function messageQuery($query, $time) { function messageQuery($query, $time, $failed = false) {
global $jush, $driver; global $jush, $driver;
restart_session(); restart_session();
$history = &get_session("queries"); $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"] $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"]]); $sql_id = "sql-" . count($history[$_GET["db"]]);
$return = "<a href='#$sql_id' class='toggle'>" . lang('SQL command') . "</a>\n"; $return = "<a href='#$sql_id' class='toggle'>" . lang('SQL command') . "</a>\n";
$warnings = $driver->warnings(); if (!$failed && ($warnings = $driver->warnings())) {
if ($warnings) {
$id = "warnings-" . count($history[$_GET["db"]]); $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"; $return = "<a href='#$id' class='toggle'>" . lang('Warnings') . "</a>, $return<div id='$id' class='hidden'>\n$warnings</div>\n";
} }

View file

@ -37,7 +37,7 @@
$start = microtime(true); $start = microtime(true);
$return = $this->_conn->query($query); $return = $this->_conn->query($query);
if ($print) { if ($print) {
echo $adminer->selectQuery($query, $start); echo $adminer->selectQuery($query, $start, !$return);
} }
return $return; return $return;
} }

View file

@ -647,7 +647,7 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
} }
$sql = ""; $sql = "";
if ($query) { if ($query) {
$sql = $adminer->messageQuery($query, $time); $sql = $adminer->messageQuery($query, $time, $failed);
} }
if ($failed) { if ($failed) {
$error = error() . $sql . script("messagesPrint();"); $error = error() . $sql . script("messagesPrint();");

View 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"; 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 ""; 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" : "") . "-->"; return " <span class='time'>" . @date("H:i:s") . "</span><!--\n" . str_replace("--", "--><!-- ", $query) . "\n" . ($time ? "($time)\n" : "") . "-->";
} }

View file

@ -30,7 +30,7 @@ class AdminerMasterSlave {
} }
} }
function messageQuery($query, $time) { function messageQuery($query, $time, $failed = false) {
//! doesn't work with sql.inc.php //! doesn't work with sql.inc.php
$connection = connection(); $connection = connection();
$result = $connection->query('SHOW MASTER STATUS'); $result = $connection->query('SHOW MASTER STATUS');

View file

@ -182,7 +182,7 @@ class AdminerPlugin extends Adminer {
return $this->_applyPlugin(__FUNCTION__, $args); return $this->_applyPlugin(__FUNCTION__, $args);
} }
function selectQuery($query, $start) { function selectQuery($query, $start, $failed = false) {
$args = func_get_args(); $args = func_get_args();
return $this->_applyPlugin(__FUNCTION__, $args); return $this->_applyPlugin(__FUNCTION__, $args);
} }
@ -307,7 +307,7 @@ class AdminerPlugin extends Adminer {
return $this->_applyPlugin(__FUNCTION__, $args); return $this->_applyPlugin(__FUNCTION__, $args);
} }
function messageQuery($query, $time) { function messageQuery($query, $time, $failed = false) {
$args = func_get_args(); $args = func_get_args();
return $this->_applyPlugin(__FUNCTION__, $args); return $this->_applyPlugin(__FUNCTION__, $args);
} }

View file

@ -17,7 +17,7 @@ class AdminerSqlLog {
$this->filename = $filename; $this->filename = $filename;
} }
function messageQuery($query, $time) { function messageQuery($query, $time, $failed = false) {
$this->_log($query); $this->_log($query);
} }