From 69b73a44b098580aa2d077fba08968bee0d06b6c Mon Sep 17 00:00:00 2001 From: ayushchd Date: Mon, 25 Feb 2013 14:28:27 +0530 Subject: [PATCH] Bug fix #3818 After "Rename table ... to ..." left menu doesn't reflect changes The left navigationa and the other places where the old table name was showing up, now updates if the table is renamed. --- import.php | 6 ++++++ js/sql.js | 8 ++++++++ sql.php | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/import.php b/import.php index 75b4f36f40..cf190b2725 100644 --- a/import.php +++ b/import.php @@ -66,6 +66,12 @@ if (! empty($sql_query)) { $GLOBALS['reload'] = true; } + //do a dynamic reload if table is RENAMED (by sending the instruction to the AJAX response handler) + if (preg_match('/^RENAME\s+TABLE\s+(.*?)\s+TO\s+(.*?)($|;|\s)/i', $sql_query, $rename_table_names)) { + $ajax_reload_nav['table_name'] = $rename_table_names[2]; + $ajax_reload_nav['reload'] = true; + } + $sql_query = ''; } elseif (! empty($sql_localfile)) { // run SQL file on server diff --git a/js/sql.js b/js/sql.js index b1e5208659..3f91d04f9c 100644 --- a/js/sql.js +++ b/js/sql.js @@ -280,6 +280,14 @@ AJAX.registerOnload('sql.js', function() { .show() .html(data.message); } + + if (typeof data.ajax_reload_nav != 'undefined') { + if (data.ajax_reload_nav.reload) { + PMA_commonParams.set('table', data.ajax_reload_nav.table_name); + PMA_commonActions.refreshMain(); + } + } + $sqlqueryresults.show().trigger('makegrid'); $('#togglequerybox').show(); PMA_init_slider(); diff --git a/sql.php b/sql.php index 36ed636458..b15c80ce38 100644 --- a/sql.php +++ b/sql.php @@ -27,6 +27,13 @@ $scripts->addFile('tbl_structure.js'); $scripts->addFile('indexes.js'); $scripts->addFile('gis_data_editor.js'); +/** + * Set ajax_reload_nav in the response if it was already set + */ +if (isset($ajax_reload_nav) && $ajax_reload_nav['reload'] === true) { + $response->addJSON('ajax_reload_nav', $ajax_reload_nav); +} + /** * Sets globals from $_POST */