]> git.joonet.de Git - adminer.git/commitdiff
Display warnings in messages
authorJakub Vrana <jakub@vrana.cz>
Thu, 1 Feb 2018 08:21:50 +0000 (09:21 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 1 Feb 2018 08:21:50 +0000 (09:21 +0100)
adminer/include/adminer.inc.php
adminer/static/default.css
changes.txt

index 77f05c30b00397be8d9cda82ca7fd445657232e2..0d66ac48ff8baeae1c98d462204f3d3c36480ffe 100644 (file)
@@ -616,19 +616,30 @@ class Adminer {
        * @return string
        */
        function messageQuery($query, $time) {
-               global $jush;
+               global $jush, $driver;
                restart_session();
                $history = &get_session("queries");
                if (!$history[$_GET["db"]]) {
                        $history[$_GET["db"]] = array();
                }
-               $id = "sql-" . count($history[$_GET["db"]]);
                if (strlen($query) > 1e6) {
                        $query = preg_replace('~[\x80-\xFF]+$~', '', substr($query, 0, 1e6)) . "\n..."; // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
                }
                $history[$_GET["db"]][] = array($query, time(), $time); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
-               return " <span class='time'>" . @date("H:i:s") . "</span>" // @ - time zone may be not set
+               $return = " <span class='time'>" . @date("H:i:s") . "</span>"; // @ - time zone may be not set
+               $warnings = $driver->warnings();
+               $print = "";
+               if ($warnings && $warnings->num_rows) {
+                       $id = "warnings-" . count($history[$_GET["db"]]);
+                       $return .= " <a href='#$id' class='toggle'>" . lang('Warnings') . "</a>,";
+                       ob_start();
+                       select($warnings); // select() usually needs to print a big table progressively
+                       $print = "<div id='$id' class='hidden'>\n" . ob_get_clean() . "</div>\n";
+               }
+               $id = "sql-" . count($history[$_GET["db"]]);
+               return $return
                        . " <a href='#$id' class='toggle'>" . lang('SQL command') . "</a>"
+                       . $print
                        . "<div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></pre>'
                        . ($time ? " <span class='time'>($time)</span>" : '')
                        . (support("sql") ? '<p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a>' : '')
index 7e46dcd58375094be5fad7e6b133548ed2744006..898f272430cf5aad0b54e2b04e6fa70ddee02865 100644 (file)
@@ -37,6 +37,7 @@ input.wayoff { left: -1000px; position: absolute; }
 .error { color: red; background: #fee; }
 .error b { background: #fff; font-weight: normal; }
 .message { color: green; background: #efe; }
+.message table { color: #000; background: #fff; }
 .error, .message { padding: .5em .8em; margin: 1em 20px 0 0; }
 .char { color: #007F00; }
 .date { color: #7F007F; }
index 38f0cc1c08a0b6c6b9bef7bd9a66b3c08428bbbe..9e46a6cf42cf1d1532b0710d50e17c4796e0af4e 100644 (file)
@@ -4,7 +4,7 @@ PHP <5.3 compatibility even with Elasticsearch enabled
 Fully support functions in default values
 Stop redirecting links via adminer.org
 Support X-Forwarded-Prefix
-MySQL: Display warnings in SQL command and select
+MySQL: Display warnings
 MariaDB: Support JSON since MariaDB 10.2
 PostgreSQL: Support functions
 PostgreSQL: Allow editing views with uppercase letters (bug #467)