Drop getDbnameAndOptions() method
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
6dba61136a
commit
a9972da998
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user