diff --git a/libraries/classes/Plugins/Import/ImportCsv.php b/libraries/classes/Plugins/Import/ImportCsv.php index 31003c661a..8d0f9e0d02 100644 --- a/libraries/classes/Plugins/Import/ImportCsv.php +++ b/libraries/classes/Plugins/Import/ImportCsv.php @@ -618,7 +618,8 @@ class ImportCsv extends AbstractImportCsv $newDb = 'CSV_DB ' . (count($result) + 1); } - [$db_name, $options] = $this->getDbnameAndOptions($GLOBALS['db'], $newDb); + $db_name = $GLOBALS['db'] !== '' ? $GLOBALS['db'] : $newDb; + $options = $GLOBALS['db'] !== '' ? ['create_db' => false] :null; /* Non-applicable parameters */ $create = null; diff --git a/libraries/classes/Plugins/Import/ImportMediawiki.php b/libraries/classes/Plugins/Import/ImportMediawiki.php index 1a450f79d3..c6431ee4d6 100644 --- a/libraries/classes/Plugins/Import/ImportMediawiki.php +++ b/libraries/classes/Plugins/Import/ImportMediawiki.php @@ -378,10 +378,8 @@ class ImportMediawiki extends ImportPlugin */ private function executeImportTables(array &$tables, array $analyses, array &$sqlStatements): void { - // $db_name : The currently selected database name, if applicable - // No backquotes - // $options : An associative array of options - [$db_name, $options] = $this->getDbnameAndOptions($GLOBALS['db'], 'mediawiki_DB'); + $db_name = $GLOBALS['db'] !== '' ? $GLOBALS['db'] : 'mediawiki_DB'; + $options = $GLOBALS['db'] !== '' ? ['create_db' => false] :null; // Array of SQL strings // Non-applicable parameters diff --git a/libraries/classes/Plugins/Import/ImportOds.php b/libraries/classes/Plugins/Import/ImportOds.php index cfb6c3a219..99bd310406 100644 --- a/libraries/classes/Plugins/Import/ImportOds.php +++ b/libraries/classes/Plugins/Import/ImportOds.php @@ -204,7 +204,8 @@ class ImportOds extends ImportPlugin */ /* Set database name to the currently selected one, if applicable */ - [$db_name, $options] = $this->getDbnameAndOptions($GLOBALS['db'], 'ODS_DB'); + $db_name = $GLOBALS['db'] !== '' ? $GLOBALS['db'] : 'ODS_DB'; + $options = $GLOBALS['db'] !== '' ? ['create_db' => false] :null; /* Non-applicable parameters */ $create = null; diff --git a/libraries/classes/Plugins/Import/ImportShp.php b/libraries/classes/Plugins/Import/ImportShp.php index 7c205b7c4f..98a97d421b 100644 --- a/libraries/classes/Plugins/Import/ImportShp.php +++ b/libraries/classes/Plugins/Import/ImportShp.php @@ -286,13 +286,8 @@ class ImportShp extends ImportPlugin $analyses[$table_no][Import::FORMATTEDSQL][$spatial_col] = true; // Set database name to the currently selected one, if applicable - if (strlen((string) $GLOBALS['db']) > 0) { - $db_name = $GLOBALS['db']; - $options = ['create_db' => false]; - } else { - $db_name = 'SHP_DB'; - $options = null; - } + $db_name = $GLOBALS['db'] !== '' ? $GLOBALS['db'] : 'SHP_DB'; + $options = $GLOBALS['db'] !== '' ? ['create_db' => false] :null; // Created and execute necessary SQL statements from data $null_param = null; diff --git a/libraries/classes/Plugins/ImportPlugin.php b/libraries/classes/Plugins/ImportPlugin.php index c77bdfcf26..64d1e69fa4 100644 --- a/libraries/classes/Plugins/ImportPlugin.php +++ b/libraries/classes/Plugins/ImportPlugin.php @@ -12,8 +12,6 @@ use PhpMyAdmin\Import; use PhpMyAdmin\Properties\Plugins\ImportPluginProperties; use PhpMyAdmin\Properties\Plugins\PluginPropertyItem; -use function strlen; - /** * Provides a common interface that will have to be implemented by all of the * import plugins. @@ -63,30 +61,6 @@ abstract class ImportPlugin implements Plugin */ abstract protected function setProperties(): ImportPluginProperties; - /** - * Define DB name and options - * - * @param string $currentDb DB - * @param string $defaultDb Default DB name - * - * @return array DB name and options (an associative array of options) - */ - protected function getDbnameAndOptions($currentDb, $defaultDb): array - { - $db_name = $defaultDb; - $options = null; - - if (strlen((string) $currentDb) > 0) { - $db_name = $currentDb; - $options = ['create_db' => false]; - } - - return [ - $db_name, - $options, - ]; - } - public static function isAvailable(): bool { return true;