From e93e128510426e7cd348f562492664ce5f2b8184 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Tue, 7 Oct 2014 19:23:39 +0530 Subject: [PATCH] Port 'bug #3120 Events are not exported when using xml' to QA_4_2 Signed-off-by: Madhura Jayaratne --- ChangeLog | 1 + export.php | 1 + libraries/config.default.php | 7 ++++ libraries/plugins/export/ExportXml.class.php | 35 ++++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/ChangeLog b/ChangeLog index a885f70b4008..31b0e2ed3fd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ phpMyAdmin - ChangeLog - bug #4545 trying to favorite table while browser localStorage is disabled throws JS error - bug #4259 reCaptcha sound session expired problem - bug #4548 Inline editing a field converts tab to spaces +- bug #3120 Events are not exported when using xml 4.2.9.0 (2014-09-20) - bug ajax.js responseHandler: cannot read property of null diff --git a/export.php b/export.php index edcc8a1c9ea8..559d8dedf49f 100644 --- a/export.php +++ b/export.php @@ -87,6 +87,7 @@ 'ods_columns', 'json_structure_or_data', 'xml_structure_or_data', + 'xml_export_events', 'xml_export_functions', 'xml_export_procedures', 'xml_export_tables', diff --git a/libraries/config.default.php b/libraries/config.default.php index cf941b13f263..7067e7fedb31 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -1995,6 +1995,13 @@ */ $cfg['Export']['xml_export_struc'] = true; +/** + * Export events + * + * @global string $cfg['Export']['xml_export_events'] + */ +$cfg['Export']['xml_export_events'] = true; + /** * Export functions * diff --git a/libraries/plugins/export/ExportXml.class.php b/libraries/plugins/export/ExportXml.class.php index 713d86ed15af..84c98b3be287 100644 --- a/libraries/plugins/export/ExportXml.class.php +++ b/libraries/plugins/export/ExportXml.class.php @@ -102,6 +102,10 @@ protected function setProperties() $structure->setText(__('Object creation options (all are recommended)')); // create primary items and add them to the group if (! PMA_DRIZZLE) { + $leaf = new BoolPropertyItem(); + $leaf->setName("export_events"); + $leaf->setText(__('Events')); + $structure->addProperty($leaf); $leaf = new BoolPropertyItem(); $leaf->setName("export_functions"); $leaf->setText(__('Functions')); @@ -355,6 +359,37 @@ public function exportHeader () } } + if (isset($GLOBALS['xml_export_events']) + && $GLOBALS['xml_export_events'] + ) { + if (PMA_MYSQL_INT_VERSION > 50100) { + // Export events + $events = $GLOBALS['dbi']->fetchResult( + "SELECT EVENT_NAME FROM information_schema.EVENTS " + . "WHERE EVENT_SCHEMA='" . PMA_Util::sqlAddslashes($db) . "'" + ); + if ($events) { + foreach ($events as $event) { + $head .= ' ' . $crlf; + + $sql = $GLOBALS['dbi']->getDefinition( + $db, 'EVENT', $event + ); + $sql = rtrim($sql); + $sql = " " . htmlspecialchars($sql); + $sql = str_replace("\n", "\n ", $sql); + + $head .= $sql . $crlf; + $head .= ' ' . $crlf; + } + + unset($event); + unset($events); + } + } + } + unset($result); $head .= ' ' . $crlf;