bug #1814733 win: copy db to mixed name db fails
make use of PMA_Message do not just exit (blank white page) in case of error when copying/moving tables
This commit is contained in:
@@ -30,6 +30,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
|
|||||||
- bug #1811519 Can't delete user with a german umlaut.
|
- bug #1811519 Can't delete user with a german umlaut.
|
||||||
- bug #1811519 [privileges] fixed used collation for accessing mysql.user in server privileges
|
- bug #1811519 [privileges] fixed used collation for accessing mysql.user in server privileges
|
||||||
- it should not be possible to move or copy a table to information_schema
|
- it should not be possible to move or copy a table to information_schema
|
||||||
|
- bug #1814733 win: copy db to mixed name db fails
|
||||||
|
|
||||||
2.11.1.2 (not yet released)
|
2.11.1.2 (not yet released)
|
||||||
- fixed XSS in server_status.php, thanks to Omer Singer, The DigiTrust Group
|
- fixed XSS in server_status.php, thanks to Omer Singer, The DigiTrust Group
|
||||||
|
@@ -30,13 +30,11 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
|
|||||||
$move = false;
|
$move = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$_msg_type = 'success';
|
|
||||||
|
|
||||||
if (!isset($newname) || !strlen($newname)) {
|
if (!isset($newname) || !strlen($newname)) {
|
||||||
$_message = $strDatabaseEmpty;
|
$message = PMA_Message::error('strDatabaseEmpty');
|
||||||
$_msg_type = 'error';
|
|
||||||
} else {
|
} else {
|
||||||
$sql_query = ''; // in case target db exists
|
$sql_query = ''; // in case target db exists
|
||||||
|
$_error = false;
|
||||||
if ($move ||
|
if ($move ||
|
||||||
(isset($create_database_before_copying) && $create_database_before_copying)) {
|
(isset($create_database_before_copying) && $create_database_before_copying)) {
|
||||||
/**
|
/**
|
||||||
@@ -52,6 +50,13 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
|
|||||||
// PMA_DBI_query($local_query);
|
// PMA_DBI_query($local_query);
|
||||||
//} else {
|
//} else {
|
||||||
// please indent ->
|
// please indent ->
|
||||||
|
|
||||||
|
// lower_case_table_names=1 `DB` becomes `db`
|
||||||
|
$lower_case_table_names = PMA_DBI_fetch_value('SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1);
|
||||||
|
if ($lower_case_table_names === '1') {
|
||||||
|
$newname = strtolower($newname);
|
||||||
|
}
|
||||||
|
|
||||||
$local_query = 'CREATE DATABASE ' . PMA_backquote($newname);
|
$local_query = 'CREATE DATABASE ' . PMA_backquote($newname);
|
||||||
if (isset($db_collation)) {
|
if (isset($db_collation)) {
|
||||||
$local_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
|
$local_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
|
||||||
@@ -59,6 +64,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
|
|||||||
$local_query .= ';';
|
$local_query .= ';';
|
||||||
$sql_query = $local_query;
|
$sql_query = $local_query;
|
||||||
PMA_DBI_query($local_query);
|
PMA_DBI_query($local_query);
|
||||||
|
|
||||||
// rebuild the database list because PMA_Table::moveCopy
|
// rebuild the database list because PMA_Table::moveCopy
|
||||||
// checks in this list if the target db exists
|
// checks in this list if the target db exists
|
||||||
$GLOBALS['PMA_List_Database']->build();
|
$GLOBALS['PMA_List_Database']->build();
|
||||||
@@ -100,8 +106,14 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this_what != 'nocopy') {
|
if ($this_what != 'nocopy') {
|
||||||
PMA_Table::moveCopy($db, $each_table, $newname, $each_table,
|
if (! PMA_Table::moveCopy($db, $each_table, $newname, $each_table,
|
||||||
isset($this_what) ? $this_what : 'data', $move, 'db_copy');
|
isset($this_what) ? $this_what : 'data', $move, 'db_copy'))
|
||||||
|
{
|
||||||
|
$_error = true;
|
||||||
|
// $sql_query is filled by PMA_Table::moveCopy()
|
||||||
|
$sql_query = $back . $sql_query;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (isset($GLOBALS['add_constraints'])) {
|
if (isset($GLOBALS['add_constraints'])) {
|
||||||
$GLOBALS['sql_constraints_query_full_db'] .= $GLOBALS['sql_constraints_query'];
|
$GLOBALS['sql_constraints_query_full_db'] .= $GLOBALS['sql_constraints_query'];
|
||||||
unset($GLOBALS['sql_constraints_query']);
|
unset($GLOBALS['sql_constraints_query']);
|
||||||
@@ -113,14 +125,19 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
|
|||||||
unset($each_table);
|
unset($each_table);
|
||||||
|
|
||||||
// handle the views
|
// handle the views
|
||||||
foreach ($views as $view) {
|
if (! $_error) {
|
||||||
PMA_Table::moveCopy($db, $view, $newname, $view,
|
foreach ($views as $view) {
|
||||||
'structure', $move, 'db_copy');
|
if (! PMA_Table::moveCopy($db, $view, $newname, $view,
|
||||||
|
'structure', $move, 'db_copy')) {
|
||||||
|
$_error = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unset($view, $views);
|
unset($view, $views);
|
||||||
|
|
||||||
// now that all tables exist, create all the accumulated constraints
|
// now that all tables exist, create all the accumulated constraints
|
||||||
if (isset($GLOBALS['add_constraints'])) {
|
if (! $_error && isset($GLOBALS['add_constraints'])) {
|
||||||
/**
|
/**
|
||||||
* @todo this works with mysqli but not with mysql, because
|
* @todo this works with mysqli but not with mysql, because
|
||||||
* mysql extension does not accept more than one statement; maybe
|
* mysql extension does not accept more than one statement; maybe
|
||||||
@@ -136,7 +153,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
|
|||||||
// } // end else MySQL < 50107
|
// } // end else MySQL < 50107
|
||||||
|
|
||||||
// Duplicate the bookmarks for this db (done once for each db)
|
// Duplicate the bookmarks for this db (done once for each db)
|
||||||
if ($db != $newname) {
|
if (! $_error && $db != $newname) {
|
||||||
$get_fields = array('user', 'label', 'query');
|
$get_fields = array('user', 'label', 'query');
|
||||||
$where_fields = array('dbase' => $db);
|
$where_fields = array('dbase' => $db);
|
||||||
$new_fields = array('dbase' => $newname);
|
$new_fields = array('dbase' => $newname);
|
||||||
@@ -144,7 +161,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
|
|||||||
$where_fields, $new_fields);
|
$where_fields, $new_fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($move) {
|
if (! $_error && $move) {
|
||||||
// cleanup pmadb stuff for this db
|
// cleanup pmadb stuff for this db
|
||||||
require_once './libraries/relation_cleanup.lib.php';
|
require_once './libraries/relation_cleanup.lib.php';
|
||||||
PMA_relationsCleanupDatabase($db);
|
PMA_relationsCleanupDatabase($db);
|
||||||
@@ -154,25 +171,31 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
|
|||||||
$sql_query .= "\n" . $local_query;
|
$sql_query .= "\n" . $local_query;
|
||||||
PMA_DBI_query($local_query);
|
PMA_DBI_query($local_query);
|
||||||
}
|
}
|
||||||
$_message = sprintf($strRenameDatabaseOK, htmlspecialchars($db),
|
$message = PMA_Message::success('strRenameDatabaseOK');
|
||||||
htmlspecialchars($newname));
|
$message->addParam($db);
|
||||||
} else {
|
$message->addParam($newname);
|
||||||
$_message = sprintf($strCopyDatabaseOK, htmlspecialchars($db),
|
} elseif (! $_error) {
|
||||||
htmlspecialchars($newname));
|
$message = PMA_Message::success('strCopyDatabaseOK');
|
||||||
|
$message->addParam($db);
|
||||||
|
$message->addParam($newname);
|
||||||
}
|
}
|
||||||
$reload = true;
|
$reload = true;
|
||||||
|
|
||||||
/* Change database to be used */
|
/* Change database to be used */
|
||||||
if ($move) {
|
if (! $_error && $move) {
|
||||||
$db = $newname;
|
$db = $newname;
|
||||||
} else {
|
} elseif (! $_error) {
|
||||||
if (isset($switch_to_new) && $switch_to_new == 'true') {
|
if (isset($switch_to_new) && $switch_to_new == 'true') {
|
||||||
PMA_setCookie('pma_switch_to_new', 'true');
|
PMA_setCookie('pma_switch_to_new', 'true');
|
||||||
$db = $newname;
|
$db = $newname;
|
||||||
} else {
|
} else {
|
||||||
PMA_setCookie('pma_switch_to_new', '');
|
PMA_setCookie('pma_switch_to_new', '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_error && ! isset($message)) {
|
||||||
|
$message = PMA_Message::error();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -203,9 +226,9 @@ if (empty($is_info)) {
|
|||||||
require './libraries/db_info.inc.php';
|
require './libraries/db_info.inc.php';
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
if (isset($_message)) {
|
if (isset($message)) {
|
||||||
PMA_showMessage($_message, $sql_query, $_msg_type);
|
PMA_showMessage($message, $sql_query);
|
||||||
unset($_message, $_msg_type);
|
unset($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -546,10 +546,15 @@ class PMA_Table {
|
|||||||
|
|
||||||
// Ensure the target is valid
|
// Ensure the target is valid
|
||||||
if (! $GLOBALS['PMA_List_Database']->exists($source_db, $target_db)) {
|
if (! $GLOBALS['PMA_List_Database']->exists($source_db, $target_db)) {
|
||||||
/**
|
if (! $GLOBALS['PMA_List_Database']->exists($source_db)) {
|
||||||
* @todo exit really needed here? or just a return?
|
$GLOBALS['message'] = PMA_Message::rawError('source database `'
|
||||||
*/
|
. htmlspecialchars($source_db) . '` not found');
|
||||||
exit;
|
}
|
||||||
|
if (! $GLOBALS['PMA_List_Database']->exists($target_db)) {
|
||||||
|
$GLOBALS['message'] = PMA_Message::rawError('target database `'
|
||||||
|
. htmlspecialchars($target_db) . '` not found');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$source = PMA_backquote($source_db) . '.' . PMA_backquote($source_table);
|
$source = PMA_backquote($source_db) . '.' . PMA_backquote($source_table);
|
||||||
@@ -882,7 +887,7 @@ class PMA_Table {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user