From d98658187a5ee9be33bb5fa54e7fe0638ef9b70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sun, 25 Mar 2018 19:32:13 -0300 Subject: [PATCH] Replace PhpMyAdmin\Relation static calls 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 | 6 +- chk_rel.php | 14 ++-- db_datadict.php | 12 +-- db_operations.php | 5 +- db_qbe.php | 3 +- db_tracking.php | 5 +- export.php | 4 +- index.php | 4 +- libraries/classes/Bookmark.php | 3 +- libraries/classes/CentralColumns.php | 11 ++- libraries/classes/Console.php | 46 ++++++----- .../Database/DatabaseStructureController.php | 16 +++- .../Table/TableRelationController.php | 12 ++- .../Table/TableSearchController.php | 12 ++- .../Table/TableStructureController.php | 14 +++- libraries/classes/Database/Designer.php | 25 ++++-- .../classes/Database/Designer/Common.php | 63 +++++++++------ libraries/classes/Database/Qbe.php | 52 +++++++------ libraries/classes/DatabaseInterface.php | 14 +++- libraries/classes/Display/Export.php | 21 ++++- libraries/classes/Display/Results.php | 20 +++-- libraries/classes/ErrorReport.php | 8 +- libraries/classes/Footer.php | 8 +- libraries/classes/InsertEdit.php | 20 +++-- libraries/classes/Menu.php | 20 +++-- libraries/classes/Navigation/Navigation.php | 19 ++++- libraries/classes/Navigation/Nodes/Node.php | 8 +- .../classes/Navigation/Nodes/NodeDatabase.php | 8 +- .../Navigation/Nodes/NodeDatabaseChild.php | 2 +- libraries/classes/Normalization.php | 10 ++- libraries/classes/Operations.php | 17 ++++- .../classes/Plugins/Export/ExportHtmlword.php | 5 +- .../classes/Plugins/Export/ExportLatex.php | 6 +- .../classes/Plugins/Export/ExportOdt.php | 7 +- .../classes/Plugins/Export/ExportSql.php | 7 +- .../classes/Plugins/Export/ExportTexytext.php | 5 +- .../classes/Plugins/Export/Helpers/Pdf.php | 44 ++++++++++- libraries/classes/Plugins/ExportPlugin.php | 14 +++- .../Plugins/Schema/Dia/DiaRelationSchema.php | 2 +- .../Plugins/Schema/Eps/EpsRelationSchema.php | 2 +- .../Plugins/Schema/ExportRelationSchema.php | 30 +++++--- libraries/classes/Plugins/Schema/Pdf/Pdf.php | 8 +- .../Plugins/Schema/Pdf/PdfRelationSchema.php | 10 +-- .../Plugins/Schema/Svg/SvgRelationSchema.php | 2 +- .../classes/Plugins/Schema/TableStats.php | 9 ++- libraries/classes/RecentFavoriteTable.php | 12 ++- libraries/classes/RelationCleanup.php | 76 ++++++++++--------- libraries/classes/SavedSearches.php | 48 +++++++----- libraries/classes/Server/Privileges.php | 24 +++--- libraries/classes/Server/UserGroups.php | 29 ++++--- libraries/classes/Sql.php | 19 ++++- libraries/classes/SystemDatabase.php | 10 ++- libraries/classes/Table.php | 42 +++++----- libraries/classes/Tracker.php | 68 +++++++++++------ libraries/classes/Tracking.php | 13 ++-- libraries/classes/Transformations.php | 13 ++-- libraries/classes/Twig/RelationExtension.php | 12 +-- libraries/classes/UserPreferences.php | 17 ++++- libraries/tbl_columns_definition_form.inc.php | 12 +-- libraries/user_preferences.inc.php | 3 +- navigation.php | 3 +- schema_export.php | 3 +- server_privileges.php | 3 +- server_user_groups.php | 3 +- tbl_change.php | 3 +- tbl_export.php | 3 +- tbl_operations.php | 5 +- tbl_relation.php | 7 +- tbl_replace.php | 4 +- .../Table/TableSearchControllerTest.php | 3 +- .../Plugins/Schema/DiaRelationSchemaTest.php | 3 +- .../Plugins/Schema/EpsRelationSchemaTest.php | 3 +- .../Plugins/Schema/PdfRelationSchemaTest.php | 3 +- .../Plugins/Schema/SvgRelationSchemaTest.php | 3 +- test/classes/RelationCleanupTest.php | 22 ++++-- test/classes/TableTest.php | 3 +- transformation_wrapper.php | 3 +- 77 files changed, 739 insertions(+), 369 deletions(-) diff --git a/browse_foreigners.php b/browse_foreigners.php index 8412321cc9..0ae36334d1 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -35,10 +35,12 @@ $header = $response->getHeader(); $header->disableMenuAndConsole(); $header->setBodyId('body_browse_foreigners'); +$relation = new Relation(); + /** * Displays the frame */ -$foreigners = Relation::getForeigners($db, $table); +$foreigners = $relation->getForeigners($db, $table); $browseForeigners = new BrowseForeigners( $GLOBALS['cfg']['LimitChars'], $GLOBALS['cfg']['MaxRows'], @@ -50,7 +52,7 @@ $foreign_limit = $browseForeigners->getForeignLimit( isset($_REQUEST['foreign_showAll']) ? $_REQUEST['foreign_showAll'] : null ); -$foreignData = Relation::getForeignData( +$foreignData = $relation->getForeignData( $foreigners, $_REQUEST['field'], true, isset($_REQUEST['foreign_filter']) ? $_REQUEST['foreign_filter'] diff --git a/chk_rel.php b/chk_rel.php index 183ee4f338..f34e8300d5 100644 --- a/chk_rel.php +++ b/chk_rel.php @@ -10,25 +10,27 @@ use PhpMyAdmin\Response; require_once 'libraries/common.inc.php'; +$relation = new Relation(); + // If request for creating the pmadb if (isset($_REQUEST['create_pmadb'])) { - if (Relation::createPmaDatabase()) { - Relation::fixPmaTables('phpmyadmin'); + if ($relation->createPmaDatabase()) { + $relation->fixPmaTables('phpmyadmin'); } } // If request for creating all PMA tables. if (isset($_REQUEST['fixall_pmadb'])) { - Relation::fixPmaTables($GLOBALS['db']); + $relation->fixPmaTables($GLOBALS['db']); } -$cfgRelation = Relation::getRelationsParam(); +$cfgRelation = $relation->getRelationsParam(); // If request for creating missing PMA tables. if (isset($_REQUEST['fix_pmadb'])) { - Relation::fixPmaTables($cfgRelation['db']); + $relation->fixPmaTables($cfgRelation['db']); } $response = Response::getInstance(); $response->addHTML( - Relation::getRelationsParamDiagnostic($cfgRelation) + $relation->getRelationsParamDiagnostic($cfgRelation) ); diff --git a/db_datadict.php b/db_datadict.php index 94e8beb860..7a5d7f4fa3 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -34,10 +34,12 @@ $response = Response::getInstance(); $header = $response->getHeader(); $header->enablePrintView(); +$relation = new Relation(); + /** * Gets the relations settings */ -$cfgRelation = Relation::getRelationsParam(); +$cfgRelation = $relation->getRelationsParam(); /** * Check parameters @@ -50,7 +52,7 @@ PhpMyAdmin\Util::checkParameters(array('db')); $err_url = 'db_sql.php' . Url::getCommon(array('db' => $db)); if ($cfgRelation['commwork']) { - $comment = Relation::getDbComment($db); + $comment = $relation->getDbComment($db); /** * Displays DB comment @@ -69,7 +71,7 @@ $tables = $GLOBALS['dbi']->getTables($db); $count = 0; foreach ($tables as $table) { - $comments = Relation::getComments($db, $table); + $comments = $relation->getComments($db, $table); echo '
' , "\n"; @@ -95,7 +97,7 @@ foreach ($tables as $table) { $columns = $GLOBALS['dbi']->getColumns($db, $table); // Check if we can use Relations - list($res_rel, $have_rel) = Relation::getRelationsAndStatus( + list($res_rel, $have_rel) = $relation->getRelationsAndStatus( ! empty($cfgRelation['relation']), $db, $table ); @@ -171,7 +173,7 @@ foreach ($tables as $table) { if ($have_rel) { echo ' '; - if ($foreigner = Relation::searchColumnInForeigners($res_rel, $column_name)) { + if ($foreigner = $relation->searchColumnInForeigners($res_rel, $column_name)) { echo htmlspecialchars( $foreigner['foreign_table'] . ' -> ' diff --git a/db_operations.php b/db_operations.php index 02118e3f5d..70c0d53877 100644 --- a/db_operations.php +++ b/db_operations.php @@ -210,15 +210,16 @@ if (strlen($GLOBALS['db']) > 0 /** * Settings for relations stuff */ +$relation = new Relation(); -$cfgRelation = Relation::getRelationsParam(); +$cfgRelation = $relation->getRelationsParam(); /** * Check if comments were updated * (must be done before displaying the menu tabs) */ if (isset($_REQUEST['comment'])) { - Relation::setDbComment($GLOBALS['db'], $_REQUEST['comment']); + $relation->setDbComment($GLOBALS['db'], $_REQUEST['comment']); } require 'libraries/db_common.inc.php'; diff --git a/db_qbe.php b/db_qbe.php index df143faaaf..3860d68b13 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -22,7 +22,8 @@ require_once 'libraries/common.inc.php'; $response = Response::getInstance(); // Gets the relation settings -$cfgRelation = Relation::getRelationsParam(); +$relation = new Relation(); +$cfgRelation = $relation->getRelationsParam(); $savedSearchList = array(); $savedSearch = null; diff --git a/db_tracking.php b/db_tracking.php index d5fa0c7086..0c8724d60a 100644 --- a/db_tracking.php +++ b/db_tracking.php @@ -111,7 +111,8 @@ if ($num_tables == 0 && count($data['ddlog']) == 0) { } // --------------------------------------------------------------------------- -$cfgRelation = Relation::getRelationsParam(); +$relation = new Relation(); +$cfgRelation = $relation->getRelationsParam(); // Prepare statement to get HEAD version $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' . @@ -122,7 +123,7 @@ $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' . ' GROUP BY table_name' . ' ORDER BY table_name ASC'; -$all_tables_result = Relation::queryAsControlUser($all_tables_query); +$all_tables_result = $relation->queryAsControlUser($all_tables_query); // If a HEAD version exists if (is_object($all_tables_result) diff --git a/export.php b/export.php index f7e00868d0..376bd020c2 100644 --- a/export.php +++ b/export.php @@ -399,6 +399,8 @@ if ($save_on_server) { } // end download } +$relation = new Relation(); + // Fake loop just to allow skip of remain of this code by break, I'd really // need exceptions here :-) do { @@ -417,7 +419,7 @@ do { || isset($GLOBALS[$what . '_comments']); $do_mime = isset($GLOBALS[$what . '_mime']); if ($do_relation || $do_comments || $do_mime) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $relation->getRelationsParam(); } // Include dates in export? diff --git a/index.php b/index.php index 79b59ba508..cc492e77ee 100644 --- a/index.php +++ b/index.php @@ -594,8 +594,10 @@ if (@file_exists('config')) { ); } +$relation = new Relation(); + if ($server > 0) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $relation->getRelationsParam(); if (! $cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false ) { diff --git a/libraries/classes/Bookmark.php b/libraries/classes/Bookmark.php index e9298f2c5b..1fc833bae1 100644 --- a/libraries/classes/Bookmark.php +++ b/libraries/classes/Bookmark.php @@ -218,7 +218,8 @@ class Bookmark return $cfgBookmark; } - $cfgRelation = Relation::getRelationsParam(); + $relation = new Relation(); + $cfgRelation = $relation->getRelationsParam(); if ($cfgRelation['bookmarkwork']) { $cfgBookmark = array( 'user' => $user, diff --git a/libraries/classes/CentralColumns.php b/libraries/classes/CentralColumns.php index 66b43ba741..88a5a832a2 100644 --- a/libraries/classes/CentralColumns.php +++ b/libraries/classes/CentralColumns.php @@ -57,6 +57,11 @@ class CentralColumns */ private $disableIs; + /** + * @var Relation + */ + private $relation; + /** * Constructor * @@ -70,6 +75,8 @@ class CentralColumns $this->maxRows = (int) $GLOBALS['cfg']['MaxRows']; $this->charEditing = $GLOBALS['cfg']['CharEditing']; $this->disableIs = (bool) $GLOBALS['cfg']['Server']['DisableIS']; + + $this->relation = new Relation(); } /** @@ -86,7 +93,7 @@ class CentralColumns return $cfgCentralColumns; } - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if ($cfgRelation['centralcolumnswork']) { $cfgCentralColumns = array( @@ -486,7 +493,7 @@ class CentralColumns $has_list = $this->getFromTable($db, $table, true); $this->dbi->selectDb($db); foreach ($has_list as $column) { - $column_status = Relation::checkChildForeignReferences( + $column_status = $this->relation->checkChildForeignReferences( $db, $table, $column['col_name'] ); //column definition can only be changed if diff --git a/libraries/classes/Console.php b/libraries/classes/Console.php index d05649099a..565635b9f0 100644 --- a/libraries/classes/Console.php +++ b/libraries/classes/Console.php @@ -27,14 +27,6 @@ class Console */ private $_isEnabled; - /** - * Creates a new class instance - */ - public function __construct() - { - $this->_isEnabled = true; - } - /** * Whether we are servicing an ajax request. * @@ -43,6 +35,20 @@ class Console */ private $_isAjax; + /** + * @var Relation + */ + private $relation; + + /** + * Creates a new class instance + */ + public function __construct() + { + $this->_isEnabled = true; + $this->relation = new Relation(); + } + /** * Set the ajax flag to indicate whether * we are servicing an ajax request @@ -124,23 +130,23 @@ class Console public function getDisplay() { if ((! $this->_isAjax) && $this->_isEnabled) { - $cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']); + $cfgBookmark = Bookmark::getParams( + $GLOBALS['cfg']['Server']['user'] + ); $image = Util::getImage('console', __('SQL Query Console')); - $_sql_history = Relation::getHistory($GLOBALS['cfg']['Server']['user']); + $_sql_history = $this->relation->getHistory( + $GLOBALS['cfg']['Server']['user'] + ); $bookmarkContent = static::getBookmarkContent(); - return Template::get('console/display') - ->render( - array( - 'cfg_bookmark' => $cfgBookmark, - 'image' => $image, - 'sql_history' => $_sql_history, - 'bookmark_content' => $bookmarkContent, - ) - ); + return Template::get('console/display')->render([ + 'cfg_bookmark' => $cfgBookmark, + 'image' => $image, + 'sql_history' => $_sql_history, + 'bookmark_content' => $bookmarkContent, + ]); } return ''; } - } diff --git a/libraries/classes/Controllers/Database/DatabaseStructureController.php b/libraries/classes/Controllers/Database/DatabaseStructureController.php index d42b1e1e4b..ba3edd39e6 100644 --- a/libraries/classes/Controllers/Database/DatabaseStructureController.php +++ b/libraries/classes/Controllers/Database/DatabaseStructureController.php @@ -55,6 +55,20 @@ class DatabaseStructureController extends DatabaseController */ protected $_is_show_stats; + /** + * @var Relation $relation + */ + private $relation; + + /** + * Constructor + */ + public function __construct($response, $dbi, $db) + { + parent::__construct($response, $dbi, $db); + $this->relation = new Relation(); + } + /** * Retrieves databse information for further use * @@ -229,7 +243,7 @@ class DatabaseStructureController extends DatabaseController // Request for Synchronization of favorite tables. if (isset($_REQUEST['sync_favorite_tables'])) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if ($cfgRelation['favoritework']) { $this->synchronizeFavoriteTables($fav_instance, $user, $favorite_tables); } diff --git a/libraries/classes/Controllers/Table/TableRelationController.php b/libraries/classes/Controllers/Table/TableRelationController.php index c794886d4b..9a5c6dc683 100644 --- a/libraries/classes/Controllers/Table/TableRelationController.php +++ b/libraries/classes/Controllers/Table/TableRelationController.php @@ -53,6 +53,11 @@ class TableRelationController extends TableController */ protected $upd_query; + /** + * @var Relation $relation + */ + private $relation; + /** * Constructor * @@ -83,6 +88,7 @@ class TableRelationController extends TableController $this->existrel = $existrel; $this->existrel_foreign = $existrel_foreign; $this->upd_query = $upd_query; + $this->relation = new Relation(); } /** @@ -133,14 +139,14 @@ class TableRelationController extends TableController // If we did an update, refresh our data if (isset($_POST['destination_db']) && $this->cfgRelation['relwork']) { - $this->existrel = Relation::getForeigners( + $this->existrel = $this->relation->getForeigners( $this->db, $this->table, '', 'internal' ); } if (isset($_POST['destination_foreign_db']) && Util::isForeignKeySupported($this->tbl_storage_engine) ) { - $this->existrel_foreign = Relation::getForeigners( + $this->existrel_foreign = $this->relation->getForeigners( $this->db, $this->table, '', 'foreign' ); } @@ -156,7 +162,7 @@ class TableRelationController extends TableController 'table' => $GLOBALS['table'] ), 'is_foreign_key_supported' => Util::isForeignKeySupported($engine), - 'cfg_relation' => Relation::getRelationsParam(), + 'cfg_relation' => $this->relation->getRelationsParam(), ) ) ); diff --git a/libraries/classes/Controllers/Table/TableSearchController.php b/libraries/classes/Controllers/Table/TableSearchController.php index c1f8e3be72..9162fa4339 100644 --- a/libraries/classes/Controllers/Table/TableSearchController.php +++ b/libraries/classes/Controllers/Table/TableSearchController.php @@ -80,6 +80,11 @@ class TableSearchController extends TableController protected $url_query; + /** + * @var Relation $relation + */ + private $relation; + /** * Constructor * @@ -104,6 +109,7 @@ class TableSearchController extends TableController $this->_columnCollations = array(); $this->_geomColumnFlag = false; $this->_foreigners = array(); + $this->relation = new Relation(); // Loads table's information $this->_loadTableInfo(); $this->_connectionCharSet = $this->dbi->fetchValue( @@ -162,7 +168,7 @@ class TableSearchController extends TableController } // end for // Retrieve foreign keys - $this->_foreigners = Relation::getForeigners($this->db, $this->table); + $this->_foreigners = $this->relation->getForeigners($this->db, $this->table); } /** @@ -270,7 +276,7 @@ class TableSearchController extends TableController //Set default datalabel if not selected if (!isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') { - $dataLabel = Relation::getDisplayField($this->db, $this->table); + $dataLabel = $this->relation->getDisplayField($this->db, $this->table); } else { $dataLabel = $_POST['dataLabel']; } @@ -870,7 +876,7 @@ class TableSearchController extends TableController ) ); //Gets link to browse foreign data(if any) and criteria inputbox - $foreignData = Relation::getForeignData( + $foreignData = $this->relation->getForeignData( $this->_foreigners, $this->_columnNames[$column_index], false, '', '' ); $value = Template::get('table/search/input_box')->render( diff --git a/libraries/classes/Controllers/Table/TableStructureController.php b/libraries/classes/Controllers/Table/TableStructureController.php index 51278280b3..f60fc3cbd9 100644 --- a/libraries/classes/Controllers/Table/TableStructureController.php +++ b/libraries/classes/Controllers/Table/TableStructureController.php @@ -73,6 +73,11 @@ class TableStructureController extends TableController */ private $createAddField; + /** + * @var Relation $relation + */ + private $relation; + /** * TableStructureController constructor * @@ -121,6 +126,7 @@ class TableStructureController extends TableController $this->table_obj = $this->dbi->getTable($this->db, $this->table); $this->createAddField = new CreateAddField($dbi); + $this->relation = new Relation(); } /** @@ -278,7 +284,7 @@ class TableStructureController extends TableController 'table' => $this->table ), 'is_foreign_key_supported' => Util::isForeignKeySupported($engine), - 'cfg_relation' => Relation::getRelationsParam(), + 'cfg_relation' => $this->relation->getRelationsParam(), ) ) ); @@ -325,7 +331,7 @@ class TableStructureController extends TableController /** * Gets the relation settings */ - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); /** * Runs common work @@ -1047,7 +1053,7 @@ class TableStructureController extends TableController if (isset($_REQUEST['field_orig']) && is_array($_REQUEST['field_orig'])) { foreach ($_REQUEST['field_orig'] as $fieldindex => $fieldcontent) { if ($_REQUEST['field_name'][$fieldindex] != $fieldcontent) { - Relation::renameField( + $this->relation->renameField( $this->db, $this->table, $fieldcontent, $_REQUEST['field_name'][$fieldindex] ); @@ -1184,7 +1190,7 @@ class TableStructureController extends TableController $mime_map = array(); if ($GLOBALS['cfg']['ShowPropertyComments']) { - $comments_map = Relation::getComments($this->db, $this->table); + $comments_map = $this->relation->getComments($this->db, $this->table); if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { $mime_map = Transformations::getMIME($this->db, $this->table, true); } diff --git a/libraries/classes/Database/Designer.php b/libraries/classes/Database/Designer.php index 881c46cc8c..a28a42ade9 100644 --- a/libraries/classes/Database/Designer.php +++ b/libraries/classes/Database/Designer.php @@ -22,6 +22,19 @@ use PhpMyAdmin\Util; */ class Designer { + /** + * @var Relation $relation + */ + private $relation; + + /** + * Constructor + */ + public function __construct() + { + $this->relation = new Relation(); + } + /** * Function to get html for displaying the page edit/delete form * @@ -32,7 +45,7 @@ class Designer */ public function getHtmlForEditOrDeletePages($db, $operation) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); return Template::get('database/designer/edit_delete_pages')->render([ 'db' => $db, 'operation' => $operation, @@ -50,7 +63,7 @@ class Designer */ public function getHtmlForPageSaveAs($db) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); return Template::get('database/designer/page_save_as')->render([ 'db' => $db, 'pdfwork' => $cfgRelation['pdfwork'], @@ -67,13 +80,13 @@ class Designer */ private function getPageIdsAndNames($db) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); $page_query = "SELECT `page_nr`, `page_descr` FROM " . Util::backquote($cfgRelation['db']) . "." . Util::backquote($cfgRelation['pdf_pages']) . " WHERE db_name = '" . $GLOBALS['dbi']->escapeString($db) . "'" . " ORDER BY `page_descr`"; - $page_rs = Relation::queryAsControlUser( + $page_rs = $this->relation->queryAsControlUser( $page_query, false, DatabaseInterface::QUERY_STORE @@ -137,7 +150,7 @@ class Designer array $script_display_field, $display_page ) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); return Template::get('database/designer/js_fields')->render([ 'server' => $GLOBALS['server'], 'db' => $_GET['db'], @@ -178,7 +191,7 @@ class Designer { $params = []; - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if ($GLOBALS['cfgRelation']['designersettingswork']) { $query = 'SELECT `settings_data` FROM ' diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php index 07f91e7842..45a9cf403a 100644 --- a/libraries/classes/Database/Designer/Common.php +++ b/libraries/classes/Database/Designer/Common.php @@ -20,6 +20,19 @@ use PhpMyAdmin\Util; */ class Common { + /** + * @var Relation $relation + */ + private $relation; + + /** + * Constructor + */ + public function __construct() + { + $this->relation = new Relation(); + } + /** * Retrieves table info and stores it in $GLOBALS['designer'] * @@ -65,7 +78,7 @@ class Common $one_table['ENGINE'] ); - $DF = Relation::getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']); + $DF = $this->relation->getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']); if ($DF != '') { $retval[$GLOBALS['designer_url']["TABLE_NAME_SMALL"][$i]] = $DF; } @@ -126,7 +139,7 @@ class Common DatabaseInterface::QUERY_STORE ); while ($val = @$GLOBALS['dbi']->fetchRow($alltab_rs)) { - $row = Relation::getForeigners($GLOBALS['db'], $val[0], '', 'internal'); + $row = $this->relation->getForeigners($GLOBALS['db'], $val[0], '', 'internal'); if ($row !== false) { foreach ($row as $field => $value) { @@ -140,7 +153,7 @@ class Common $i++; } } - $row = Relation::getForeigners($GLOBALS['db'], $val[0], '', 'foreign'); + $row = $this->relation->getForeigners($GLOBALS['db'], $val[0], '', 'foreign'); if ($row !== false) { foreach ($row['foreign_keys_data'] as $one_key) { @@ -250,7 +263,7 @@ class Common */ public function getTablePositions($pg) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (! $cfgRelation['pdfwork']) { return null; } @@ -284,7 +297,7 @@ class Common */ public function getPageName($pg) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (! $cfgRelation['pdfwork']) { return null; } @@ -312,7 +325,7 @@ class Common */ public function deletePage($pg) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (! $cfgRelation['pdfwork']) { return false; } @@ -320,7 +333,7 @@ class Common $query = "DELETE FROM " . Util::backquote($cfgRelation['db']) . "." . Util::backquote($cfgRelation['table_coords']) . " WHERE " . Util::backquote('pdf_page_number') . " = " . intval($pg); - $success = Relation::queryAsControlUser( + $success = $this->relation->queryAsControlUser( $query, true, DatabaseInterface::QUERY_STORE ); @@ -328,7 +341,7 @@ class Common $query = "DELETE FROM " . Util::backquote($cfgRelation['db']) . "." . Util::backquote($cfgRelation['pdf_pages']) . " WHERE " . Util::backquote('page_nr') . " = " . intval($pg); - $success = Relation::queryAsControlUser( + $success = $this->relation->queryAsControlUser( $query, true, DatabaseInterface::QUERY_STORE ); } @@ -346,7 +359,7 @@ class Common */ public function getDefaultPage($db) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (! $cfgRelation['pdfwork']) { return null; } @@ -381,7 +394,7 @@ class Common */ public function getLoadingPage($db) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (! $cfgRelation['pdfwork']) { return null; } @@ -421,9 +434,9 @@ class Common */ public function createNewPage($pageName, $db) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if ($cfgRelation['pdfwork']) { - $pageNumber = Relation::createPage( + $pageNumber = $this->relation->createPage( $pageName, $cfgRelation, $db @@ -442,7 +455,7 @@ class Common */ public function saveTablePositions($pg) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (! $cfgRelation['pdfwork']) { return false; } @@ -457,7 +470,7 @@ class Common . " AND `pdf_page_number` = '" . $GLOBALS['dbi']->escapeString($pg) . "'"; - $res = Relation::queryAsControlUser( + $res = $this->relation->queryAsControlUser( $query, true, DatabaseInterface::QUERY_STORE @@ -484,7 +497,7 @@ class Common . "'" . $GLOBALS['dbi']->escapeString($_REQUEST['t_x'][$key]) . "', " . "'" . $GLOBALS['dbi']->escapeString($_REQUEST['t_y'][$key]) . "')"; - $res = Relation::queryAsControlUser( + $res = $this->relation->queryAsControlUser( $query, true, DatabaseInterface::QUERY_STORE ); } @@ -503,7 +516,7 @@ class Common */ public function saveDisplayField($db, $table, $field) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (!$cfgRelation['displaywork']) { return false; } @@ -542,8 +555,8 @@ class Common && $type_T1 == $type_T2 ) { // relation exists? - $existrel_foreign = Relation::getForeigners($DB2, $T2, '', 'foreign'); - $foreigner = Relation::searchColumnInForeigners($existrel_foreign, $F2); + $existrel_foreign = $this->relation->getForeigners($DB2, $T2, '', 'foreign'); + $foreigner = $this->relation->searchColumnInForeigners($existrel_foreign, $F2); if ($foreigner && isset($foreigner['constraint']) ) { @@ -629,7 +642,7 @@ class Common . "'" . $GLOBALS['dbi']->escapeString($T1) . "', " . "'" . $GLOBALS['dbi']->escapeString($F1) . "')"; - if (Relation::queryAsControlUser($q, false, DatabaseInterface::QUERY_STORE) + if ($this->relation->queryAsControlUser($q, false, DatabaseInterface::QUERY_STORE) ) { return array(true, __('Internal relationship has been added.')); } @@ -667,8 +680,8 @@ class Common && $type_T1 == $type_T2 ) { // InnoDB - $existrel_foreign = Relation::getForeigners($DB2, $T2, '', 'foreign'); - $foreigner = Relation::searchColumnInForeigners($existrel_foreign, $F2); + $existrel_foreign = $this->relation->getForeigners($DB2, $T2, '', 'foreign'); + $foreigner = $this->relation->searchColumnInForeigners($existrel_foreign, $F2); if (isset($foreigner['constraint'])) { $upd_query = 'ALTER TABLE ' . Util::backquote($DB2) @@ -698,7 +711,7 @@ class Common . " AND foreign_table = '" . $GLOBALS['dbi']->escapeString($T1) . "'" . " AND foreign_field = '" . $GLOBALS['dbi']->escapeString($F1) . "'"; - $result = Relation::queryAsControlUser( + $result = $this->relation->queryAsControlUser( $delete_query, false, DatabaseInterface::QUERY_STORE @@ -725,7 +738,7 @@ class Common */ public function saveSetting($index, $value) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); $cfgDesigner = array( 'user' => $GLOBALS['cfg']['Server']['user'], 'db' => $cfgRelation['db'], @@ -757,7 +770,7 @@ class Common . " WHERE username = '" . $GLOBALS['dbi']->escapeString($cfgDesigner['user']) . "';"; - $success = Relation::queryAsControlUser($save_query); + $success = $this->relation->queryAsControlUser($save_query); } else { $save_data = array($index => $value); @@ -768,7 +781,7 @@ class Common . " VALUES('" . $cfgDesigner['user'] . "'," . " '" . json_encode($save_data) . "');"; - $success = Relation::queryAsControlUser($query); + $success = $this->relation->queryAsControlUser($query); } } diff --git a/libraries/classes/Database/Qbe.php b/libraries/classes/Database/Qbe.php index f7110abe66..e2f326ce29 100644 --- a/libraries/classes/Database/Qbe.php +++ b/libraries/classes/Database/Qbe.php @@ -212,6 +212,33 @@ class Qbe */ private $_currentSearch = null; + /** + * @var Relation $relation + */ + private $relation; + + /** + * Public Constructor + * + * @param string $dbname Database name + * @param array $savedSearchList List of saved searches + * @param SavedSearches $currentSearch Current search id + */ + public function __construct( + $dbname, + array $savedSearchList = array(), + $currentSearch = null + ) { + $this->_db = $dbname; + $this->_savedSearchList = $savedSearchList; + $this->_currentSearch = $currentSearch; + $this->_loadCriterias(); + // Sets criteria parameters + $this->_setSearchParams(); + $this->_setCriteriaTablesAndColumns(); + $this->relation = new Relation(); + } + /** * Initialize criterias * @@ -241,25 +268,6 @@ class Qbe return $this->_currentSearch; } - /** - * Public Constructor - * - * @param string $dbname Database name - * @param array $savedSearchList List of saved searches - * @param SavedSearches $currentSearch Current search id - */ - public function __construct( - $dbname, array $savedSearchList = array(), $currentSearch = null - ) { - $this->_db = $dbname; - $this->_savedSearchList = $savedSearchList; - $this->_currentSearch = $currentSearch; - $this->_loadCriterias(); - // Sets criteria parameters - $this->_setSearchParams(); - $this->_setCriteriaTablesAndColumns(); - } - /** * Sets search parameters * @@ -1395,7 +1403,7 @@ class Qbe // So we select candidate tables which are foreign tables. $foreign_tables = array(); foreach ($candidate_columns as $one_table) { - $foreigners = Relation::getForeigners($this->_db, $one_table); + $foreigners = $this->relation->getForeigners($this->_db, $one_table); foreach ($foreigners as $key => $foreigner) { if ($key != 'foreign_keys_data') { if (in_array($foreigner['foreign_table'], $candidate_columns)) { @@ -1584,7 +1592,7 @@ class Qbe // having relationships with unfinalized tables foreach ($unfinalized as $oneTable) { - $references = Relation::getChildReferences($this->_db, $oneTable); + $references = $this->relation->getChildReferences($this->_db, $oneTable); foreach ($references as $column => $columnReferences) { foreach ($columnReferences as $reference) { @@ -1667,7 +1675,7 @@ class Qbe { $relations[$oneTable] = array(); - $foreigners = Relation::getForeigners($GLOBALS['db'], $oneTable); + $foreigners = $this->relation->getForeigners($GLOBALS['db'], $oneTable); foreach ($foreigners as $field => $foreigner) { // Foreign keys data if ($field == 'foreign_keys_data') { diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php index e2f76ed83f..577a98a618 100644 --- a/libraries/classes/DatabaseInterface.php +++ b/libraries/classes/DatabaseInterface.php @@ -117,6 +117,11 @@ class DatabaseInterface */ public $types; + /** + * @var Relation $relation + */ + private $relation; + /** * Constructor * @@ -133,6 +138,7 @@ class DatabaseInterface $this->_table_cache = array(); $this->_current_user = array(); $this->types = new Types($this); + $this->relation = new Relation(); } /** @@ -1528,15 +1534,15 @@ class DatabaseInterface // If Zero configuration mode enabled, check PMA tables in current db. if ($GLOBALS['cfg']['ZeroConf'] == true) { if (strlen($GLOBALS['db'])) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (empty($cfgRelation['db'])) { - Relation::fixPmaTables($GLOBALS['db'], false); + $this->relation->fixPmaTables($GLOBALS['db'], false); } } - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (empty($cfgRelation['db'])) { if ($GLOBALS['dblist']->databases->exists('phpmyadmin')) { - Relation::fixPmaTables('phpmyadmin', false); + $this->relation->fixPmaTables('phpmyadmin', false); } } } diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index c404727eb8..c4b9479fb7 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -27,6 +27,19 @@ use PhpMyAdmin\Util; */ class Export { + /** + * @var Relation $relation + */ + private $relation; + + /** + * Constructor + */ + public function __construct() + { + $this->relation = new Relation(); + } + /** * Outputs appropriate checked statement for checkbox. * @@ -139,7 +152,7 @@ class Export private function getOptionsForTemplates($exportType) { // Get the relation settings - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); $query = "SELECT `id`, `template_name` FROM " . Util::backquote($cfgRelation['db']) . '.' @@ -149,7 +162,7 @@ class Export . "' AND `export_type` = '" . $GLOBALS['dbi']->escapeString($exportType) . "'" . " ORDER BY `template_name`;"; - $result = Relation::queryAsControlUser($query); + $result = $this->relation->queryAsControlUser($query); $templates = []; if ($result !== false) { @@ -643,7 +656,7 @@ class Export $unlimNumRows, $multiValues ) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (isset($_REQUEST['single_table'])) { $GLOBALS['single_table'] = $_REQUEST['single_table']; @@ -758,7 +771,7 @@ class Export break; } - $result = Relation::queryAsControlUser($query, false); + $result = $this->relation->queryAsControlUser($query, false); $response = Response::getInstance(); if (! $result) { diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index c386670403..7b772145bc 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -185,6 +185,10 @@ class Results */ public $transformation_info; + /** + * @var Relation $relation + */ + private $relation; /** * Get any property of this class @@ -200,7 +204,6 @@ class Results } } - /** * Set values for any property of this class * @@ -216,7 +219,6 @@ class Results } } - /** * Constructor for PhpMyAdmin\Display\Results class * @@ -229,6 +231,8 @@ class Results */ public function __construct($db, $table, $goto, $sql_query) { + $this->relation = new Relation(); + $this->_setDefaultTransformations(); $this->__set('db', $db); @@ -243,7 +247,7 @@ class Results * * @return void */ - private function _setDefaultTransformations() + private function _setDefaultTransformations() { $json_highlighting_data = array( 'libraries/classes/Plugins/Transformations/Output/Text_Plain_Json.php', @@ -310,7 +314,7 @@ class Results ) ); - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if ($cfgRelation['db']) { $this->transformation_info[$cfgRelation['db']] = array(); $relDb = &$this->transformation_info[$cfgRelation['db']]; @@ -1575,7 +1579,7 @@ class Results if (empty($field->table)) { continue; } - $ret[$field->table] = Relation::getComments( + $ret[$field->table] = $this->relation->getComments( empty($field->database) ? $this->__get('db') : $field->database, $field->table ); @@ -4602,7 +4606,7 @@ class Results // configuration storage. If no PMA storage, we won't be able // to use the "column to display" notion (for example show // the name related to a numeric id). - $exist_rel = Relation::getForeigners( + $exist_rel = $this->relation->getForeigners( $this->__get('db'), $this->__get('table'), '', self::POSITION_BOTH ); @@ -4610,7 +4614,7 @@ class Results foreach ($exist_rel as $master_field => $rel) { if ($master_field != 'foreign_keys_data') { - $display_field = Relation::getDisplayField( + $display_field = $this->relation->getDisplayField( $rel['foreign_db'], $rel['foreign_table'] ); $map[$master_field] = array( @@ -4622,7 +4626,7 @@ class Results } else { foreach ($rel as $key => $one_key) { foreach ($one_key['index_list'] as $index => $one_field) { - $display_field = Relation::getDisplayField( + $display_field = $this->relation->getDisplayField( isset($one_key['ref_db_name']) ? $one_key['ref_db_name'] : $GLOBALS['db'], diff --git a/libraries/classes/ErrorReport.php b/libraries/classes/ErrorReport.php index d512123458..297bd22cb1 100644 --- a/libraries/classes/ErrorReport.php +++ b/libraries/classes/ErrorReport.php @@ -31,6 +31,11 @@ class ErrorReport */ private $httpRequest; + /** + * @var Relation $relation + */ + private $relation; + /** * Constructor * @@ -40,6 +45,7 @@ class ErrorReport { $this->httpRequest = $httpRequest; $this->submissionUrl = 'https://reports.phpmyadmin.net/incidents/create'; + $this->relation = new Relation(); } /** @@ -66,7 +72,7 @@ class ErrorReport */ public function getData($exceptionType = 'js') { - $relParams = Relation::getRelationsParam(); + $relParams = $this->relation->getRelationsParam(); // common params for both, php & js exceptions $report = [ "pma_version" => PMA_VERSION, diff --git a/libraries/classes/Footer.php b/libraries/classes/Footer.php index 6fb79dc165..a664e3b49e 100644 --- a/libraries/classes/Footer.php +++ b/libraries/classes/Footer.php @@ -55,6 +55,11 @@ class Footer */ private $_isEnabled; + /** + * @var Relation $relation + */ + private $relation; + /** * Creates a new class instance */ @@ -63,6 +68,7 @@ class Footer $this->_isEnabled = true; $this->_scripts = new Scripts(); $this->_isMinimal = false; + $this->relation = new Relation(); } /** @@ -245,7 +251,7 @@ class Footer && isset($GLOBALS['dbi']) && $GLOBALS['dbi']->isUserType('logged') ) { - Relation::setHistory( + $this->relation->setHistory( Core::ifSetOr($GLOBALS['db'], ''), Core::ifSetOr($GLOBALS['table'], ''), $GLOBALS['cfg']['Server']['user'], diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php index 5aaaeb7488..362fe6c51c 100644 --- a/libraries/classes/InsertEdit.php +++ b/libraries/classes/InsertEdit.php @@ -33,6 +33,11 @@ class InsertEdit */ private $dbi; + /** + * @var Relation $relation + */ + private $relation; + /** * Constructor * @@ -41,6 +46,7 @@ class InsertEdit public function __construct(DatabaseInterface $dbi) { $this->dbi = $dbi; + $this->relation = new Relation(); } /** @@ -567,7 +573,7 @@ class InsertEdit array $foreigners, array $foreignData ) { - $foreigner = Relation::searchColumnInForeigners($foreigners, $column['Field']); + $foreigner = $this->relation->searchColumnInForeigners($foreigners, $column['Field']); if (mb_strstr($column['True_Type'], 'enum')) { if (mb_strlen($column['Type']) > 20) { $nullify_code = '1'; @@ -895,7 +901,7 @@ class InsertEdit . ($readOnly ? ' disabled' : '') . ' tabindex="' . ($tabindex + $tabindex_for_value) . '"' . ' id="field_' . $idindex . '_3">'; - $html_output .= Relation::foreignDropdown( + $html_output .= $this->relation->foreignDropdown( $foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], @@ -2361,8 +2367,8 @@ class InsertEdit array $map, $relation_field ) { - $foreigner = Relation::searchColumnInForeigners($map, $relation_field); - $display_field = Relation::getDisplayField( + $foreigner = $this->relation->searchColumnInForeigners($map, $relation_field); + $display_field = $this->relation->getDisplayField( $foreigner['foreign_db'], $foreigner['foreign_table'] ); @@ -2410,7 +2416,7 @@ class InsertEdit $dispval, $relation_field_value ) { - $foreigner = Relation::searchColumnInForeigners($map, $relation_field); + $foreigner = $this->relation->searchColumnInForeigners($map, $relation_field); if ('K' == $_SESSION['tmpval']['relational_display']) { // user chose "relational key" in the display options, so // the title contains the display field @@ -2909,7 +2915,7 @@ class InsertEdit $comments_map = array(); if ($GLOBALS['cfg']['ShowPropertyComments']) { - $comments_map = Relation::getComments($db, $table); + $comments_map = $this->relation->getComments($db, $table); } return $comments_map; @@ -3198,7 +3204,7 @@ class InsertEdit // The function column // ------------------- - $foreignData = Relation::getForeignData( + $foreignData = $this->relation->getForeignData( $foreigners, $column['Field'], false, diff --git a/libraries/classes/Menu.php b/libraries/classes/Menu.php index dea9f801ef..4e34ac8f01 100644 --- a/libraries/classes/Menu.php +++ b/libraries/classes/Menu.php @@ -42,6 +42,11 @@ class Menu */ private $_table; + /** + * @var Relation $relation + */ + private $relation; + /** * Creates a new instance of Menu * @@ -52,8 +57,9 @@ class Menu public function __construct($server, $db, $table) { $this->_server = $server; - $this->_db = $db; - $this->_table = $table; + $this->_db = $db; + $this->_table = $table; + $this->relation = new Relation(); } /** @@ -138,7 +144,7 @@ class Menu return Util::cacheGet($cache_key); } $allowedTabs = Util::getMenuTabList($level); - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if ($cfgRelation['menuswork']) { $groupTable = Util::backquote($cfgRelation['db']) . "." @@ -153,7 +159,7 @@ class Menu . $userTable . " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "')"; - $result = Relation::queryAsControlUser($sql_query, false); + $result = $this->relation->queryAsControlUser($sql_query, false); if ($result) { while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { $tabName = mb_substr( @@ -293,12 +299,12 @@ class Menu } // end if } else { // no table selected, display database comment if present - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); // Get additional information about tables for tooltip is done // in Util::getDbInfo() only once if ($cfgRelation['commwork']) { - $comment = Relation::getDbComment($this->_db); + $comment = $this->relation->getDbComment($this->_db); /** * Displays table comment */ @@ -449,7 +455,7 @@ class Menu /** * Gets the relation settings */ - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); $tabs = array(); diff --git a/libraries/classes/Navigation/Navigation.php b/libraries/classes/Navigation/Navigation.php index f4e7fa2f3d..c4a297bee6 100644 --- a/libraries/classes/Navigation/Navigation.php +++ b/libraries/classes/Navigation/Navigation.php @@ -22,6 +22,19 @@ use PhpMyAdmin\Util; */ class Navigation { + /** + * @var Relation $relation + */ + private $relation; + + /** + * Constructor + */ + public function __construct() + { + $this->relation = new Relation(); + } + /** * Renders the navigation tree, or part of it * @@ -99,7 +112,7 @@ class Navigation . "'" . $GLOBALS['dbi']->escapeString($dbName) . "'," . "'" . (! empty($tableName)? $GLOBALS['dbi']->escapeString($tableName) : "" ) . "')"; - Relation::queryAsControlUser($sqlQuery, false); + $this->relation->queryAsControlUser($sqlQuery, false); } /** @@ -150,7 +163,7 @@ class Navigation ? " AND `table_name`='" . $GLOBALS['dbi']->escapeString($tableName) . "'" : "" ); - Relation::queryAsControlUser($sqlQuery, false); + $this->relation->queryAsControlUser($sqlQuery, false); } /** @@ -176,7 +189,7 @@ class Navigation . " AND `db_name`='" . $GLOBALS['dbi']->escapeString($dbName) . "'" . " AND `table_name`='" . (! empty($tableName) ? $GLOBALS['dbi']->escapeString($tableName) : '') . "'"; - $result = Relation::queryAsControlUser($sqlQuery, false); + $result = $this->relation->queryAsControlUser($sqlQuery, false); $hidden = array(); if ($result) { diff --git a/libraries/classes/Navigation/Nodes/Node.php b/libraries/classes/Navigation/Nodes/Node.php index 21fd384327..a299206317 100644 --- a/libraries/classes/Navigation/Nodes/Node.php +++ b/libraries/classes/Navigation/Nodes/Node.php @@ -102,6 +102,11 @@ class Node */ public $pos3 = 0; + /** + * @var Relation $relation + */ + protected $relation; + /** * Initialises the class by setting the mandatory variables * @@ -120,6 +125,7 @@ class Node $this->type = Node::CONTAINER; } $this->is_group = (bool)$is_group; + $this->relation = new Relation(); } /** @@ -803,7 +809,7 @@ class Node */ public function getNavigationHidingData() { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if ($cfgRelation['navwork']) { $navTable = Util::backquote($cfgRelation['db']) . "." . Util::backquote( diff --git a/libraries/classes/Navigation/Nodes/NodeDatabase.php b/libraries/classes/Navigation/Nodes/NodeDatabase.php index 67d1f9ecee..e36ab0b6b9 100644 --- a/libraries/classes/Navigation/Nodes/NodeDatabase.php +++ b/libraries/classes/Navigation/Nodes/NodeDatabase.php @@ -387,7 +387,7 @@ class NodeDatabase extends Node } // Remove hidden items so that they are not displayed in navigation tree - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if ($cfgRelation['navwork']) { $hiddenItems = $this->getHiddenItems(substr($type, 0, -1)); foreach ($retval as $key => $item) { @@ -411,7 +411,7 @@ class NodeDatabase extends Node public function getHiddenItems($type) { $db = $this->real_name; - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if (empty($cfgRelation['navigationhiding'])) { return array(); } @@ -422,7 +422,7 @@ class NodeDatabase extends Node . " AND `item_type`='" . $type . "'" . " AND `db_name`='" . $GLOBALS['dbi']->escapeString($db) . "'"; - $result = Relation::queryAsControlUser($sqlQuery, false); + $result = $this->relation->queryAsControlUser($sqlQuery, false); $hiddenItems = array(); if ($result) { while ($row = $GLOBALS['dbi']->fetchArray($result)) { @@ -669,7 +669,7 @@ class NodeDatabase extends Node public function getHtmlForControlButtons() { $ret = ''; - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if ($cfgRelation['navwork']) { if ($this->hiddenCount > 0) { $params = array( diff --git a/libraries/classes/Navigation/Nodes/NodeDatabaseChild.php b/libraries/classes/Navigation/Nodes/NodeDatabaseChild.php index e08ae1d853..5fdbbef0ff 100644 --- a/libraries/classes/Navigation/Nodes/NodeDatabaseChild.php +++ b/libraries/classes/Navigation/Nodes/NodeDatabaseChild.php @@ -35,7 +35,7 @@ abstract class NodeDatabaseChild extends Node public function getHtmlForControlButtons() { $ret = ''; - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); if ($cfgRelation['navwork']) { $db = $this->realParent()->real_name; $item = $this->real_name; diff --git a/libraries/classes/Normalization.php b/libraries/classes/Normalization.php index 0fe950b739..d40282a12b 100644 --- a/libraries/classes/Normalization.php +++ b/libraries/classes/Normalization.php @@ -29,6 +29,11 @@ class Normalization */ private $dbi; + /** + * @var Relation $relation + */ + private $relation; + /** * Constructor * @@ -37,6 +42,7 @@ class Normalization public function __construct(DatabaseInterface $dbi) { $this->dbi = $dbi; + $this->relation = new Relation(); } /** @@ -111,7 +117,7 @@ class Normalization $table, array $columnMeta = [] ) { - $cfgRelation = Relation::getRelationsParam(); + $cfgRelation = $this->relation->getRelationsParam(); $contentCells = []; $availableMime = []; $mimeMap = []; @@ -119,7 +125,7 @@ class Normalization $mimeMap = Transformations::getMIME($db, $table); $availableMime = Transformations::getAvailableMIMEtypes(); } - $commentsMap = Relation::getComments($db, $table); + $commentsMap = $this->relation->getComments($db, $table); for ($columnNumber = 0; $columnNumber < $numFields; $columnNumber++) { $contentCells[$columnNumber] = [ 'column_number' => $columnNumber, diff --git a/libraries/classes/Operations.php b/libraries/classes/Operations.php index f6f8462629..e62038a572 100644 --- a/libraries/classes/Operations.php +++ b/libraries/classes/Operations.php @@ -27,6 +27,19 @@ use PhpMyAdmin\Util; */ class Operations { + /** + * @var Relation $relation + */ + private $relation; + + /** + * Constructor + */ + public function __construct() + { + $this->relation = new Relation(); + } + /** * Get HTML output for database comment * @@ -48,7 +61,7 @@ class Operations $html_output .= ''; $html_output .= '' + . 'value="' . htmlspecialchars($this->relation->getDbComment($db)) . '" />' . ''; $html_output .= '
' . '' @@ -1284,7 +1297,7 @@ class Operations // display "Add constraints" choice only if there are // foreign keys - if (Relation::getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) { + if ($this->relation->getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) { $html_output .= ''; $html_output .= '