Remove dbi global from Controllers
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
83f433695b
commit
dce862d41b
@ -735,7 +735,7 @@ class DatabaseStructureController extends DatabaseController
|
||||
'num_favorite_tables' => $GLOBALS['cfg']['NumFavoriteTables'],
|
||||
'db' => $GLOBALS['db'],
|
||||
'properties_num_columns' => $GLOBALS['cfg']['PropertiesNumColumns'],
|
||||
'dbi' => $GLOBALS['dbi'],
|
||||
'dbi' => $this->dbi,
|
||||
'show_charset' => $GLOBALS['cfg']['ShowDbStructureCharset'],
|
||||
'show_comment' => $GLOBALS['cfg']['ShowDbStructureComment'],
|
||||
'show_creation' => $GLOBALS['cfg']['ShowDbStructureCreation'],
|
||||
|
||||
@ -27,9 +27,8 @@ class ServerCollationsController extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function indexAction()
|
||||
public function indexAction(): void
|
||||
{
|
||||
$dbi = $GLOBALS['dbi'];
|
||||
$disableIs = $GLOBALS['cfg']['Server']['DisableIS'];
|
||||
|
||||
/**
|
||||
@ -44,10 +43,10 @@ class ServerCollationsController extends Controller
|
||||
);
|
||||
$this->response->addHTML(
|
||||
$this->_getHtmlForCharsets(
|
||||
Charsets::getMySQLCharsets($dbi, $disableIs),
|
||||
Charsets::getMySQLCollations($dbi, $disableIs),
|
||||
Charsets::getMySQLCharsetsDescriptions($dbi, $disableIs),
|
||||
Charsets::getMySQLCollationsDefault($dbi, $disableIs)
|
||||
Charsets::getMySQLCharsets($this->dbi, $disableIs),
|
||||
Charsets::getMySQLCollations($this->dbi, $disableIs),
|
||||
Charsets::getMySQLCharsetsDescriptions($this->dbi, $disableIs),
|
||||
Charsets::getMySQLCollationsDefault($this->dbi, $disableIs)
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -62,9 +61,12 @@ class ServerCollationsController extends Controller
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function _getHtmlForCharsets(array $mysqlCharsets, array $mysqlCollations,
|
||||
array $mysqlCharsetsDesc, array $mysqlDftCollations
|
||||
) {
|
||||
function _getHtmlForCharsets(
|
||||
array $mysqlCharsets,
|
||||
array $mysqlCollations,
|
||||
array $mysqlCharsetsDesc,
|
||||
array $mysqlDftCollations
|
||||
): string {
|
||||
return Template::get('server/collations/charsets')->render(
|
||||
array(
|
||||
'mysql_charsets' => $mysqlCharsets,
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
/**
|
||||
* Holds the PhpMyAdmin\Controllers\Server\ServerDatabasesController
|
||||
*
|
||||
@ -15,7 +14,6 @@ use PhpMyAdmin\Charsets;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Server\Common;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
@ -65,7 +63,7 @@ class ServerDatabasesController extends Controller
|
||||
|
||||
if (isset($_REQUEST['drop_selected_dbs'])
|
||||
&& $response->isAjax()
|
||||
&& ($GLOBALS['dbi']->isSuperuser() || $GLOBALS['cfg']['AllowUserDropDatabase'])
|
||||
&& ($this->dbi->isSuperuser() || $GLOBALS['cfg']['AllowUserDropDatabase'])
|
||||
) {
|
||||
$this->dropDatabasesAction();
|
||||
return;
|
||||
@ -112,9 +110,9 @@ class ServerDatabasesController extends Controller
|
||||
'is_create_db_priv' => $GLOBALS['is_create_db_priv'],
|
||||
'dbstats' => $this->_dbstats,
|
||||
'db_to_create' => $GLOBALS['db_to_create'],
|
||||
'server_collation' => $GLOBALS['dbi']->getServerCollation(),
|
||||
'server_collation' => $this->dbi->getServerCollation(),
|
||||
'databases' => isset($databases) ? $databases : null,
|
||||
'dbi' => $GLOBALS['dbi'],
|
||||
'dbi' => $this->dbi,
|
||||
'disable_is' => $GLOBALS['cfg']['Server']['DisableIS'],
|
||||
]));
|
||||
}
|
||||
@ -133,11 +131,11 @@ class ServerDatabasesController extends Controller
|
||||
if (! empty($_POST['db_collation'])) {
|
||||
list($db_charset) = explode('_', $_POST['db_collation']);
|
||||
$charsets = Charsets::getMySQLCharsets(
|
||||
$GLOBALS['dbi'],
|
||||
$this->dbi,
|
||||
$GLOBALS['cfg']['Server']['DisableIS']
|
||||
);
|
||||
$collations = Charsets::getMySQLCollations(
|
||||
$GLOBALS['dbi'],
|
||||
$this->dbi,
|
||||
$GLOBALS['cfg']['Server']['DisableIS']
|
||||
);
|
||||
if (in_array($db_charset, $charsets)
|
||||
@ -149,13 +147,13 @@ class ServerDatabasesController extends Controller
|
||||
}
|
||||
$sql_query .= ';';
|
||||
|
||||
$result = $GLOBALS['dbi']->tryQuery($sql_query);
|
||||
$result = $this->dbi->tryQuery($sql_query);
|
||||
|
||||
if (! $result) {
|
||||
// avoid displaying the not-created db name in header or navi panel
|
||||
$GLOBALS['db'] = '';
|
||||
|
||||
$message = Message::rawError($GLOBALS['dbi']->getError());
|
||||
$message = Message::rawError($this->dbi->getError());
|
||||
$this->response->setRequestStatus(false);
|
||||
$this->response->addJSON('message', $message);
|
||||
} else {
|
||||
@ -293,7 +291,7 @@ class ServerDatabasesController extends Controller
|
||||
'first_database' => $first_database,
|
||||
'master_replication' => $GLOBALS['replication_info']['master']['status'],
|
||||
'slave_replication' => $GLOBALS['replication_info']['slave']['status'],
|
||||
'is_superuser' => $GLOBALS['dbi']->isSuperuser(),
|
||||
'is_superuser' => $this->dbi->isSuperuser(),
|
||||
'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'],
|
||||
]);
|
||||
|
||||
@ -305,7 +303,7 @@ class ServerDatabasesController extends Controller
|
||||
'master_replication' => $GLOBALS['replication_info']['master']['status'],
|
||||
'slave_replication' => $GLOBALS['replication_info']['slave']['status'],
|
||||
'database_count' => $this->_database_count,
|
||||
'is_superuser' => $GLOBALS['dbi']->isSuperuser(),
|
||||
'is_superuser' => $this->dbi->isSuperuser(),
|
||||
'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'],
|
||||
'pma_theme_image' => $GLOBALS['pmaThemeImage'],
|
||||
'text_dir' => $GLOBALS['text_dir'],
|
||||
@ -456,9 +454,9 @@ class ServerDatabasesController extends Controller
|
||||
'master_replication' => $master_replication,
|
||||
'slave_replication_status' => $GLOBALS['replication_info']['slave']['status'],
|
||||
'slave_replication' => $slave_replication,
|
||||
'is_superuser' => $GLOBALS['dbi']->isSuperuser(),
|
||||
'is_superuser' => $this->dbi->isSuperuser(),
|
||||
'allow_user_drop_database' => $GLOBALS['cfg']['AllowUserDropDatabase'],
|
||||
'is_system_schema' => $GLOBALS['dbi']->isSystemSchema($current['SCHEMA_NAME'], true),
|
||||
'is_system_schema' => $this->dbi->isSystemSchema($current['SCHEMA_NAME'], true),
|
||||
'default_tab_database' => $GLOBALS['cfg']['DefaultTabDatabase'],
|
||||
]);
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ class ServerVariablesController extends Controller
|
||||
// when server is running in ANSI_QUOTES sql_mode
|
||||
$varValue = $this->dbi->fetchSingleRow(
|
||||
'SHOW GLOBAL VARIABLES WHERE Variable_name=\''
|
||||
. $GLOBALS['dbi']->escapeString($_REQUEST['varName']) . '\';',
|
||||
. $this->dbi->escapeString($_REQUEST['varName']) . '\';',
|
||||
'NUM'
|
||||
);
|
||||
|
||||
@ -196,7 +196,7 @@ class ServerVariablesController extends Controller
|
||||
$exp[mb_strtolower($matches[3])]
|
||||
);
|
||||
} else {
|
||||
$value = $GLOBALS['dbi']->escapeString($value);
|
||||
$value = $this->dbi->escapeString($value);
|
||||
}
|
||||
|
||||
if (! is_numeric($value)) {
|
||||
@ -211,7 +211,7 @@ class ServerVariablesController extends Controller
|
||||
// Some values are rounded down etc.
|
||||
$varValue = $this->dbi->fetchSingleRow(
|
||||
'SHOW GLOBAL VARIABLES WHERE Variable_name="'
|
||||
. $GLOBALS['dbi']->escapeString($_REQUEST['varName'])
|
||||
. $this->dbi->escapeString($_REQUEST['varName'])
|
||||
. '";', 'NUM'
|
||||
);
|
||||
list($formattedValue, $isHtmlFormatted) = $this->_formatVariable(
|
||||
|
||||
@ -126,7 +126,7 @@ class TableChartController extends TableController
|
||||
);
|
||||
$url_params['back'] = 'tbl_sql.php';
|
||||
include 'libraries/tbl_common.inc.php';
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
$this->dbi->selectDb($GLOBALS['db']);
|
||||
} elseif (strlen($this->db) > 0) {
|
||||
$url_params['goto'] = Util::getScriptNameForOption(
|
||||
$this->cfg['DefaultTabDatabase'], 'database'
|
||||
|
||||
@ -71,7 +71,7 @@ class TableIndexesController extends TableController
|
||||
*/
|
||||
public function displayFormAction()
|
||||
{
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
$this->dbi->selectDb($GLOBALS['db']);
|
||||
$add_fields = 0;
|
||||
if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) {
|
||||
// coming already from form
|
||||
|
||||
@ -210,7 +210,7 @@ class TableRelationController extends TableController
|
||||
'save_row' => array_values($columns),
|
||||
'url_params' => $GLOBALS['url_params'],
|
||||
'databases' => $GLOBALS['dblist']->databases,
|
||||
'dbi' => $GLOBALS['dbi'],
|
||||
'dbi' => $this->dbi,
|
||||
])
|
||||
);
|
||||
|
||||
|
||||
@ -532,7 +532,7 @@ class TableSearchController extends TableController
|
||||
'data_label' => $dataLabel,
|
||||
'criteria_column_names' => isset($_POST['criteriaColumnNames']) ? $_POST['criteriaColumnNames'] : null,
|
||||
'criteria_column_types' => isset($_POST['criteriaColumnTypes']) ? $_POST['criteriaColumnTypes'] : null,
|
||||
'sql_types' => $GLOBALS['dbi']->types,
|
||||
'sql_types' => $this->dbi->types,
|
||||
'max_rows' => intval($GLOBALS['cfg']['MaxRows']),
|
||||
'max_plot_limit' => ((! empty($_POST['maxPlotLimit']))
|
||||
? intval($_POST['maxPlotLimit'])
|
||||
@ -668,7 +668,7 @@ class TableSearchController extends TableController
|
||||
. " FROM " . Util::backquote($this->db)
|
||||
. "." . Util::backquote($this->table)
|
||||
. " WHERE " . Util::backquote($column)
|
||||
. " RLIKE '" . $GLOBALS['dbi']->escapeString($find) . "' COLLATE "
|
||||
. " RLIKE '" . $this->dbi->escapeString($find) . "' COLLATE "
|
||||
. $charSet . "_bin"; // here we
|
||||
// change the collation of the 2nd operand to a case sensitive
|
||||
// binary collation to make sure that the comparison is case sensitive
|
||||
@ -726,13 +726,13 @@ class TableSearchController extends TableController
|
||||
if (is_array($toReplace)) {
|
||||
foreach ($toReplace as $row) {
|
||||
$sql_query .= "\n WHEN " . Util::backquote($column)
|
||||
. " = '" . $GLOBALS['dbi']->escapeString($row[0])
|
||||
. "' THEN '" . $GLOBALS['dbi']->escapeString($row[1]) . "'";
|
||||
. " = '" . $this->dbi->escapeString($row[0])
|
||||
. "' THEN '" . $this->dbi->escapeString($row[1]) . "'";
|
||||
}
|
||||
}
|
||||
$sql_query .= " END"
|
||||
. " WHERE " . Util::backquote($column)
|
||||
. " RLIKE '" . $GLOBALS['dbi']->escapeString($find) . "' COLLATE "
|
||||
. " RLIKE '" . $this->dbi->escapeString($find) . "' COLLATE "
|
||||
. $charSet . "_bin"; // here we
|
||||
// change the collation of the 2nd operand to a case sensitive
|
||||
// binary collation to make sure that the comparison
|
||||
@ -871,7 +871,7 @@ class TableSearchController extends TableController
|
||||
$type = $this->_columnTypes[$column_index];
|
||||
$collation = $this->_columnCollations[$column_index];
|
||||
//Gets column's comparison operators depending on column type
|
||||
$typeOperators = $GLOBALS['dbi']->types->getTypeOperatorsHtml(
|
||||
$typeOperators = $this->dbi->types->getTypeOperatorsHtml(
|
||||
preg_replace('@\(.*@s', '', $this->_columnTypes[$column_index]),
|
||||
$this->_columnNullFlags[$column_index], $selected_operator
|
||||
);
|
||||
@ -937,7 +937,7 @@ class TableSearchController extends TableController
|
||||
// else continue to form the where clause from column criteria values
|
||||
$fullWhereClause = array();
|
||||
foreach ($_POST['criteriaColumnOperators'] as $column_index => $operator) {
|
||||
$unaryFlag = $GLOBALS['dbi']->types->isUnaryOperator($operator);
|
||||
$unaryFlag = $this->dbi->types->isUnaryOperator($operator);
|
||||
$tmp_geom_func = isset($_POST['geom_func'][$column_index])
|
||||
? $_POST['geom_func'][$column_index] : null;
|
||||
|
||||
@ -990,10 +990,10 @@ class TableSearchController extends TableController
|
||||
$parens_close = '';
|
||||
}
|
||||
$enum_where = '\''
|
||||
. $GLOBALS['dbi']->escapeString($criteriaValues[0]) . '\'';
|
||||
. $this->dbi->escapeString($criteriaValues[0]) . '\'';
|
||||
for ($e = 1; $e < $enum_selected_count; $e++) {
|
||||
$enum_where .= ', \''
|
||||
. $GLOBALS['dbi']->escapeString($criteriaValues[$e]) . '\'';
|
||||
. $this->dbi->escapeString($criteriaValues[$e]) . '\'';
|
||||
}
|
||||
|
||||
return ' ' . $func_type . ' ' . $parens_open
|
||||
@ -1122,7 +1122,7 @@ class TableSearchController extends TableController
|
||||
&& 'NOT BETWEEN' != $func_type
|
||||
) {
|
||||
return $backquoted_name . ' ' . $func_type . ' ' . $quot
|
||||
. $GLOBALS['dbi']->escapeString($criteriaValues) . $quot;
|
||||
. $this->dbi->escapeString($criteriaValues) . $quot;
|
||||
}
|
||||
$func_type = str_replace(' (...)', '', $func_type);
|
||||
|
||||
@ -1141,7 +1141,7 @@ class TableSearchController extends TableController
|
||||
$value = 'NULL';
|
||||
continue;
|
||||
}
|
||||
$value = $quot . $GLOBALS['dbi']->escapeString(trim($value))
|
||||
$value = $quot . $this->dbi->escapeString(trim($value))
|
||||
. $quot;
|
||||
}
|
||||
|
||||
|
||||
@ -1218,7 +1218,7 @@ class TableStructureController extends TableController
|
||||
$mime_map = $this->transformations->getMime($this->db, $this->table, true);
|
||||
}
|
||||
}
|
||||
$centralColumns = new CentralColumns($GLOBALS['dbi']);
|
||||
$centralColumns = new CentralColumns($this->dbi);
|
||||
$central_list = $centralColumns->getFromTable(
|
||||
$this->db,
|
||||
$this->table
|
||||
@ -1253,8 +1253,8 @@ class TableStructureController extends TableController
|
||||
FROM `INFORMATION_SCHEMA`.`VIEWS`
|
||||
WHERE TABLE_SCHEMA='%s'
|
||||
AND TABLE_NAME='%s';",
|
||||
$GLOBALS['dbi']->escapeString($this->db),
|
||||
$GLOBALS['dbi']->escapeString($this->table)
|
||||
$this->dbi->escapeString($this->db),
|
||||
$this->dbi->escapeString($this->table)
|
||||
)
|
||||
);
|
||||
|
||||
@ -1334,7 +1334,7 @@ class TableStructureController extends TableController
|
||||
'relation_commwork' => $GLOBALS['cfgRelation']['commwork'],
|
||||
'relation_mimework' => $GLOBALS['cfgRelation']['mimework'],
|
||||
'central_columns_work' => $GLOBALS['cfgRelation']['centralcolumnswork'],
|
||||
'mysql_int_version' => $GLOBALS['dbi']->getVersion(),
|
||||
'mysql_int_version' => $this->dbi->getVersion(),
|
||||
'pma_theme_image' => $GLOBALS['pmaThemeImage'],
|
||||
'text_dir' => $GLOBALS['text_dir'],
|
||||
'is_active' => Tracker::isActive(),
|
||||
@ -1478,7 +1478,7 @@ class TableStructureController extends TableController
|
||||
*/
|
||||
protected function getDataForSubmitMult($submit_mult, $selected, $action)
|
||||
{
|
||||
$centralColumns = new CentralColumns($GLOBALS['dbi']);
|
||||
$centralColumns = new CentralColumns($this->dbi);
|
||||
$what = null;
|
||||
$query_type = null;
|
||||
$is_unset_submit_mult = false;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user