Skip to content

Commit

Permalink
Port 'bug #3120 Events are not exported when using xml' to QA_4_2
Browse files Browse the repository at this point in the history
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
  • Loading branch information
madhuracj committed Oct 7, 2014
1 parent a82cb7a commit e93e128
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions export.php
Expand Up @@ -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',
Expand Down
7 changes: 7 additions & 0 deletions libraries/config.default.php
Expand Up @@ -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
*
Expand Down
35 changes: 35 additions & 0 deletions libraries/plugins/export/ExportXml.class.php
Expand Up @@ -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'));
Expand Down Expand Up @@ -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 .= ' <pma:event name="'
. $event . '">' . $crlf;

$sql = $GLOBALS['dbi']->getDefinition(
$db, 'EVENT', $event
);
$sql = rtrim($sql);
$sql = " " . htmlspecialchars($sql);
$sql = str_replace("\n", "\n ", $sql);

$head .= $sql . $crlf;
$head .= ' </pma:event>' . $crlf;
}

unset($event);
unset($events);
}
}
}

unset($result);

$head .= ' </pma:database>' . $crlf;
Expand Down

0 comments on commit e93e128

Please sign in to comment.