From d4b4124a5e5d4d3014e41981ae1b0c548c619fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Thu, 30 Aug 2018 19:05:09 -0300 Subject: [PATCH] Remove $GLOBALS['dbi'] from Relation class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- browse_foreigners.php | 2 +- chk_rel.php | 2 +- db_datadict.php | 2 +- db_operations.php | 2 +- db_qbe.php | 2 +- export.php | 2 +- index.php | 2 +- libraries/classes/Bookmark.php | 2 +- libraries/classes/CentralColumns.php | 2 +- libraries/classes/Console.php | 2 +- .../Database/DatabaseStructureController.php | 2 +- .../Table/TableRelationController.php | 2 +- .../Table/TableSearchController.php | 2 +- .../Table/TableStructureController.php | 2 +- libraries/classes/Database/Designer.php | 2 +- .../classes/Database/Designer/Common.php | 2 +- libraries/classes/Database/Qbe.php | 2 +- libraries/classes/DatabaseInterface.php | 2 +- libraries/classes/Display/Export.php | 2 +- libraries/classes/Display/Results.php | 2 +- libraries/classes/ErrorReport.php | 2 +- libraries/classes/Footer.php | 2 +- libraries/classes/InsertEdit.php | 2 +- libraries/classes/Menu.php | 2 +- libraries/classes/Navigation/Navigation.php | 4 +- libraries/classes/Navigation/Nodes/Node.php | 2 +- libraries/classes/Normalization.php | 2 +- libraries/classes/Operations.php | 2 +- .../classes/Plugins/Export/Helpers/Pdf.php | 2 +- libraries/classes/Plugins/ExportPlugin.php | 4 +- .../Plugins/Schema/ExportRelationSchema.php | 2 +- libraries/classes/Plugins/Schema/Pdf/Pdf.php | 2 +- .../classes/Plugins/Schema/TableStats.php | 2 +- libraries/classes/RecentFavoriteTable.php | 2 +- libraries/classes/Relation.php | 184 +++++++++--------- libraries/classes/RelationCleanup.php | 8 +- libraries/classes/SavedSearches.php | 2 +- libraries/classes/Server/Privileges.php | 12 +- libraries/classes/Server/UserGroups.php | 10 +- libraries/classes/Sql.php | 2 +- libraries/classes/SystemDatabase.php | 2 +- libraries/classes/Table.php | 6 +- libraries/classes/Tracker.php | 22 +-- libraries/classes/Tracking.php | 6 +- libraries/classes/Transformations.php | 6 +- libraries/classes/Twig/RelationExtension.php | 2 +- libraries/classes/UserPreferences.php | 2 +- libraries/tbl_columns_definition_form.inc.php | 2 +- libraries/user_preferences.inc.php | 2 +- navigation.php | 2 +- schema_export.php | 2 +- server_privileges.php | 2 +- server_user_groups.php | 2 +- tbl_change.php | 2 +- tbl_export.php | 2 +- tbl_operations.php | 2 +- tbl_relation.php | 2 +- tbl_replace.php | 2 +- .../Table/TableSearchControllerTest.php | 3 +- test/classes/Navigation/NavigationTest.php | 4 + .../Plugins/Export/ExportHtmlwordTest.php | 3 + .../Plugins/Export/ExportLatexTest.php | 3 + test/classes/Plugins/Export/ExportOdtTest.php | 3 + test/classes/Plugins/Export/ExportSqlTest.php | 2 + .../Plugins/Export/ExportTexytextTest.php | 2 + .../Plugins/Schema/DiaRelationSchemaTest.php | 2 +- .../Plugins/Schema/EpsRelationSchemaTest.php | 2 +- .../Plugins/Schema/PdfRelationSchemaTest.php | 2 +- .../Plugins/Schema/SvgRelationSchemaTest.php | 2 +- test/classes/RelationCleanupTest.php | 3 +- test/classes/RelationTest.php | 5 +- test/classes/TableTest.php | 2 +- transformation_wrapper.php | 2 +- 73 files changed, 214 insertions(+), 184 deletions(-) diff --git a/browse_foreigners.php b/browse_foreigners.php index 8023917d3f..6da290d503 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -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 diff --git a/chk_rel.php b/chk_rel.php index d4724ef2f9..cd625fff32 100644 --- a/chk_rel.php +++ b/chk_rel.php @@ -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'])) { diff --git a/db_datadict.php b/db_datadict.php index 621011acfd..76926ae8b2 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -36,7 +36,7 @@ $response = Response::getInstance(); $header = $response->getHeader(); $header->enablePrintView(); -$relation = new Relation(); +$relation = new Relation($GLOBALS['dbi']); $transformations = new Transformations(); /** diff --git a/db_operations.php b/db_operations.php index f1871547e0..510b524aeb 100644 --- a/db_operations.php +++ b/db_operations.php @@ -216,7 +216,7 @@ if (strlen($GLOBALS['db']) > 0 /** * Settings for relations stuff */ -$relation = new Relation(); +$relation = new Relation($GLOBALS['dbi']); $cfgRelation = $relation->getRelationsParam(); diff --git a/db_qbe.php b/db_qbe.php index 20f32b9b37..82a8d3b980 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -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 = []; diff --git a/export.php b/export.php index bf142267c6..86d62c3d82 100644 --- a/export.php +++ b/export.php @@ -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 :-) diff --git a/index.php b/index.php index d7c0a9a3bf..6ab209e1a8 100644 --- a/index.php +++ b/index.php @@ -604,7 +604,7 @@ if (@file_exists('config')) { ); } -$relation = new Relation(); +$relation = new Relation($GLOBALS['dbi']); if ($server > 0) { $cfgRelation = $relation->getRelationsParam(); diff --git a/libraries/classes/Bookmark.php b/libraries/classes/Bookmark.php index ceb1c2559a..8ac0405adb 100644 --- a/libraries/classes/Bookmark.php +++ b/libraries/classes/Bookmark.php @@ -228,7 +228,7 @@ class Bookmark return $cfgBookmark; } - $relation = new Relation(); + $relation = new Relation($GLOBALS['dbi']); $cfgRelation = $relation->getRelationsParam(); if ($cfgRelation['bookmarkwork']) { $cfgBookmark = [ diff --git a/libraries/classes/CentralColumns.php b/libraries/classes/CentralColumns.php index c8df7d4119..4204ff37e7 100644 --- a/libraries/classes/CentralColumns.php +++ b/libraries/classes/CentralColumns.php @@ -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(); } diff --git a/libraries/classes/Console.php b/libraries/classes/Console.php index 48dac1c2ad..50ac77a243 100644 --- a/libraries/classes/Console.php +++ b/libraries/classes/Console.php @@ -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(); } diff --git a/libraries/classes/Controllers/Database/DatabaseStructureController.php b/libraries/classes/Controllers/Database/DatabaseStructureController.php index 6c641c55d8..ed0638f50f 100644 --- a/libraries/classes/Controllers/Database/DatabaseStructureController.php +++ b/libraries/classes/Controllers/Database/DatabaseStructureController.php @@ -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(); } diff --git a/libraries/classes/Controllers/Table/TableRelationController.php b/libraries/classes/Controllers/Table/TableRelationController.php index e71f2547fb..09c028e109 100644 --- a/libraries/classes/Controllers/Table/TableRelationController.php +++ b/libraries/classes/Controllers/Table/TableRelationController.php @@ -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); } /** diff --git a/libraries/classes/Controllers/Table/TableSearchController.php b/libraries/classes/Controllers/Table/TableSearchController.php index 11f84b602c..ac896961bf 100644 --- a/libraries/classes/Controllers/Table/TableSearchController.php +++ b/libraries/classes/Controllers/Table/TableSearchController.php @@ -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( diff --git a/libraries/classes/Controllers/Table/TableStructureController.php b/libraries/classes/Controllers/Table/TableStructureController.php index 142cd81f19..60b0e1b194 100644 --- a/libraries/classes/Controllers/Table/TableStructureController.php +++ b/libraries/classes/Controllers/Table/TableStructureController.php @@ -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(); } diff --git a/libraries/classes/Database/Designer.php b/libraries/classes/Database/Designer.php index 7407933ec7..c5fde12d23 100644 --- a/libraries/classes/Database/Designer.php +++ b/libraries/classes/Database/Designer.php @@ -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(); } diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php index dad3aee7f3..ec22460ff4 100644 --- a/libraries/classes/Database/Designer/Common.php +++ b/libraries/classes/Database/Designer/Common.php @@ -40,7 +40,7 @@ class Common public function __construct(DatabaseInterface $dbi) { $this->dbi = $dbi; - $this->relation = new Relation(); + $this->relation = new Relation($this->dbi); } /** diff --git a/libraries/classes/Database/Qbe.php b/libraries/classes/Database/Qbe.php index 137196e094..ee8df79926 100644 --- a/libraries/classes/Database/Qbe.php +++ b/libraries/classes/Database/Qbe.php @@ -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(); diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php index 01e1b08c11..dd2d5ac870 100644 --- a/libraries/classes/DatabaseInterface.php +++ b/libraries/classes/DatabaseInterface.php @@ -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); } /** diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 2641a785e8..37d9fa1362 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -44,7 +44,7 @@ class Export */ public function __construct() { - $this->relation = new Relation(); + $this->relation = new Relation($GLOBALS['dbi']); $this->template = new Template(); } diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 4fbfa9f8fe..cddec4086b 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -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(); diff --git a/libraries/classes/ErrorReport.php b/libraries/classes/ErrorReport.php index fc0fd15562..fca2798ab6 100644 --- a/libraries/classes/ErrorReport.php +++ b/libraries/classes/ErrorReport.php @@ -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(); } diff --git a/libraries/classes/Footer.php b/libraries/classes/Footer.php index 35ba8ded99..8c00cc44b8 100644 --- a/libraries/classes/Footer.php +++ b/libraries/classes/Footer.php @@ -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']); } /** diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php index 08a16c3bdf..93f55f2b4c 100644 --- a/libraries/classes/InsertEdit.php +++ b/libraries/classes/InsertEdit.php @@ -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(); diff --git a/libraries/classes/Menu.php b/libraries/classes/Menu.php index 97bb0bc80e..0737a76334 100644 --- a/libraries/classes/Menu.php +++ b/libraries/classes/Menu.php @@ -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']); } /** diff --git a/libraries/classes/Navigation/Navigation.php b/libraries/classes/Navigation/Navigation.php index 7075fdaff8..8f1bc5ca1b 100644 --- a/libraries/classes/Navigation/Navigation.php +++ b/libraries/classes/Navigation/Navigation.php @@ -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']); } /** diff --git a/libraries/classes/Navigation/Nodes/Node.php b/libraries/classes/Navigation/Nodes/Node.php index 2327224604..6772a40ade 100644 --- a/libraries/classes/Navigation/Nodes/Node.php +++ b/libraries/classes/Navigation/Nodes/Node.php @@ -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']); } /** diff --git a/libraries/classes/Normalization.php b/libraries/classes/Normalization.php index 0645131f73..488c9ae7e5 100644 --- a/libraries/classes/Normalization.php +++ b/libraries/classes/Normalization.php @@ -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(); } diff --git a/libraries/classes/Operations.php b/libraries/classes/Operations.php index f8487952a9..f88e2f2d9d 100644 --- a/libraries/classes/Operations.php +++ b/libraries/classes/Operations.php @@ -39,7 +39,7 @@ class Operations */ public function __construct() { - $this->relation = new Relation(); + $this->relation = new Relation($GLOBALS['dbi']); } /** diff --git a/libraries/classes/Plugins/Export/Helpers/Pdf.php b/libraries/classes/Plugins/Export/Helpers/Pdf.php index 8ace9305e2..fac48e0c86 100644 --- a/libraries/classes/Plugins/Export/Helpers/Pdf.php +++ b/libraries/classes/Plugins/Export/Helpers/Pdf.php @@ -90,7 +90,7 @@ class Pdf extends PdfLib $diskcache, $pdfa ); - $this->relation = new Relation(); + $this->relation = new Relation($GLOBALS['dbi']); $this->transformations = new Transformations(); } diff --git a/libraries/classes/Plugins/ExportPlugin.php b/libraries/classes/Plugins/ExportPlugin.php index f356410df3..71eee3820d 100644 --- a/libraries/classes/Plugins/ExportPlugin.php +++ b/libraries/classes/Plugins/ExportPlugin.php @@ -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(); } diff --git a/libraries/classes/Plugins/Schema/ExportRelationSchema.php b/libraries/classes/Plugins/Schema/ExportRelationSchema.php index 4b11ba3cb3..4b6962c59f 100644 --- a/libraries/classes/Plugins/Schema/ExportRelationSchema.php +++ b/libraries/classes/Plugins/Schema/ExportRelationSchema.php @@ -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']); } /** diff --git a/libraries/classes/Plugins/Schema/Pdf/Pdf.php b/libraries/classes/Plugins/Schema/Pdf/Pdf.php index f709d18711..12de3a5216 100644 --- a/libraries/classes/Plugins/Schema/Pdf/Pdf.php +++ b/libraries/classes/Plugins/Schema/Pdf/Pdf.php @@ -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']); } /** diff --git a/libraries/classes/Plugins/Schema/TableStats.php b/libraries/classes/Plugins/Schema/TableStats.php index 9130043264..2ddbd8ada2 100644 --- a/libraries/classes/Plugins/Schema/TableStats.php +++ b/libraries/classes/Plugins/Schema/TableStats.php @@ -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 diff --git a/libraries/classes/RecentFavoriteTable.php b/libraries/classes/RecentFavoriteTable.php index 96f6cf0bc3..a16aafa4c7 100644 --- a/libraries/classes/RecentFavoriteTable.php +++ b/libraries/classes/RecentFavoriteTable.php @@ -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]) diff --git a/libraries/classes/Relation.php b/libraries/classes/Relation.php index e420392b6d..d6fc41fa78 100644 --- a/libraries/classes/Relation.php +++ b/libraries/classes/Relation.php @@ -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]; } diff --git a/libraries/classes/RelationCleanup.php b/libraries/classes/RelationCleanup.php index 1cbd4b8726..bf02acdf8c 100644 --- a/libraries/classes/RelationCleanup.php +++ b/libraries/classes/RelationCleanup.php @@ -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']) { diff --git a/libraries/classes/SavedSearches.php b/libraries/classes/SavedSearches.php index 32cf606f5e..f06e1659d2 100644 --- a/libraries/classes/SavedSearches.php +++ b/libraries/classes/SavedSearches.php @@ -70,7 +70,7 @@ class SavedSearches public function __construct(array $config) { $this->setConfig($config); - $this->relation = new Relation(); + $this->relation = new Relation($GLOBALS['dbi']); } /** diff --git a/libraries/classes/Server/Privileges.php b/libraries/classes/Server/Privileges.php index 665107431e..a452352ff2 100644 --- a/libraries/classes/Server/Privileges.php +++ b/libraries/classes/Server/Privileges.php @@ -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('/(?getRelationsParam(); $user_group_count = 0; if ($cfgRelation['menuswork']) { diff --git a/libraries/classes/Server/UserGroups.php b/libraries/classes/Server/UserGroups.php index 94ea51a8eb..34a6c71907 100644 --- a/libraries/classes/Server/UserGroups.php +++ b/libraries/classes/Server/UserGroups.php @@ -29,7 +29,7 @@ class UserGroups */ public static function getHtmlForListingUsersofAGroup($userGroup) { - $relation = new Relation(); + $relation = new Relation($GLOBALS['dbi']); $html_output = '

' . sprintf(__('Users of \'%s\' user group'), htmlspecialchars($userGroup)) . '

'; @@ -73,7 +73,7 @@ class UserGroups */ public static function getHtmlForUserGroupsTable() { - $relation = new Relation(); + $relation = new Relation($GLOBALS['dbi']); $html_output = '

' . __('User groups') . '

'; $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 .= '

' . __('Add user group') . '

'; @@ -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']) diff --git a/libraries/classes/Sql.php b/libraries/classes/Sql.php index b39648cee2..14afe13f19 100644 --- a/libraries/classes/Sql.php +++ b/libraries/classes/Sql.php @@ -51,7 +51,7 @@ class Sql */ public function __construct() { - $this->relation = new Relation(); + $this->relation = new Relation($GLOBALS['dbi']); $this->transformations = new Transformations(); } diff --git a/libraries/classes/SystemDatabase.php b/libraries/classes/SystemDatabase.php index c476701d98..7fd9195149 100644 --- a/libraries/classes/SystemDatabase.php +++ b/libraries/classes/SystemDatabase.php @@ -39,7 +39,7 @@ class SystemDatabase public function __construct(DatabaseInterface $dbi) { $this->dbi = $dbi; - $this->relation = new Relation(); + $this->relation = new Relation($this->dbi); } /** diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php index bd4fa06a49..a3e6fd9c61 100644 --- a/libraries/classes/Table.php +++ b/libraries/classes/Table.php @@ -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') { diff --git a/libraries/classes/Tracker.php b/libraries/classes/Tracker.php index ce7cb24647..678d946f61 100644 --- a/libraries/classes/Tracker.php +++ b/libraries/classes/Tracker.php @@ -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']); diff --git a/libraries/classes/Tracking.php b/libraries/classes/Tracking.php index dff336d02e..b7d7d85dcf 100644 --- a/libraries/classes/Tracking.php +++ b/libraries/classes/Tracking.php @@ -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 diff --git a/libraries/classes/Transformations.php b/libraries/classes/Transformations.php index 39e0c3f328..8559ac54b4 100644 --- a/libraries/classes/Transformations.php +++ b/libraries/classes/Transformations.php @@ -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'])) { diff --git a/libraries/classes/Twig/RelationExtension.php b/libraries/classes/Twig/RelationExtension.php index 0cfb5c72d0..de8bf4a684 100644 --- a/libraries/classes/Twig/RelationExtension.php +++ b/libraries/classes/Twig/RelationExtension.php @@ -27,7 +27,7 @@ class RelationExtension extends AbstractExtension */ public function getFunctions() { - $relation = new Relation(); + $relation = new Relation($GLOBALS['dbi']); return [ new TwigFunction( 'foreign_dropdown', diff --git a/libraries/classes/UserPreferences.php b/libraries/classes/UserPreferences.php index 884861a3e1..d7611a7257 100644 --- a/libraries/classes/UserPreferences.php +++ b/libraries/classes/UserPreferences.php @@ -40,7 +40,7 @@ class UserPreferences */ public function __construct() { - $this->relation = new Relation(); + $this->relation = new Relation($GLOBALS['dbi']); $this->template = new Template(); } diff --git a/libraries/tbl_columns_definition_form.inc.php b/libraries/tbl_columns_definition_form.inc.php index 63aec33c2d..0a4aab4456 100644 --- a/libraries/tbl_columns_definition_form.inc.php +++ b/libraries/tbl_columns_definition_form.inc.php @@ -30,7 +30,7 @@ Util::checkParameters( global $db, $table; -$relation = new Relation(); +$relation = new Relation($GLOBALS['dbi']); $transformations = new Transformations(); $template = new Template(); diff --git a/libraries/user_preferences.inc.php b/libraries/user_preferences.inc.php index 2a3b94a821..ccf551e4f5 100644 --- a/libraries/user_preferences.inc.php +++ b/libraries/user_preferences.inc.php @@ -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 = __( diff --git a/navigation.php b/navigation.php index 560f3ab218..622c7e4219 100644 --- a/navigation.php +++ b/navigation.php @@ -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'])) { diff --git a/schema_export.php b/schema_export.php index 85148c5223..ff6afc8c3c 100644 --- a/schema_export.php +++ b/schema_export.php @@ -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'])) { diff --git a/server_privileges.php b/server_privileges.php index fcc9f48863..e5765dc944 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -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(); /** diff --git a/server_user_groups.php b/server_user_groups.php index 3d540eecee..e885a0edda 100644 --- a/server_user_groups.php +++ b/server_user_groups.php @@ -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; diff --git a/tbl_change.php b/tbl_change.php index 20804d89bb..be51c1b57e 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -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 diff --git a/tbl_export.php b/tbl_export.php index cf346eee17..98ced269e6 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -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(); diff --git a/tbl_operations.php b/tbl_operations.php index c79c70c068..0d6ffd686e 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -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 diff --git a/tbl_relation.php b/tbl_relation.php index 5b7e551e19..711ab39def 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -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') diff --git a/tbl_replace.php b/tbl_replace.php index 25b0e064aa..40e5f70cbe 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -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']); diff --git a/test/classes/Controllers/Table/TableSearchControllerTest.php b/test/classes/Controllers/Table/TableSearchControllerTest.php index 74cc82fd84..9fca823962 100644 --- a/test/classes/Controllers/Table/TableSearchControllerTest.php +++ b/test/classes/Controllers/Table/TableSearchControllerTest.php @@ -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(); diff --git a/test/classes/Navigation/NavigationTest.php b/test/classes/Navigation/NavigationTest.php index 0016c7190b..43a9b8e893 100644 --- a/test/classes/Navigation/NavigationTest.php +++ b/test/classes/Navigation/NavigationTest.php @@ -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( diff --git a/test/classes/Plugins/Export/ExportHtmlwordTest.php b/test/classes/Plugins/Export/ExportHtmlwordTest.php index 47cdf10c1d..4a73f932df 100644 --- a/test/classes/Plugins/Export/ExportHtmlwordTest.php +++ b/test/classes/Plugins/Export/ExportHtmlwordTest.php @@ -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] = [ diff --git a/test/classes/Plugins/Export/ExportLatexTest.php b/test/classes/Plugins/Export/ExportLatexTest.php index 3071426b53..b05b98bc96 100644 --- a/test/classes/Plugins/Export/ExportLatexTest.php +++ b/test/classes/Plugins/Export/ExportLatexTest.php @@ -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] = [ diff --git a/test/classes/Plugins/Export/ExportOdtTest.php b/test/classes/Plugins/Export/ExportOdtTest.php index 295964c152..76aede239c 100644 --- a/test/classes/Plugins/Export/ExportOdtTest.php +++ b/test/classes/Plugins/Export/ExportOdtTest.php @@ -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] = [ diff --git a/test/classes/Plugins/Export/ExportSqlTest.php b/test/classes/Plugins/Export/ExportSqlTest.php index ce0919ac5a..64dbe9a6ec 100644 --- a/test/classes/Plugins/Export/ExportSqlTest.php +++ b/test/classes/Plugins/Export/ExportSqlTest.php @@ -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); diff --git a/test/classes/Plugins/Export/ExportTexytextTest.php b/test/classes/Plugins/Export/ExportTexytextTest.php index 32b809757b..fe5438244c 100644 --- a/test/classes/Plugins/Export/ExportTexytextTest.php +++ b/test/classes/Plugins/Export/ExportTexytextTest.php @@ -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') diff --git a/test/classes/Plugins/Schema/DiaRelationSchemaTest.php b/test/classes/Plugins/Schema/DiaRelationSchemaTest.php index 4bc0f508f9..18e25f3847 100644 --- a/test/classes/Plugins/Schema/DiaRelationSchemaTest.php +++ b/test/classes/Plugins/Schema/DiaRelationSchemaTest.php @@ -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') diff --git a/test/classes/Plugins/Schema/EpsRelationSchemaTest.php b/test/classes/Plugins/Schema/EpsRelationSchemaTest.php index f889d7b865..c430d272c0 100644 --- a/test/classes/Plugins/Schema/EpsRelationSchemaTest.php +++ b/test/classes/Plugins/Schema/EpsRelationSchemaTest.php @@ -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') diff --git a/test/classes/Plugins/Schema/PdfRelationSchemaTest.php b/test/classes/Plugins/Schema/PdfRelationSchemaTest.php index 2900eb2f0d..be1b267277 100644 --- a/test/classes/Plugins/Schema/PdfRelationSchemaTest.php +++ b/test/classes/Plugins/Schema/PdfRelationSchemaTest.php @@ -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') diff --git a/test/classes/Plugins/Schema/SvgRelationSchemaTest.php b/test/classes/Plugins/Schema/SvgRelationSchemaTest.php index d2ad4bda8b..7f2f2f5846 100644 --- a/test/classes/Plugins/Schema/SvgRelationSchemaTest.php +++ b/test/classes/Plugins/Schema/SvgRelationSchemaTest.php @@ -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') diff --git a/test/classes/RelationCleanupTest.php b/test/classes/RelationCleanupTest.php index 8609bb4dd8..3b9e1baa9b 100644 --- a/test/classes/RelationCleanupTest.php +++ b/test/classes/RelationCleanupTest.php @@ -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']]); } diff --git a/test/classes/RelationTest.php b/test/classes/RelationTest.php index 9402230d3c..02e39dec0f 100644 --- a/test/classes/RelationTest.php +++ b/test/classes/RelationTest.php @@ -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'; diff --git a/test/classes/TableTest.php b/test/classes/TableTest.php index 255b2fb5bb..fc678ca174 100644 --- a/test/classes/TableTest.php +++ b/test/classes/TableTest.php @@ -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 diff --git a/transformation_wrapper.php b/transformation_wrapper.php index a2620cec61..edde026d6b 100644 --- a/transformation_wrapper.php +++ b/transformation_wrapper.php @@ -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(); /**