]> git.joonet.de Git - adminer.git/commitdiff
Plugins: Add method dumpFooter()
authorJakub Vrana <jakub@vrana.cz>
Tue, 11 Mar 2025 07:59:38 +0000 (08:59 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 11 Mar 2025 07:59:38 +0000 (08:59 +0100)
adminer/dump.inc.php
adminer/include/adminer.inc.php
adminer/select.inc.php
adminer/sql.inc.php
changes.txt
editor/include/adminer.inc.php
plugins/dump-json.php
plugins/dump-php.php
plugins/dump-xml.php
plugins/plugin.php

index d3e2d425e5e12090e72519e2cd4cdcaab8519fbb..a5352429ece0ff60e7997ec9175ee778b1631c7f 100644 (file)
@@ -140,9 +140,7 @@ SET foreign_key_checks = 0;
                }
        }
 
-       if ($is_sql) {
-               echo "-- " . gmdate("Y-m-d H:i:s e") . "\n";
-       }
+       $adminer->dumpFooter();
        exit;
 }
 
index 7c8028de483cdefd6f970b53ace33538356787bf..9ee7eba3c174f854b84e70eec94e75544c7622df 100644 (file)
@@ -945,6 +945,15 @@ class Adminer {
                return $ext;
        }
 
+       /** Print text after export
+       * @return null prints data
+       */
+       function dumpFooter() {
+               if ($_POST["format"] == "sql") {
+                       echo "-- " . gmdate("Y-m-d H:i:s e") . "\n";
+               }
+       }
+
        /** Set the path of the file for webserver load
        * @return string path of the sql dump file
        */
index 95950d7204f6b47f1980ee84d93266aae11a2b32..8631c6551a088a01fc5b209d0ba9fd57bf84b400 100644 (file)
@@ -100,6 +100,7 @@ if ($_POST && !$error) {
                        $query = implode(" UNION ALL ", $union);
                }
                $adminer->dumpData($TABLE, "table", $query);
+               $adminer->dumpFooter();
                exit;
        }
 
index 088be1a04f6c1a98aed67f3ba1abcf75650c5aa2..86181108c2759c3d40f13cab0812d048688c2faa 100644 (file)
@@ -5,6 +5,7 @@ if (!$error && $_POST["export"]) {
        dump_headers("sql");
        $adminer->dumpTable("", "");
        $adminer->dumpData("", "table", $_POST["query"]);
+       $adminer->dumpFooter();
        exit;
 }
 
index 7b0688d9c50ac6738321d6f9e2465f0c777de9a1..d753598774fda232b28aa034416ebcb935ac62eb 100644 (file)
@@ -9,6 +9,7 @@ MariaDB: Fix creating and altering generated columns (bug #897)
 SQLite: Fix creating table in compiled version (bug #901, regression from 5.0.0)
 Elastic: Do not pass null values on insert (PR #892)
 Elastic: Fix displaying sparse rows (PR #893)
+Plugins: Add method dumpFooter()
 
 Adminer 5.0.2 (released 2025-03-10):
 PostgreSQL: Fix setting NULL and original value on enum (bug #884)
index 65ebb88b35f5abfbc6b4224ff15bcf4383c12cd6..6518919ca406d64c545fae087e2bd20f2f7fd124 100644 (file)
@@ -574,6 +574,9 @@ qsl('div').onclick = whisperClick;", "")
                return $ext;
        }
 
+       function dumpFooter() {
+       }
+
        function importServerPath() {
        }
 
index a295e3dcd90660d8ba62faa94b59683786780f74..cd0feda894abda11c3adf47fb48c0676889b372a 100644 (file)
@@ -19,10 +19,6 @@ class AdminerDumpJson {
                }
        }
 
-       function _database() {
-               echo "}\n";
-       }
-
        function dumpData($table, $style, $query) {
                if ($_POST["format"] == "json") {
                        if ($this->database) {
@@ -30,7 +26,6 @@ class AdminerDumpJson {
                        } else {
                                $this->database = true;
                                echo "{\n";
-                               register_shutdown_function(array($this, '_database'));
                        }
                        $connection = Adminer\connection();
                        $result = $connection->query($query, 1);
@@ -57,4 +52,10 @@ class AdminerDumpJson {
                        return "json";
                }
        }
+
+       function dumpFooter() {
+               if ($_POST["format"] == "json" && $this->database) {
+                       echo "}\n";
+               }
+       }
 }
index c1e36a2d6342466b9c398c718d6a91ad295c4468..8404a621c39b3946e703663573bad0ffcb49bf82 100644 (file)
@@ -7,7 +7,6 @@
 */
 class AdminerDumpPhp {
        protected $output = array();
-       protected $shutdown_callback = false;
 
        function dumpFormat() {
                return array('php' => 'PHP');
@@ -23,10 +22,6 @@ class AdminerDumpPhp {
        function dumpTable($table, $style, $is_view = 0) {
                if ($_POST['format'] == 'php') {
                        $this->output[$table] = array();
-                       if (!$this->shutdown_callback) {
-                               $this->shutdown_callback = true;
-                               register_shutdown_function(array($this, '_export'));
-                       }
                        return true;
                }
        }
@@ -44,8 +39,11 @@ class AdminerDumpPhp {
                }
        }
 
-       function _export() {
-               echo "<?php\n";
-               var_export($this->output);
+       function dumpFooter() {
+               if ($_POST['format'] == 'php') {
+                       echo "<?php\n";
+                       var_export($this->output);
+                       echo ";\n";
+               }
        }
 }
index b983cfad7adbb1480f60ef0dbe2f79d3350ccfd4..57e4431797c5f4a99ba6459cd0fdfa7bcb11dd31 100644 (file)
@@ -19,16 +19,11 @@ class AdminerDumpXml {
                }
        }
 
-       function _database() {
-               echo "</database>\n";
-       }
-
        function dumpData($table, $style, $query) {
                if ($_POST["format"] == "xml") {
                        if (!$this->database) {
                                $this->database = true;
                                echo "<database name='" . Adminer\h(Adminer\DB) . "'>\n";
-                               register_shutdown_function(array($this, '_database'));
                        }
                        $connection = Adminer\connection();
                        $result = $connection->query($query, 1);
@@ -51,4 +46,10 @@ class AdminerDumpXml {
                        return "xml";
                }
        }
+
+       function dumpFooter() {
+               if ($_POST["format"] == "xml" && $this->database) {
+                       echo "</database>\n";
+               }
+       }
 }
index aa3cb6dbb79ae29bcb98ee1d8d18f608582ee68c..b2e4aa510ec214ccedafb73610fcc3576ad56d5a 100644 (file)
@@ -387,6 +387,11 @@ class AdminerPlugin extends Adminer\Adminer {
                return $this->applyPlugin(__FUNCTION__, $args);
        }
 
+       function dumpFooter() {
+               $args = func_get_args();
+               return $this->applyPlugin(__FUNCTION__, $args);
+       }
+
        function importServerPath() {
                $args = func_get_args();
                return $this->applyPlugin(__FUNCTION__, $args);