Remove $GLOBALS['dbi'] from Relation class

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
Maurício Meneghini Fauth 2018-08-30 19:05:09 -03:00
parent 2ef6c9aec2
commit d4b4124a5e
73 changed files with 214 additions and 184 deletions

View File

@ -36,7 +36,7 @@ $header = $response->getHeader();
$header->disableMenuAndConsole();
$header->setBodyId('body_browse_foreigners');
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
/**
* Displays the frame

View File

@ -12,7 +12,7 @@ use PhpMyAdmin\Response;
require_once 'libraries/common.inc.php';
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
// If request for creating the pmadb
if (isset($_REQUEST['create_pmadb'])) {

View File

@ -36,7 +36,7 @@ $response = Response::getInstance();
$header = $response->getHeader();
$header->enablePrintView();
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$transformations = new Transformations();
/**

View File

@ -216,7 +216,7 @@ if (strlen($GLOBALS['db']) > 0
/**
* Settings for relations stuff
*/
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();

View File

@ -24,7 +24,7 @@ require_once 'libraries/common.inc.php';
$response = Response::getInstance();
// Gets the relation settings
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
$savedSearchList = [];

View File

@ -408,7 +408,7 @@ if ($save_on_server) {
} // end download
}
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
// Fake loop just to allow skip of remain of this code by break, I'd really
// need exceptions here :-)

View File

@ -604,7 +604,7 @@ if (@file_exists('config')) {
);
}
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
if ($server > 0) {
$cfgRelation = $relation->getRelationsParam();

View File

@ -228,7 +228,7 @@ class Bookmark
return $cfgBookmark;
}
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if ($cfgRelation['bookmarkwork']) {
$cfgBookmark = [

View File

@ -83,7 +83,7 @@ class CentralColumns
$this->charEditing = $GLOBALS['cfg']['CharEditing'];
$this->disableIs = (bool) $GLOBALS['cfg']['Server']['DisableIS'];
$this->relation = new Relation();
$this->relation = new Relation($this->dbi);
$this->template = new Template();
}

View File

@ -53,7 +53,7 @@ class Console
public function __construct()
{
$this->_isEnabled = true;
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->template = new Template();
}

View File

@ -78,7 +78,7 @@ class DatabaseStructureController extends DatabaseController
public function __construct($response, $dbi, $db)
{
parent::__construct($response, $dbi, $db);
$this->relation = new Relation();
$this->relation = new Relation($dbi);
$this->replication = new Replication();
}

View File

@ -94,7 +94,7 @@ class TableRelationController extends TableController
$this->existrel = $existrel;
$this->existrel_foreign = $existrel_foreign;
$this->upd_query = $upd_query;
$this->relation = new Relation();
$this->relation = new Relation($dbi);
}
/**

View File

@ -115,7 +115,7 @@ class TableSearchController extends TableController
$this->_columnCollations = [];
$this->_geomColumnFlag = false;
$this->_foreigners = [];
$this->relation = new Relation();
$this->relation = new Relation($dbi);
// Loads table's information
$this->_loadTableInfo();
$this->_connectionCharSet = $this->dbi->fetchValue(

View File

@ -135,7 +135,7 @@ class TableStructureController extends TableController
$this->table_obj = $this->dbi->getTable($this->db, $this->table);
$this->createAddField = new CreateAddField($dbi);
$this->relation = new Relation();
$this->relation = new Relation($dbi);
$this->transformations = new Transformations();
}

View File

@ -47,7 +47,7 @@ class Designer
public function __construct(DatabaseInterface $dbi)
{
$this->dbi = $dbi;
$this->relation = new Relation();
$this->relation = new Relation($this->dbi);
$this->template = new Template();
}

View File

@ -40,7 +40,7 @@ class Common
public function __construct(DatabaseInterface $dbi)
{
$this->dbi = $dbi;
$this->relation = new Relation();
$this->relation = new Relation($this->dbi);
}
/**

View File

@ -248,8 +248,8 @@ class Qbe
$this->_db = $dbname;
$this->_savedSearchList = $savedSearchList;
$this->_currentSearch = $currentSearch;
$this->relation = new Relation();
$this->dbi = $dbi;
$this->relation = new Relation($this->dbi);
$this->template = new Template();
$this->_loadCriterias();

View File

@ -139,7 +139,7 @@ class DatabaseInterface
$this->_table_cache = [];
$this->_current_user = [];
$this->types = new Types($this);
$this->relation = new Relation();
$this->relation = new Relation($this);
}
/**

View File

@ -44,7 +44,7 @@ class Export
*/
public function __construct()
{
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->template = new Template();
}

View File

@ -214,7 +214,7 @@ class Results
*/
public function __construct($db, $table, $goto, $sql_query)
{
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->transformations = new Transformations();
$this->template = new Template();

View File

@ -52,7 +52,7 @@ class ErrorReport
{
$this->httpRequest = $httpRequest;
$this->submissionUrl = 'https://reports.phpmyadmin.net/incidents/create';
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->template = new Template();
}

View File

@ -70,7 +70,7 @@ class Footer
$this->_isEnabled = true;
$this->_scripts = new Scripts();
$this->_isMinimal = false;
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
}
/**

View File

@ -63,7 +63,7 @@ class InsertEdit
public function __construct(DatabaseInterface $dbi)
{
$this->dbi = $dbi;
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->transformations = new Transformations();
$this->fileListing = new FileListing();
$this->template = new Template();

View File

@ -61,7 +61,7 @@ class Menu
$this->_server = $server;
$this->_db = $db;
$this->_table = $table;
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
}
/**

View File

@ -27,14 +27,14 @@ class Navigation
/**
* @var Relation $relation
*/
private $relation;
public $relation;
/**
* Constructor
*/
public function __construct()
{
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
}
/**

View File

@ -127,7 +127,7 @@ class Node
$this->type = Node::CONTAINER;
}
$this->is_group = (bool)$is_group;
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
}
/**

View File

@ -54,7 +54,7 @@ class Normalization
public function __construct(DatabaseInterface $dbi)
{
$this->dbi = $dbi;
$this->relation = new Relation();
$this->relation = new Relation($this->dbi);
$this->transformations = new Transformations();
$this->template = new Template();
}

View File

@ -39,7 +39,7 @@ class Operations
*/
public function __construct()
{
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
}
/**

View File

@ -90,7 +90,7 @@ class Pdf extends PdfLib
$diskcache,
$pdfa
);
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->transformations = new Transformations();
}

View File

@ -35,7 +35,7 @@ abstract class ExportPlugin
/**
* @var Relation $relation
*/
protected $relation;
public $relation;
/**
* @var Export $export
@ -52,7 +52,7 @@ abstract class ExportPlugin
*/
public function __construct()
{
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->export = new Export();
$this->transformations = new Transformations();
}

View File

@ -51,7 +51,7 @@ class ExportRelationSchema
$this->diagram = $diagram;
$this->setPageNumber($_REQUEST['page_number']);
$this->setOffline(isset($_REQUEST['offline_export']));
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
}
/**

View File

@ -86,7 +86,7 @@ class Pdf extends PdfLib
$this->_pageNumber = $pageNumber;
$this->_withDoc = $withDoc;
$this->_db = $db;
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
}
/**

View File

@ -83,7 +83,7 @@ abstract class TableStats
$this->offline = $offline;
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->font = new Font();
// checks whether the table exists

View File

@ -63,7 +63,7 @@ class RecentFavoriteTable
*/
private function __construct($type)
{
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->_tableType = $type;
$server_id = $GLOBALS['server'];
if (! isset($_SESSION['tmpval'][$this->_tableType . '_tables'][$server_id])

View File

@ -27,6 +27,11 @@ use PhpMyAdmin\Util;
*/
class Relation
{
/**
* @var DatabaseInterface
*/
public $dbi;
/**
* @var Template
*/
@ -34,9 +39,12 @@ class Relation
/**
* Relation constructor.
*
* @param DatabaseInterface $dbi Database interface
*/
public function __construct()
public function __construct(DatabaseInterface $dbi)
{
$this->dbi = $dbi;
$this->template = new Template();
}
@ -61,14 +69,14 @@ class Relation
$cache_affected_rows = false;
if ($show_error) {
$result = $GLOBALS['dbi']->query(
$result = $this->dbi->query(
$sql,
DatabaseInterface::CONNECT_CONTROL,
$options,
$cache_affected_rows
);
} else {
$result = @$GLOBALS['dbi']->tryQuery(
$result = @$this->dbi->tryQuery(
$sql,
DatabaseInterface::CONNECT_CONTROL,
$options,
@ -515,7 +523,7 @@ class Relation
if ($GLOBALS['server'] == 0
|| empty($GLOBALS['cfg']['Server']['pmadb'])
|| ! $GLOBALS['dbi']->selectDb(
|| ! $this->dbi->selectDb(
$GLOBALS['cfg']['Server']['pmadb'],
DatabaseInterface::CONNECT_CONTROL
)
@ -551,7 +559,7 @@ class Relation
return $cfgRelation;
}
while ($curr_table = @$GLOBALS['dbi']->fetchRow($tab_rs)) {
while ($curr_table = @$this->dbi->fetchRow($tab_rs)) {
if ($curr_table[0] == $GLOBALS['cfg']['Server']['bookmarktable']) {
$cfgRelation['bookmark'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['relation']) {
@ -592,7 +600,7 @@ class Relation
$cfgRelation['export_templates'] = $curr_table[0];
}
} // end while
$GLOBALS['dbi']->freeResult($tab_rs);
$this->dbi->freeResult($tab_rs);
if (isset($cfgRelation['relation'])) {
$cfgRelation['relwork'] = true;
@ -725,8 +733,8 @@ class Relation
DatabaseInterface::QUERY_STORE
);
if ($result) {
$rows = $GLOBALS['dbi']->numRows($result);
$GLOBALS['dbi']->freeResult($result);
$rows = $this->dbi->numRows($result);
$this->dbi->freeResult($result);
// input transformations are present
// no need to upgrade
if ($rows === 2) {
@ -751,13 +759,13 @@ class Relation
),
$query
);
$GLOBALS['dbi']->tryMultiQuery($query, DatabaseInterface::CONNECT_CONTROL);
$this->dbi->tryMultiQuery($query, DatabaseInterface::CONNECT_CONTROL);
// skips result sets of query as we are not interested in it
while ($GLOBALS['dbi']->moreResults(DatabaseInterface::CONNECT_CONTROL)
&& $GLOBALS['dbi']->nextResult(DatabaseInterface::CONNECT_CONTROL)
while ($this->dbi->moreResults(DatabaseInterface::CONNECT_CONTROL)
&& $this->dbi->nextResult(DatabaseInterface::CONNECT_CONTROL)
) {
}
$error = $GLOBALS['dbi']->getError(DatabaseInterface::CONNECT_CONTROL);
$error = $this->dbi->getError(DatabaseInterface::CONNECT_CONTROL);
// return true if no error exists otherwise false
return empty($error);
}
@ -792,14 +800,14 @@ class Relation
`foreign_field`
FROM ' . Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['relation']) . '
WHERE `master_db` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `master_table` = \'' . $GLOBALS['dbi']->escapeString($table)
WHERE `master_db` = \'' . $this->dbi->escapeString($db) . '\'
AND `master_table` = \'' . $this->dbi->escapeString($table)
. '\' ';
if (strlen($column) > 0) {
$rel_query .= ' AND `master_field` = '
. '\'' . $GLOBALS['dbi']->escapeString($column) . '\'';
. '\'' . $this->dbi->escapeString($column) . '\'';
}
$foreign = $GLOBALS['dbi']->fetchResult(
$foreign = $this->dbi->fetchResult(
$rel_query,
'master_field',
null,
@ -874,11 +882,11 @@ class Relation
SELECT `display_field`
FROM ' . Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['table_info']) . '
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString((string)$db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString((string)$table)
WHERE `db_name` = \'' . $this->dbi->escapeString((string)$db) . '\'
AND `table_name` = \'' . $this->dbi->escapeString((string)$table)
. '\'';
$row = $GLOBALS['dbi']->fetchSingleRow(
$row = $this->dbi->fetchSingleRow(
$disp_query,
'ASSOC',
DatabaseInterface::CONNECT_CONTROL
@ -903,10 +911,10 @@ class Relation
/**
* Pick first char field
*/
$columns = $GLOBALS['dbi']->getColumnsFull($db, $table);
$columns = $this->dbi->getColumnsFull($db, $table);
if ($columns) {
foreach ($columns as $column) {
if ($GLOBALS['dbi']->types->getTypeClass($column['DATA_TYPE']) == 'CHAR') {
if ($this->dbi->types->getTypeClass($column['DATA_TYPE']) == 'CHAR') {
return $column['COLUMN_NAME'];
}
}
@ -930,7 +938,7 @@ class Relation
if ($table != '') {
// MySQL native column comments
$columns = $GLOBALS['dbi']->getColumns($db, $table, null, true);
$columns = $this->dbi->getColumns($db, $table, null, true);
if ($columns) {
foreach ($columns as $column) {
if (! empty($column['Comment'])) {
@ -966,7 +974,7 @@ class Relation
FROM " . Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation['column_info'])
. "
WHERE db_name = '" . $GLOBALS['dbi']->escapeString($db) . "'
WHERE db_name = '" . $this->dbi->escapeString($db) . "'
AND table_name = ''
AND column_name = '(db_comment)'";
$com_rs = $this->queryAsControlUser(
@ -975,11 +983,11 @@ class Relation
DatabaseInterface::QUERY_STORE
);
if ($com_rs && $GLOBALS['dbi']->numRows($com_rs) > 0) {
$row = $GLOBALS['dbi']->fetchAssoc($com_rs);
if ($com_rs && $this->dbi->numRows($com_rs) > 0) {
$row = $this->dbi->fetchAssoc($com_rs);
$comment = $row['comment'];
}
$GLOBALS['dbi']->freeResult($com_rs);
$this->dbi->freeResult($com_rs);
}
return $comment;
@ -1011,12 +1019,12 @@ class Relation
DatabaseInterface::QUERY_STORE
);
if ($com_rs && $GLOBALS['dbi']->numRows($com_rs) > 0) {
while ($row = $GLOBALS['dbi']->fetchAssoc($com_rs)) {
if ($com_rs && $this->dbi->numRows($com_rs) > 0) {
while ($row = $this->dbi->fetchAssoc($com_rs)) {
$comments[$row['db_name']] = $row['comment'];
}
}
$GLOBALS['dbi']->freeResult($com_rs);
$this->dbi->freeResult($com_rs);
}
return $comments;
@ -1046,17 +1054,17 @@ class Relation
. Util::backquote($cfgRelation['column_info'])
. ' (`db_name`, `table_name`, `column_name`, `comment`)'
. ' VALUES (\''
. $GLOBALS['dbi']->escapeString($db)
. $this->dbi->escapeString($db)
. "', '', '(db_comment)', '"
. $GLOBALS['dbi']->escapeString($comment)
. $this->dbi->escapeString($comment)
. "') "
. ' ON DUPLICATE KEY UPDATE '
. "`comment` = '" . $GLOBALS['dbi']->escapeString($comment) . "'";
. "`comment` = '" . $this->dbi->escapeString($comment) . "'";
} else {
$upd_query = 'DELETE FROM '
. Util::backquote($cfgRelation['db']) . '.'
. Util::backquote($cfgRelation['column_info'])
. ' WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db)
. ' WHERE `db_name` = \'' . $this->dbi->escapeString($db)
. '\'
AND `table_name` = \'\'
AND `column_name` = \'(db_comment)\'';
@ -1118,11 +1126,11 @@ class Relation
`timevalue`,
`sqlquery`)
VALUES
(\'' . $GLOBALS['dbi']->escapeString($username) . '\',
\'' . $GLOBALS['dbi']->escapeString($db) . '\',
\'' . $GLOBALS['dbi']->escapeString($table) . '\',
(\'' . $this->dbi->escapeString($username) . '\',
\'' . $this->dbi->escapeString($db) . '\',
\'' . $this->dbi->escapeString($table) . '\',
NOW(),
\'' . $GLOBALS['dbi']->escapeString($sqlquery) . '\')'
\'' . $this->dbi->escapeString($sqlquery) . '\')'
);
$this->purgeHistory($username);
@ -1163,10 +1171,10 @@ class Relation
`timevalue`
FROM ' . Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['history']) . '
WHERE `username` = \'' . $GLOBALS['dbi']->escapeString($username) . '\'
WHERE `username` = \'' . $this->dbi->escapeString($username) . '\'
ORDER BY `id` DESC';
return $GLOBALS['dbi']->fetchResult(
return $this->dbi->fetchResult(
$hist_query,
null,
null,
@ -1201,11 +1209,11 @@ class Relation
SELECT `timevalue`
FROM ' . Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['history']) . '
WHERE `username` = \'' . $GLOBALS['dbi']->escapeString($username) . '\'
WHERE `username` = \'' . $this->dbi->escapeString($username) . '\'
ORDER BY `timevalue` DESC
LIMIT ' . $GLOBALS['cfg']['QueryHistoryMax'] . ', 1';
if ($max_time = $GLOBALS['dbi']->fetchValue(
if ($max_time = $this->dbi->fetchValue(
$search_query,
0,
0,
@ -1215,7 +1223,7 @@ class Relation
'DELETE FROM '
. Util::backquote($cfgRelation['db']) . '.'
. Util::backquote($cfgRelation['history']) . '
WHERE `username` = \'' . $GLOBALS['dbi']->escapeString($username)
WHERE `username` = \'' . $this->dbi->escapeString($username)
. '\'
AND `timevalue` <= \'' . $max_time . '\''
);
@ -1457,7 +1465,7 @@ class Relation
// Check if table has more rows than specified by
// $GLOBALS['cfg']['ForeignKeyMaxLimit']
$moreThanLimit = $GLOBALS['dbi']->getTable($foreign_db, $foreign_table)
$moreThanLimit = $this->dbi->getTable($foreign_db, $foreign_table)
->checkIfMinRecordsExist($GLOBALS['cfg']['ForeignKeyMaxLimit']);
if ($override_total == true
@ -1476,12 +1484,12 @@ class Relation
. '.' . Util::backquote($foreign_table);
$f_query_filter = empty($foreign_filter) ? '' : ' WHERE '
. Util::backquote($foreign_field)
. ' LIKE "%' . $GLOBALS['dbi']->escapeString($foreign_filter) . '%"'
. ' LIKE "%' . $this->dbi->escapeString($foreign_filter) . '%"'
. (
($foreign_display == false)
? ''
: ' OR ' . Util::backquote($foreign_display)
. ' LIKE "%' . $GLOBALS['dbi']->escapeString($foreign_filter)
. ' LIKE "%' . $this->dbi->escapeString($foreign_filter)
. '%"'
);
$f_query_order = ($foreign_display == false) ? '' : ' ORDER BY '
@ -1491,7 +1499,7 @@ class Relation
$f_query_limit = ! empty($foreign_limit) ? ($foreign_limit) : '';
if (!empty($foreign_filter)) {
$the_total = $GLOBALS['dbi']->fetchValue(
$the_total = $this->dbi->fetchValue(
'SELECT COUNT(*)' . $f_query_from . $f_query_filter
);
if ($the_total === false) {
@ -1499,20 +1507,20 @@ class Relation
}
}
$disp = $GLOBALS['dbi']->tryQuery(
$disp = $this->dbi->tryQuery(
$f_query_main . $f_query_from . $f_query_filter
. $f_query_order . $f_query_limit
);
if ($disp && $GLOBALS['dbi']->numRows($disp) > 0) {
if ($disp && $this->dbi->numRows($disp) > 0) {
// If a resultset has been created, pre-cache it in the $disp_row
// array. This helps us from not needing to use mysql_data_seek by
// accessing a pre-cached PHP array. Usually those resultsets are
// not that big, so a performance hit should not be expected.
$disp_row = [];
while ($single_disp_row = @$GLOBALS['dbi']->fetchAssoc($disp)) {
while ($single_disp_row = @$this->dbi->fetchAssoc($disp)) {
$disp_row[] = $single_disp_row;
}
@$GLOBALS['dbi']->freeResult($disp);
@$this->dbi->freeResult($disp);
} else {
// Either no data in the foreign table or
// user does not have select permission to foreign table/field
@ -1527,7 +1535,7 @@ class Relation
} while (false);
if ($get_total) {
$the_total = $GLOBALS['dbi']->getTable($foreign_db, $foreign_table)
$the_total = $this->dbi->getTable($foreign_db, $foreign_table)
->countRecords(true);
}
@ -1563,14 +1571,14 @@ class Relation
$table_query = 'UPDATE '
. Util::backquote($cfgRelation['db']) . '.'
. Util::backquote($cfgRelation['table_info'])
. ' SET display_field = \'' . $GLOBALS['dbi']->escapeString(
. ' SET display_field = \'' . $this->dbi->escapeString(
$new_name
) . '\''
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db)
. ' WHERE db_name = \'' . $this->dbi->escapeString($db)
. '\''
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
. ' AND table_name = \'' . $this->dbi->escapeString($table)
. '\''
. ' AND display_field = \'' . $GLOBALS['dbi']->escapeString($field)
. ' AND display_field = \'' . $this->dbi->escapeString($field)
. '\'';
$this->queryAsControlUser($table_query);
}
@ -1579,28 +1587,28 @@ class Relation
$table_query = 'UPDATE '
. Util::backquote($cfgRelation['db']) . '.'
. Util::backquote($cfgRelation['relation'])
. ' SET master_field = \'' . $GLOBALS['dbi']->escapeString(
. ' SET master_field = \'' . $this->dbi->escapeString(
$new_name
) . '\''
. ' WHERE master_db = \'' . $GLOBALS['dbi']->escapeString($db)
. ' WHERE master_db = \'' . $this->dbi->escapeString($db)
. '\''
. ' AND master_table = \'' . $GLOBALS['dbi']->escapeString($table)
. ' AND master_table = \'' . $this->dbi->escapeString($table)
. '\''
. ' AND master_field = \'' . $GLOBALS['dbi']->escapeString($field)
. ' AND master_field = \'' . $this->dbi->escapeString($field)
. '\'';
$this->queryAsControlUser($table_query);
$table_query = 'UPDATE '
. Util::backquote($cfgRelation['db']) . '.'
. Util::backquote($cfgRelation['relation'])
. ' SET foreign_field = \'' . $GLOBALS['dbi']->escapeString(
. ' SET foreign_field = \'' . $this->dbi->escapeString(
$new_name
) . '\''
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
. ' WHERE foreign_db = \'' . $this->dbi->escapeString($db)
. '\''
. ' AND foreign_table = \'' . $GLOBALS['dbi']->escapeString($table)
. ' AND foreign_table = \'' . $this->dbi->escapeString($table)
. '\''
. ' AND foreign_field = \'' . $GLOBALS['dbi']->escapeString($field)
. ' AND foreign_field = \'' . $this->dbi->escapeString($field)
. '\'';
$this->queryAsControlUser($table_query);
}
@ -1633,14 +1641,14 @@ class Relation
. Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
. Util::backquote($GLOBALS['cfgRelation'][$table])
. ' SET '
. $db_field . ' = \'' . $GLOBALS['dbi']->escapeString($target_db)
. $db_field . ' = \'' . $this->dbi->escapeString($target_db)
. '\', '
. $table_field . ' = \'' . $GLOBALS['dbi']->escapeString($target_table)
. $table_field . ' = \'' . $this->dbi->escapeString($target_table)
. '\''
. ' WHERE '
. $db_field . ' = \'' . $GLOBALS['dbi']->escapeString($source_db) . '\''
. $db_field . ' = \'' . $this->dbi->escapeString($source_db) . '\''
. ' AND '
. $table_field . ' = \'' . $GLOBALS['dbi']->escapeString($source_table)
. $table_field . ' = \'' . $this->dbi->escapeString($source_table)
. '\'';
$this->queryAsControlUser($query);
}
@ -1728,8 +1736,8 @@ class Relation
$remove_query = "DELETE FROM "
. Util::backquote($GLOBALS['cfgRelation']['db']) . "."
. Util::backquote($GLOBALS['cfgRelation']['table_coords'])
. " WHERE db_name = '" . $GLOBALS['dbi']->escapeString($source_db) . "'"
. " AND table_name = '" . $GLOBALS['dbi']->escapeString($source_table)
. " WHERE db_name = '" . $this->dbi->escapeString($source_db) . "'"
. " AND table_name = '" . $this->dbi->escapeString($source_table)
. "'";
$this->queryAsControlUser($remove_query);
}
@ -1765,13 +1773,13 @@ class Relation
. Util::backquote(
$GLOBALS['cfgRelation']['navigationhiding']
)
. " SET db_name = '" . $GLOBALS['dbi']->escapeString($target_db)
. " SET db_name = '" . $this->dbi->escapeString($target_db)
. "',"
. " item_name = '" . $GLOBALS['dbi']->escapeString($target_table)
. " item_name = '" . $this->dbi->escapeString($target_table)
. "'"
. " WHERE db_name = '" . $GLOBALS['dbi']->escapeString($source_db)
. " WHERE db_name = '" . $this->dbi->escapeString($source_db)
. "'"
. " AND item_name = '" . $GLOBALS['dbi']->escapeString($source_table)
. " AND item_name = '" . $this->dbi->escapeString($source_table)
. "'"
. " AND item_type = 'table'";
$this->queryAsControlUser($query);
@ -1797,11 +1805,11 @@ class Relation
. Util::backquote($cfgRelation['pdf_pages'])
. ' (db_name, page_descr)'
. ' VALUES (\''
. $GLOBALS['dbi']->escapeString($db) . '\', \''
. $GLOBALS['dbi']->escapeString($newpage) . '\')';
. $this->dbi->escapeString($db) . '\', \''
. $this->dbi->escapeString($newpage) . '\')';
$this->queryAsControlUser($ins_query, false);
return $GLOBALS['dbi']->insertId(DatabaseInterface::CONNECT_CONTROL);
return $this->dbi->insertId(DatabaseInterface::CONNECT_CONTROL);
}
/**
@ -1822,15 +1830,15 @@ class Relation
. " `table_schema`, `referenced_column_name`"
. " FROM `information_schema`.`key_column_usage`"
. " WHERE `referenced_table_name` = '"
. $GLOBALS['dbi']->escapeString($table) . "'"
. $this->dbi->escapeString($table) . "'"
. " AND `referenced_table_schema` = '"
. $GLOBALS['dbi']->escapeString($db) . "'";
. $this->dbi->escapeString($db) . "'";
if ($column) {
$rel_query .= " AND `referenced_column_name` = '"
. $GLOBALS['dbi']->escapeString($column) . "'";
. $this->dbi->escapeString($column) . "'";
}
$child_references = $GLOBALS['dbi']->fetchResult(
$child_references = $this->dbi->fetchResult(
$rel_query,
['referenced_column_name', null]
);
@ -1982,8 +1990,8 @@ class Relation
*/
public function createPmaDatabase()
{
$GLOBALS['dbi']->tryQuery("CREATE DATABASE IF NOT EXISTS `phpmyadmin`");
if ($error = $GLOBALS['dbi']->getError()) {
$this->dbi->tryQuery("CREATE DATABASE IF NOT EXISTS `phpmyadmin`");
if ($error = $this->dbi->getError()) {
if ($GLOBALS['errno'] == 1044) {
$GLOBALS['message'] = __(
'You do not have necessary privileges to create a database named'
@ -2030,7 +2038,7 @@ class Relation
'pma__export_templates' => 'export_templates',
];
$existingTables = $GLOBALS['dbi']->getTables($db, DatabaseInterface::CONNECT_CONTROL);
$existingTables = $this->dbi->getTables($db, DatabaseInterface::CONNECT_CONTROL);
$createQueries = null;
$foundOne = false;
@ -2039,10 +2047,10 @@ class Relation
if ($create) {
if ($createQueries == null) { // first create
$createQueries = $this->getDefaultPmaTableNames();
$GLOBALS['dbi']->selectDb($db);
$this->dbi->selectDb($db);
}
$GLOBALS['dbi']->tryQuery($createQueries[$table]);
if ($error = $GLOBALS['dbi']->getError()) {
$this->dbi->tryQuery($createQueries[$table]);
if ($error = $this->dbi->getError()) {
$GLOBALS['message'] = $error;
return;
}
@ -2200,12 +2208,12 @@ class Relation
public function getTables($foreignDb, $tblStorageEngine)
{
$tables = [];
$tablesRows = $GLOBALS['dbi']->query(
$tablesRows = $this->dbi->query(
'SHOW TABLE STATUS FROM ' . Util::backquote($foreignDb),
DatabaseInterface::CONNECT_USER,
DatabaseInterface::QUERY_STORE
);
while ($row = $GLOBALS['dbi']->fetchRow($tablesRows)) {
while ($row = $this->dbi->fetchRow($tablesRows)) {
if (isset($row[1]) && mb_strtoupper($row[1]) == $tblStorageEngine) {
$tables[] = $row[0];
}

View File

@ -30,7 +30,7 @@ class RelationCleanup
*/
public static function column($db, $table, $column)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if ($cfgRelation['commwork']) {
@ -92,7 +92,7 @@ class RelationCleanup
*/
public static function table($db, $table)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if ($cfgRelation['commwork']) {
@ -178,7 +178,7 @@ class RelationCleanup
*/
public static function database($db)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if ($cfgRelation['commwork']) {
@ -277,7 +277,7 @@ class RelationCleanup
*/
public static function user($username)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if ($cfgRelation['bookmarkwork']) {

View File

@ -70,7 +70,7 @@ class SavedSearches
public function __construct(array $config)
{
$this->setConfig($config);
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
}
/**

View File

@ -544,7 +544,7 @@ class Privileges
*/
public function getHtmlToChooseUserGroup($username)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
$groupTable = Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation['usergroups']);
@ -591,7 +591,7 @@ class Privileges
public function setUserGroup($username, $userGroup)
{
$userGroup = is_null($userGroup) ? '' : $userGroup;
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if (empty($cfgRelation['db']) || empty($cfgRelation['users']) || empty($cfgRelation['usergroups'])) {
return;
@ -2944,7 +2944,7 @@ class Privileges
*/
public function getUserGroupCount()
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
$user_group_table = Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['usergroups']);
@ -2968,7 +2968,7 @@ class Privileges
*/
public function getUserGroupForUser($username)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if (empty($cfgRelation['db'])
@ -3013,7 +3013,7 @@ class Privileges
$hostname,
$username
) {
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
if (isset($GLOBALS['dbname'])) {
//if (preg_match('/\\\\(?:_|%)/i', $dbname)) {
if (preg_match('/(?<!\\\\)(?:_|%)/i', $GLOBALS['dbname'])) {
@ -3674,7 +3674,7 @@ class Privileges
*/
public function getHtmlTableBodyForUserRights(array $db_rights)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
$user_group_count = 0;
if ($cfgRelation['menuswork']) {

View File

@ -29,7 +29,7 @@ class UserGroups
*/
public static function getHtmlForListingUsersofAGroup($userGroup)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$html_output = '<h2>'
. sprintf(__('Users of \'%s\' user group'), htmlspecialchars($userGroup))
. '</h2>';
@ -73,7 +73,7 @@ class UserGroups
*/
public static function getHtmlForUserGroupsTable()
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$html_output = '<h2>' . __('User groups') . '</h2>';
$cfgRelation = $relation->getRelationsParam();
$groupTable = Util::backquote($cfgRelation['db'])
@ -193,7 +193,7 @@ class UserGroups
*/
public static function delete($userGroup)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
$userTable = Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation['users']);
@ -218,7 +218,7 @@ class UserGroups
*/
public static function getHtmlToEditUserGroup($userGroup = null)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$html_output = '';
if ($userGroup == null) {
$html_output .= '<h2>' . __('Add user group') . '</h2>';
@ -349,7 +349,7 @@ class UserGroups
*/
public static function edit($userGroup, $new = false)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$tabs = Util::getMenuTabList();
$cfgRelation = $relation->getRelationsParam();
$groupTable = Util::backquote($cfgRelation['db'])

View File

@ -51,7 +51,7 @@ class Sql
*/
public function __construct()
{
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->transformations = new Transformations();
}

View File

@ -39,7 +39,7 @@ class SystemDatabase
public function __construct(DatabaseInterface $dbi)
{
$this->dbi = $dbi;
$this->relation = new Relation();
$this->relation = new Relation($this->dbi);
}
/**

View File

@ -98,7 +98,7 @@ class Table
$this->_dbi = $dbi;
$this->_name = $table_name;
$this->_db_name = $db_name;
$this->relation = new Relation();
$this->relation = new Relation($this->_dbi);
}
/**
@ -833,7 +833,7 @@ class Table
array $where_fields,
array $new_fields
) {
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$last_id = -1;
if (!isset($GLOBALS['cfgRelation']) || !$GLOBALS['cfgRelation'][$work]) {
@ -923,7 +923,7 @@ class Table
) {
global $err_url;
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
// Try moving the tables directly, using native `RENAME` statement.
if ($move && $what == 'data') {

View File

@ -72,7 +72,7 @@ class Tracker
* from Relation::getRelationsParam
*/
self::$enabled = false;
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
/* Restore original state */
self::$enabled = true;
@ -137,7 +137,7 @@ class Tracker
* from Relation::getRelationsParam
*/
self::$enabled = false;
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
/* Restore original state */
self::$enabled = true;
@ -193,7 +193,7 @@ class Tracker
) {
global $sql_backquotes, $export_type;
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
if ($tracking_set == '') {
$tracking_set
@ -303,7 +303,7 @@ class Tracker
*/
public static function deleteTracking($dbname, $tablename, $version = '')
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$sql_query = "/*NOTRACK*/\n"
. "DELETE FROM " . self::_getTrackingTable()
@ -339,7 +339,7 @@ class Tracker
$query,
$tracking_set = 'CREATE DATABASE,ALTER DATABASE,DROP DATABASE'
) {
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$date = Util::date('Y-m-d H:i:s');
@ -407,7 +407,7 @@ class Tracker
$version,
$new_state
) {
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$sql_query = " UPDATE " . self::_getTrackingTable() .
" SET `tracking_active` = '" . $new_state . "' " .
@ -440,7 +440,7 @@ class Tracker
$type,
$new_data
) {
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
if ($type == 'DDL') {
$save_to = 'schema_sql';
@ -520,7 +520,7 @@ class Tracker
*/
public static function getVersion($dbname, $tablename, $statement = null)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$sql_query = " SELECT MAX(version) FROM " . self::_getTrackingTable() .
" WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($dbname) . "' " .
@ -551,7 +551,7 @@ class Tracker
*/
public static function getTrackedData($dbname, $tablename, $version)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$sql_query = " SELECT * FROM " . self::_getTrackingTable() .
" WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($dbname) . "' ";
@ -806,7 +806,7 @@ class Tracker
*/
public static function handleQuery($query)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
// If query is marked as untouchable, leave
if (mb_strstr($query, "/*NOTRACK*/")) {
@ -925,7 +925,7 @@ class Tracker
*/
private static function _getTrackingTable()
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
return Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['tracking']);

View File

@ -141,7 +141,7 @@ class Tracking
*/
public function getListOfVersionsOfTable()
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
$sql_query = " SELECT * FROM " .
Util::backquote($cfgRelation['db']) . "." .
@ -234,7 +234,7 @@ class Tracking
*/
public function getSqlResultForSelectableTables()
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
$sql_query = " SELECT DISTINCT db_name, table_name FROM " .
@ -1184,7 +1184,7 @@ class Tracking
string $pmaThemeImage,
string $textDir
) {
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
// Prepare statement to get HEAD version

View File

@ -254,7 +254,7 @@ class Transformations
*/
public function getMime($db, $table, $strict = false, $fullName = false)
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if (! $cfgRelation['mimework']) {
@ -343,7 +343,7 @@ class Transformations
$inputTransformOpts,
$forcedelete = false
) {
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if (! $cfgRelation['mimework']) {
@ -450,7 +450,7 @@ class Transformations
*/
public function clear($db, $table = '', $column = '')
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if (! isset($cfgRelation['column_info'])) {

View File

@ -27,7 +27,7 @@ class RelationExtension extends AbstractExtension
*/
public function getFunctions()
{
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
return [
new TwigFunction(
'foreign_dropdown',

View File

@ -40,7 +40,7 @@ class UserPreferences
*/
public function __construct()
{
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
$this->template = new Template();
}

View File

@ -30,7 +30,7 @@ Util::checkParameters(
global $db, $table;
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$transformations = new Transformations();
$template = new Template();

View File

@ -64,7 +64,7 @@ if (!empty($_GET['saved'])) {
}
// warn about using session storage for settings
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if (! $cfgRelation['userconfigwork']) {
$msg = __(

View File

@ -31,7 +31,7 @@ if (isset($_REQUEST['getNaviSettings']) && $_REQUEST['getNaviSettings']) {
exit();
}
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if ($cfgRelation['navwork']) {
if (isset($_REQUEST['hideNavItem'])) {

View File

@ -20,7 +20,7 @@ require_once 'libraries/common.inc.php';
* get all variables needed for exporting relational schema
* in $cfgRelation
*/
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
if (! isset($_REQUEST['export_type'])) {

View File

@ -26,7 +26,7 @@ require_once 'libraries/common.inc.php';
*/
require_once 'libraries/check_user_privileges.inc.php';
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
/**

View File

@ -14,7 +14,7 @@ use PhpMyAdmin\Server\Users;
require_once 'libraries/common.inc.php';
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$relation->getRelationsParam();
if (! $GLOBALS['cfgRelation']['menuswork']) {
exit;

View File

@ -91,7 +91,7 @@ if (! empty($disp_message)) {
$table_columns = $insertEdit->getTableColumns($db, $table);
// retrieve keys into foreign fields, if any
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$foreigners = $relation->getForeigners($db, $table);
// Retrieve form parameters for insert/edit form

View File

@ -25,7 +25,7 @@ $scripts = $header->getScripts();
$scripts->addFile('export.js');
// Get the relation settings
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
$displayExport = new Export();

View File

@ -46,7 +46,7 @@ $url_params['goto'] = $url_params['back'] = 'tbl_operations.php';
/**
* Gets relation settings
*/
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
// reselect current db (needed in some cases probably due to

View File

@ -43,7 +43,7 @@ $options_array = [
'NO_ACTION' => 'NO ACTION',
'RESTRICT' => 'RESTRICT',
];
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
$tbl_storage_engine = mb_strtoupper(
$dbi->getTable($db, $table)->getStatusInfo('Engine')

View File

@ -50,7 +50,7 @@ $scripts->addFile('sql.js');
$scripts->addFile('indexes.js');
$scripts->addFile('gis_data_editor.js');
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$transformations = new Transformations();
$insertEdit = new InsertEdit($GLOBALS['dbi']);

View File

@ -47,7 +47,7 @@ class TableSearchControllerTest extends PmaTestCase
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$GLOBALS['cfgRelation'] = $relation->getRelationsParam();
$GLOBALS['cfg']['Server']['DisableIS'] = false;
@ -90,6 +90,7 @@ class TableSearchControllerTest extends PmaTestCase
->will($this->returnArgument(0));
$GLOBALS['dbi'] = $dbi;
$relation->dbi = $dbi;
$this->_response = new ResponseStub();

View File

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests\Navigation;
use PhpMyAdmin\Navigation\Navigation;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Tests\PmaTestCase;
/**
@ -72,6 +73,7 @@ class NavigationTest extends PmaTestCase
->will($this->returnArgument(0));
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
$this->object->hideNavigationItem('itemName', 'itemType', 'db');
}
@ -96,6 +98,7 @@ class NavigationTest extends PmaTestCase
$dbi->expects($this->any())->method('escapeString')
->will($this->returnArgument(0));
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
$this->object->unhideNavigationItem('itemName', 'itemType', 'db');
}
@ -146,6 +149,7 @@ class NavigationTest extends PmaTestCase
->will($this->returnArgument(0));
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
$html = $this->object->getItemUnhideDialog('db');
$this->assertContains(

View File

@ -11,6 +11,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Plugins\Export\ExportHtmlword;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Tests\PmaTestCase;
use ReflectionMethod;
use ReflectionProperty;
@ -531,6 +532,7 @@ class ExportHtmlwordTest extends PmaTestCase
->will($this->returnArgument(0));
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
$this->object->expects($this->exactly(3))
->method('formatOneColumnDefinition')
@ -627,6 +629,7 @@ class ExportHtmlwordTest extends PmaTestCase
->will($this->returnArgument(0));
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
$GLOBALS['cfgRelation']['relation'] = true;
$_SESSION['relation'][0] = [

View File

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests\Plugins\Export;
use PhpMyAdmin\Plugins\Export\ExportLatex;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Tests\PmaTestCase;
use ReflectionMethod;
use ReflectionProperty;
@ -743,6 +744,7 @@ class ExportLatexTest extends PmaTestCase
);
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
if (isset($GLOBALS['latex_caption'])) {
unset($GLOBALS['latex_caption']);
}
@ -852,6 +854,7 @@ class ExportLatexTest extends PmaTestCase
);
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
$GLOBALS['cfgRelation']['relation'] = true;
$_SESSION['relation'][0] = [

View File

@ -11,6 +11,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Plugins\Export\ExportOdt;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Tests\PmaTestCase;
use ReflectionMethod;
use ReflectionProperty;
@ -742,6 +743,7 @@ class ExportOdtTest extends PmaTestCase
);
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
$this->object->expects($this->exactly(2))
->method('formatOneColumnDefinition')
@ -848,6 +850,7 @@ class ExportOdtTest extends PmaTestCase
);
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
$GLOBALS['odt_buffer'] = '';
$GLOBALS['cfgRelation']['relation'] = true;
$_SESSION['relation'][0] = [

View File

@ -11,6 +11,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Plugins\Export\ExportSql;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Table;
use PhpMyAdmin\Tests\PmaTestCase;
use ReflectionMethod;
@ -1240,6 +1241,7 @@ class ExportSqlTest extends PmaTestCase
);
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
$method = new ReflectionMethod('PhpMyAdmin\Plugins\Export\ExportSql', '_getTableComments');
$method->setAccessible(true);

View File

@ -11,6 +11,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Plugins\Export\ExportTexytext;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Tests\PmaTestCase;
use ReflectionMethod;
use ReflectionProperty;
@ -428,6 +429,7 @@ class ExportTexytextTest extends PmaTestCase
->will($this->returnValue([$columns]));
$GLOBALS['dbi'] = $dbi;
$this->object->relation = new Relation($dbi);
$this->object->expects($this->exactly(1))
->method('formatOneColumnDefinition')

View File

@ -56,7 +56,7 @@ class DiaRelationSchemaTest extends PmaTestCase
'relwork' => 'relwork',
'relation' => 'relation'
];
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$relation->getRelationsParam();
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')

View File

@ -57,7 +57,7 @@ class EpsRelationSchemaTest extends PmaTestCase
'relwork' => 'relwork',
'relation' => 'relation'
];
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$relation->getRelationsParam();
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')

View File

@ -69,7 +69,7 @@ class PdfRelationSchemaTest extends PmaTestCase
'column_info' => 'column_info',
'pdf_pages' => 'pdf_pages'
];
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$relation->getRelationsParam();
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')

View File

@ -56,7 +56,7 @@ class SvgRelationSchemaTest extends PmaTestCase
'relwork' => 'relwork',
'relation' => 'relation'
];
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$relation->getRelationsParam();
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')

View File

@ -60,8 +60,8 @@ class RelationCleanupTest extends TestCase
$GLOBALS['cfg']['Server']['designer_settings'] = 'designer_settings';
$GLOBALS['cfg']['Server']['export_templates'] = 'pma__export_templates';
$this->relation = new Relation($GLOBALS['dbi']);
$this->redefineRelation();
$this->relation = new Relation();
}
@ -73,6 +73,7 @@ class RelationCleanupTest extends TestCase
public function redefineRelation()
{
$GLOBALS['dbi'] = new RelationCleanupDbiMock();
$this->relation->dbi = $GLOBALS['dbi'];
unset($_SESSION['relation'][$GLOBALS['server']]);
}

View File

@ -47,7 +47,7 @@ class RelationTest extends TestCase
$GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath();
$GLOBALS['cfg']['ServerDefault'] = 0;
$this->relation = new Relation();
$this->relation = new Relation($GLOBALS['dbi']);
}
/**
@ -70,6 +70,7 @@ class RelationTest extends TestCase
->will($this->returnValue('executeResult2'));
$GLOBALS['dbi'] = $dbi;
$this->relation->dbi = $GLOBALS['dbi'];
$sql = "insert into PMA_bookmark A,B values(1, 2)";
$this->assertEquals(
@ -232,6 +233,7 @@ class RelationTest extends TestCase
->will($this->returnValue($getColumnsResult));
$GLOBALS['dbi'] = $dbi;
$this->relation->dbi = $GLOBALS['dbi'];
$db = 'information_schema';
$this->assertEquals(
@ -270,6 +272,7 @@ class RelationTest extends TestCase
->method('getError')
->will($this->onConsecutiveCalls(true, false));
$GLOBALS['dbi'] = $dbi;
$this->relation->dbi = $GLOBALS['dbi'];
$GLOBALS['cfg']['Server']['pmadb'] = 'pmadb';
$GLOBALS['cfg']['Server']['column_info'] = 'column_info';

View File

@ -44,7 +44,7 @@ class TableTest extends PmaTestCase
$GLOBALS['sql_drop_table'] = true;
$GLOBALS['cfg']['Server']['table_uiprefs'] = "pma__table_uiprefs";
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$GLOBALS['cfgRelation'] = $relation->getRelationsParam();
$GLOBALS['dblist'] = new \stdClass();
$GLOBALS['dblist']->databases = new class

View File

@ -23,7 +23,7 @@ define('IS_TRANSFORMATION_WRAPPER', true);
require_once './libraries/common.inc.php';
$transformations = new Transformations();
$relation = new Relation();
$relation = new Relation($GLOBALS['dbi']);
$cfgRelation = $relation->getRelationsParam();
/**