Merge pull request #1304 from D-storm/scrutinizer

clarify variable origin (db_operations.php)
This commit is contained in:
Marc Delisle 2014-07-27 18:36:08 -04:00
commit ba8a6326ce

View File

@ -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('<div id="boxContainer" data-box-width="300">');
@ -214,7 +215,7 @@ if (!$is_information_schema) {
/**
* database comment
*/
$response->addHTML(PMA_getHtmlForDatabaseComment($db));
$response->addHTML(PMA_getHtmlForDatabaseComment($GLOBALS['db']));
}
$response->addHTML('<div class="operations_half_width">');
@ -228,8 +229,8 @@ if (!$is_information_schema) {
/**
* rename database
*/
if ($db != 'mysql') {
$response->addHTML(PMA_getHtmlForRenameDatabase($db));
if ($GLOBALS['db'] != 'mysql') {
$response->addHTML(PMA_getHtmlForRenameDatabase($GLOBALS['db']));
}
// Drop link if allowed
@ -238,19 +239,19 @@ if (!$is_information_schema) {
// Don't allow to easily drop mysql database, RFE #1327514.
if (($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase'])
&& ! $db_is_system_schema
&& (PMA_DRIZZLE || $db != 'mysql')
&& (PMA_DRIZZLE || $GLOBALS['db'] != 'mysql')
) {
$response->addHTML(PMA_getHtmlForDropDatabaseLink($db));
$response->addHTML(PMA_getHtmlForDropDatabaseLink($GLOBALS['db']));
}
/**
* Copy database
*/
$response->addHTML(PMA_getHtmlForCopyDatabase($db));
$response->addHTML(PMA_getHtmlForCopyDatabase($GLOBALS['db']));
/**
* Change database charset
*/
$response->addHTML(PMA_getHtmlForChangeDatabaseCharset($db, $table));
$response->addHTML(PMA_getHtmlForChangeDatabaseCharset($GLOBALS['db'], $table));
if ($num_tables > 0
&& ! $cfgRelation['allworks']
@ -284,7 +285,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) {
SELECT *
FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote($cfgRelation['pdf_pages']) . '
WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\'';
WHERE db_name = \'' . PMA_Util::sqlAddSlashes($GLOBALS['db']) . '\'';
$test_rs = PMA_queryAsControlUser(
$test_query,
false,