From a1e376c45b755232f11f69834ed978f4e64875f0 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Tue, 10 Mar 2015 12:09:40 +0530 Subject: [PATCH] bug #4789 Views aren't dropped when copying a database Signed-off-by: Madhura Jayaratne --- ChangeLog | 1 + libraries/operations.lib.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index 63f974e1f5..d75d1501c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ phpMyAdmin - ChangeLog - bug #4790 DROP TABLE/VIEW IF EXISTS are not tracked - bug Compatibility with central columns of version 4.4 - bug #4758 Firefox with auth_type to http with multiple server doesn't work anymore +- bug #4789 Views aren't dropped when copying a database 4.3.11.1 (2015-03-04) - bug [security] Risk of BREACH attack, see PMASA-2015-1 diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php index 807bdd3aa4..bcefc85a85 100644 --- a/libraries/operations.lib.php +++ b/libraries/operations.lib.php @@ -397,6 +397,20 @@ function PMA_getViewsAndCreateSqlViewStandIn( // first all the views are collected and a stand-in is created // the real views are created after the tables if (PMA_Table::isView($db, $each_table)) { + + // If view exists, and 'add drop view' is selected: Drop it! + if ($_REQUEST['what'] != 'nocopy' + && isset($_REQUEST['drop_if_exists']) + && $_REQUEST['drop_if_exists'] == 'true' + ) { + $drop_query = 'DROP VIEW IF EXISTS ' + . PMA_Util::backquote($_REQUEST['newname']) . '.' + . PMA_Util::backquote($each_table); + $GLOBALS['dbi']->query($drop_query); + + $GLOBALS['sql_query'] .= "\n" . $drop_query . ';'; + } + $views[] = $each_table; // Create stand-in definition to resolve view dependencies $sql_view_standin = $export_sql_plugin->getTableDefStandIn(