Extract checkWhetherDatabasesExist()
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
bf09fd4f55
commit
cdaaf02fb0
@ -14250,6 +14250,11 @@ parameters:
|
||||
count: 2
|
||||
path: src/Table/TableMover.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$query of method PhpMyAdmin\\\\DatabaseInterface\\:\\:query\\(\\) expects string, mixed given\\.$#"
|
||||
count: 1
|
||||
path: src/Table/TableMover.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:quoteString\\(\\) expects string, string\\|null given\\.$#"
|
||||
count: 6
|
||||
|
||||
@ -60,33 +60,16 @@ class TableMover
|
||||
}
|
||||
}
|
||||
|
||||
// Setting required export settings.
|
||||
$GLOBALS['asfile'] = 1;
|
||||
|
||||
// Ensuring the target database is valid.
|
||||
$databaseList = $dbi->getDatabaseList();
|
||||
if (! $databaseList->exists($sourceDb, $targetDb)) {
|
||||
if (! $databaseList->exists($sourceDb)) {
|
||||
$GLOBALS['message'] = Message::rawError(
|
||||
sprintf(
|
||||
__('Source database `%s` was not found!'),
|
||||
htmlspecialchars($sourceDb),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (! $databaseList->exists($targetDb)) {
|
||||
$GLOBALS['message'] = Message::rawError(
|
||||
sprintf(
|
||||
__('Target database `%s` was not found!'),
|
||||
htmlspecialchars($targetDb),
|
||||
),
|
||||
);
|
||||
}
|
||||
$missingDatabaseMessage = self::checkWhetherDatabasesExist($dbi, $sourceDb, $targetDb);
|
||||
if ($missingDatabaseMessage !== null) {
|
||||
$GLOBALS['message'] = $missingDatabaseMessage;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setting required export settings.
|
||||
$GLOBALS['asfile'] = 1;
|
||||
|
||||
/**
|
||||
* The full name of source table, quoted.
|
||||
*/
|
||||
@ -526,4 +509,32 @@ class TableMover
|
||||
// Building back the query.
|
||||
return $statement->build() . ';';
|
||||
}
|
||||
|
||||
private static function checkWhetherDatabasesExist(
|
||||
DatabaseInterface $dbi,
|
||||
string $sourceDb,
|
||||
string $targetDb,
|
||||
): Message|null {
|
||||
$databaseList = $dbi->getDatabaseList();
|
||||
|
||||
if (! $databaseList->exists($sourceDb)) {
|
||||
return Message::rawError(
|
||||
sprintf(
|
||||
__('Source database `%s` was not found!'),
|
||||
htmlspecialchars($sourceDb),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (! $databaseList->exists($targetDb)) {
|
||||
return Message::rawError(
|
||||
sprintf(
|
||||
__('Target database `%s` was not found!'),
|
||||
htmlspecialchars($targetDb),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user