diff --git a/db_operations.php b/db_operations.php index b80fe3ce44..60f00d0b6b 100644 --- a/db_operations.php +++ b/db_operations.php @@ -32,7 +32,7 @@ $scripts->addFile('db_operations.js'); /** * Rename/move or copy database */ -if (strlen($db) +if (strlen($GLOBALS['db']) && (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_copy'])) ) { if (! empty($_REQUEST['db_rename'])) { @@ -59,12 +59,12 @@ if (strlen($db) // to avoid selecting alternatively the current and new db // we would need to modify the CREATE definitions to qualify // the db name - PMA_runProcedureAndFunctionDefinitions($db); + PMA_runProcedureAndFunctionDefinitions($GLOBALS['db']); // go back to current db, just in case - $GLOBALS['dbi']->selectDb($db); + $GLOBALS['dbi']->selectDb($GLOBALS['db']); - $tables_full = $GLOBALS['dbi']->getTablesFull($db); + $tables_full = $GLOBALS['dbi']->getTablesFull($GLOBALS['db']); include_once "libraries/plugin_interface.lib.php"; // remove all foreign key constraints, otherwise we can get errors @@ -79,20 +79,20 @@ if (strlen($db) ); $GLOBALS['sql_constraints_query_full_db'] = PMA_getSqlConstraintsQueryForFullDb( - $tables_full, $export_sql_plugin, $move, $db + $tables_full, $export_sql_plugin, $move, $GLOBALS['db'] ); $views = PMA_getViewsAndCreateSqlViewStandIn( - $tables_full, $export_sql_plugin, $db + $tables_full, $export_sql_plugin, $GLOBALS['db'] ); list($sql_query, $_error) = PMA_getSqlQueryForCopyTable( - $tables_full, $sql_query, $move, $db + $tables_full, $sql_query, $move, $GLOBALS['db'] ); // handle the views if (! $_error) { - $_error = PMA_handleTheViews($views, $move, $db); + $_error = PMA_handleTheViews($views, $move, $GLOBALS['db']); } unset($views); @@ -105,50 +105,51 @@ if (strlen($db) // here DELIMITER is not used because it's not part of the // language; each statement is sent one by one - PMA_runEventDefinitionsForDb($db); + PMA_runEventDefinitionsForDb($GLOBALS['db']); } // go back to current db, just in case - $GLOBALS['dbi']->selectDb($db); + $GLOBALS['dbi']->selectDb($GLOBALS['db']); // Duplicate the bookmarks for this db (done once for each db) - PMA_duplicateBookmarks($_error, $db); + PMA_duplicateBookmarks($_error, $GLOBALS['db']); if (! $_error && $move) { /** * cleanup pmadb stuff for this db */ include_once 'libraries/relation_cleanup.lib.php'; - PMA_relationsCleanupDatabase($db); + PMA_relationsCleanupDatabase($GLOBALS['db']); // if someday the RENAME DATABASE reappears, do not DROP - $local_query = 'DROP DATABASE ' . PMA_Util::backquote($db) . ';'; + $local_query = 'DROP DATABASE ' . PMA_Util::backquote($GLOBALS['db']) + . ';'; $sql_query .= "\n" . $local_query; $GLOBALS['dbi']->query($local_query); $message = PMA_Message::success( __('Database %1$s has been renamed to %2$s.') ); - $message->addParam($db); + $message->addParam($GLOBALS['db']); $message->addParam($_REQUEST['newname']); } elseif (! $_error) { $message = PMA_Message::success( __('Database %1$s has been copied to %2$s.') ); - $message->addParam($db); + $message->addParam($GLOBALS['db']); $message->addParam($_REQUEST['newname']); } $reload = true; /* Change database to be used */ if (! $_error && $move) { - $db = $_REQUEST['newname']; + $GLOBALS['db'] = $_REQUEST['newname']; } elseif (! $_error) { if (isset($_REQUEST['switch_to_new']) && $_REQUEST['switch_to_new'] == 'true' ) { $GLOBALS['PMA_Config']->setCookie('pma_switch_to_new', 'true'); - $db = $_REQUEST['newname']; + $GLOBALS['db'] = $_REQUEST['newname']; } else { $GLOBALS['PMA_Config']->setCookie('pma_switch_to_new', ''); } @@ -172,7 +173,7 @@ if (strlen($db) 'sql_query', PMA_Util::getMessage(null, $sql_query) ); - $response->addJSON('db', $db); + $response->addJSON('db', $GLOBALS['db']); exit; } } @@ -188,7 +189,7 @@ $cfgRelation = PMA_getRelationsParam(); * (must be done before displaying the menu tabs) */ if (isset($_REQUEST['comment'])) { - PMA_setDbComment($db, $_REQUEST['comment']); + PMA_setDbComment($GLOBALS['db'], $_REQUEST['comment']); } require 'libraries/db_common.inc.php'; @@ -204,8 +205,8 @@ if (isset($message)) { unset($message); } -$_REQUEST['db_collation'] = PMA_getDbCollation($db); -$is_information_schema = $GLOBALS['dbi']->isSystemSchema($db); +$_REQUEST['db_collation'] = PMA_getDbCollation($GLOBALS['db']); +$is_information_schema = $GLOBALS['dbi']->isSystemSchema($GLOBALS['db']); $response->addHTML('