diff --git a/ChangeLog b/ChangeLog index dab1c1af00..242686236e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -96,6 +96,7 @@ underscore - bug #3830 Can't export custom query because it lowercases table names - bug #3829 Enabling query profiling crashes javascript based navigation + rfe #879 Reserved word warning ++ Remove the database ordering sub-feature of the only_db directive 3.5.8.0 (not yet released) - bug #3828 MariaDB reported as MySQL diff --git a/doc/config.rst b/doc/config.rst index f46d0bf059..9223cff823 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -364,20 +364,9 @@ Server connection settings $cfg['Servers'][$i]['only_db'] = array('db1', 'db2'); - .. versionchanged:: 2.5.5 - The order inside the array is used for sorting the - databases in the navigation panel, so that you can individually - arrange your databases. - - If you want to have certain databases at the top, but don't care about the - others, you do not need to specify all other databases. Use following code - instead to tell phpMyAdmin that it should display db3 and db4 on top, and - the rest in alphabetic order: - - .. code-block:: php - - $cfg['Servers'][$i]['only_db'] = array('db3', 'db4', '\*'); - + .. versionchanged:: 4.0.0 + Previous versions permitted to specify the display order of + the database names via this directive. .. config:option:: $cfg['Servers'][$i]['hide_db'] diff --git a/libraries/List_Database.class.php b/libraries/List_Database.class.php index 7e6a7d54ef..39b121985b 100644 --- a/libraries/List_Database.class.php +++ b/libraries/List_Database.class.php @@ -192,14 +192,6 @@ class PMA_List_Database extends PMA_List $items = array(); foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) { - if ($each_only_db === '*' && ! $this->show_databases_disabled) { - // append all not already listed dbs to the list - $items = array_merge( - $items, array_diff($this->retrieve(), $items) - ); - // there can only be one '*', and this can only be last - break; - } // check if the db name contains wildcard, // thus containing not escaped _ or % diff --git a/libraries/config.default.php b/libraries/config.default.php index 8b1ce032e9..5d4e805b16 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -251,7 +251,7 @@ $cfg['Servers'][$i]['nopassword'] = false; /** * If set to a db-name, only this db is displayed in navigation panel - * It may also be an array of db-names, where sorting order is relevant. + * It may also be an array of db-names * * @global string $cfg['Servers'][$i]['only_db'] */ diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php index f8ef95609d..9120f99a43 100644 --- a/libraries/config/messages.inc.php +++ b/libraries/config/messages.inc.php @@ -403,7 +403,7 @@ $strConfigServers_MaxTableUiprefs_desc = __('Limits number of table preferences $strConfigServers_MaxTableUiprefs_name = __('Maximal number of table preferences to store'); $strConfigServers_nopassword_desc = __('Try to connect without password'); $strConfigServers_nopassword_name = __('Connect without password'); -$strConfigServers_only_db_desc = __('You can use MySQL wildcard characters (% and _), escape them if you want to use their literal instances, i.e. use [kbd]\'my\_db\'[/kbd] and not [kbd]\'my_db\'[/kbd]. Using this option you can sort database list, just enter their names in order and use [kbd]*[/kbd] at the end to show the rest in alphabetical order.'); +$strConfigServers_only_db_desc = __('You can use MySQL wildcard characters (% and _), escape them if you want to use their literal instances, i.e. use [kbd]\'my\_db\'[/kbd] and not [kbd]\'my_db\'[/kbd].'); $strConfigServers_only_db_name = __('Show only listed databases'); $strConfigServers_password_desc = __('Leave empty if not using config auth'); $strConfigServers_password_name = __('Password for config auth'); diff --git a/libraries/navigation/Nodes/Node.class.php b/libraries/navigation/Nodes/Node.class.php index a0ecbd8b68..a1f0e3b442 100644 --- a/libraries/navigation/Nodes/Node.class.php +++ b/libraries/navigation/Nodes/Node.class.php @@ -433,6 +433,21 @@ class Node $whereClause .= "AND `SCHEMA_NAME` NOT REGEXP '" . $GLOBALS['cfg']['Server']['hide_db'] . "' "; } + + if (! empty($GLOBALS['cfg']['Server']['only_db'])) { + if (is_string($GLOBALS['cfg']['Server']['only_db'])) { + $GLOBALS['cfg']['Server']['only_db'] = array( + $GLOBALS['cfg']['Server']['only_db'] + ); + } + $whereClause .= "AND ("; + $subClauses = array(); + foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) { + $subClauses[] = " `SCHEMA_NAME` LIKE '" + . $each_only_db . "' "; + } + $whereClause .= implode("OR", $subClauses) . ")"; + } return $whereClause; }