1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-18 12:21:24 +02:00

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

@@ -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";
}

View 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;
}

View 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();");