diff --git a/adminer/dump.inc.php b/adminer/dump.inc.php index d3e2d425..a5352429 100644 --- a/adminer/dump.inc.php +++ b/adminer/dump.inc.php @@ -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; } diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 7c8028de..9ee7eba3 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -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 */ diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 95950d72..8631c655 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -100,6 +100,7 @@ if ($_POST && !$error) { $query = implode(" UNION ALL ", $union); } $adminer->dumpData($TABLE, "table", $query); + $adminer->dumpFooter(); exit; } diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index 088be1a0..86181108 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -5,6 +5,7 @@ if (!$error && $_POST["export"]) { dump_headers("sql"); $adminer->dumpTable("", ""); $adminer->dumpData("", "table", $_POST["query"]); + $adminer->dumpFooter(); exit; } diff --git a/changes.txt b/changes.txt index 7b0688d9..d7535987 100644 --- a/changes.txt +++ b/changes.txt @@ -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) diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 65ebb88b..6518919c 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -574,6 +574,9 @@ qsl('div').onclick = whisperClick;", "") return $ext; } + function dumpFooter() { + } + function importServerPath() { } diff --git a/plugins/dump-json.php b/plugins/dump-json.php index a295e3dc..cd0feda8 100644 --- a/plugins/dump-json.php +++ b/plugins/dump-json.php @@ -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"; + } + } } diff --git a/plugins/dump-php.php b/plugins/dump-php.php index c1e36a2d..8404a621 100644 --- a/plugins/dump-php.php +++ b/plugins/dump-php.php @@ -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 "output); + function dumpFooter() { + if ($_POST['format'] == 'php') { + echo "output); + echo ";\n"; + } } } diff --git a/plugins/dump-xml.php b/plugins/dump-xml.php index b983cfad..57e44317 100644 --- a/plugins/dump-xml.php +++ b/plugins/dump-xml.php @@ -19,16 +19,11 @@ class AdminerDumpXml { } } - function _database() { - echo "\n"; - } - function dumpData($table, $style, $query) { if ($_POST["format"] == "xml") { if (!$this->database) { $this->database = true; echo "\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 "\n"; + } + } } diff --git a/plugins/plugin.php b/plugins/plugin.php index aa3cb6db..b2e4aa51 100644 --- a/plugins/plugin.php +++ b/plugins/plugin.php @@ -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);