]> git.joonet.de Git - adminer.git/commitdiff
Return string from warnings()
authorJakub Vrana <jakub@vrana.cz>
Thu, 1 Feb 2018 10:43:44 +0000 (11:43 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 1 Feb 2018 10:43:44 +0000 (11:43 +0100)
adminer/drivers/mysql.inc.php
adminer/include/adminer.inc.php
adminer/include/driver.inc.php
adminer/sql.inc.php

index 8eba872cec61ec7fcee1c3d17f627976ea6df3fb..890a6aaa3d1d8951b512624d5813ad3aa67e1c68 100644 (file)
@@ -278,7 +278,12 @@ if (!defined("DRIVER")) {
                }
                
                function warnings() {
-                       return $this->_conn->query("SHOW WARNINGS");
+                       $result = $this->_conn->query("SHOW WARNINGS");
+                       if ($result && $result->num_rows) {
+                               ob_start();
+                               select($result); // select() usually needs to print a big table progressively
+                               return ob_get_clean();
+                       }
                }
 
        }
index 0d66ac48ff8baeae1c98d462204f3d3c36480ffe..c28881e943c78bfd264bd2b4e11674a5fa904bf0 100644 (file)
@@ -212,12 +212,10 @@ class Adminer {
                ;
                $print = "</p>\n"; // required for IE9 inline edit
                $warnings = $driver->warnings();
-               if ($warnings && $warnings->num_rows) {
+               if ($warnings) {
                        $id = "warnings";
-                       ob_start();
-                       select($warnings); // select() usually needs to print a big table progressively
                        $return .= ", <a href='#$id'>" . lang('Warnings') . "</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "")
-                               . "$print<div id='$id' class='hidden'>\n" . ob_get_clean() . "</div>\n"
+                               . "$print<div id='$id' class='hidden'>\n$warnings</div>\n"
                        ;
                } else {
                        $return .= $print;
@@ -629,16 +627,13 @@ class Adminer {
                $return = " <span class='time'>" . @date("H:i:s") . "</span>"; // @ - time zone may be not set
                $warnings = $driver->warnings();
                $print = "";
-               if ($warnings && $warnings->num_rows) {
+               if ($warnings) {
                        $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";
+                       $print = "<div id='$id' class='hidden'>\n$warnings</div>\n";
                }
                $id = "sql-" . count($history[$_GET["db"]]);
-               return $return
-                       . " <a href='#$id' class='toggle'>" . lang('SQL command') . "</a>"
+               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>" : '')
index a6d1afcde4bc8c7e2f9c41a8c579270f77de95c2..2c66a36315c3c9c41eba815fe5fdb033975e2dfb 100644 (file)
        }
        
        /** Get warnings about the last command
-       * @return Min_Result or false
+       * @return string HTML
        */
        function warnings() {
-               return false;
+               return '';
        }
        
 }
index c5a271460f28a861641e8f8308e268d188308dfb..175a80bd5810b2c3196aee1cfc3f55e614dbc6f0 100644 (file)
@@ -130,9 +130,9 @@ if (!$error && $_POST) {
                                                                        $time = " <span class='time'>(" . format_time($start) . ")</span>"
                                                                                . (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : "") // 1000 - maximum length of encoded URL in IE is 2083 characters
                                                                        ;
-                                                                       $warnings = $driver->warnings();
-                                                                       $warnings_id = "warnings-$commands";
-                                                                       if ($warnings && $warnings->num_rows) {
+                                                                       $warnings = ($_POST["only_errors"] ? "" : $driver->warnings());
+                                                                       if ($warnings) {
+                                                                               $warnings_id = "warnings-$commands";
                                                                                $time .= ", <a href='#$warnings_id'>" . lang('Warnings') . "</a>" . script("qsl('a').onclick = partial(toggle, '$warnings_id');", "");
                                                                        }
                                                                        $explain = null;
@@ -168,11 +168,7 @@ if (!$error && $_POST) {
                                                                                        echo "<p class='message' title='" . h($connection->info) . "'>" . lang('Query executed OK, %d row(s) affected.', $connection->affected_rows) . "$time\n";
                                                                                }
                                                                        }
-                                                                       if ($warnings && $warnings->num_rows && !$_POST["only_errors"]) {
-                                                                               echo "<div id='$warnings_id' class='hidden'>\n";
-                                                                               select($warnings);
-                                                                               echo "</div>\n";
-                                                                       }
+                                                                       echo ($warnings ? "<div id='$warnings_id' class='hidden'>\n$warnings</div>\n" : "");
                                                                        if ($explain) {
                                                                                echo "<div id='$explain_id' class='hidden'>\n";
                                                                                select($explain, $connection2, $orgtables);