Merge branch 'bug4704' into QA_4_3

This commit is contained in:
Madhura Jayaratne 2015-01-22 06:45:41 +05:30
commit ebb9c1fdbe

View File

@ -429,6 +429,9 @@ class Node
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle !== false) {
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($this->_isHideDb($arr[0])) {
continue;
}
$prefix = strstr($arr[0], $dbSeparator, true);
if ($prefix === false) {
$prefix = $arr[0];
@ -447,6 +450,9 @@ class Node
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle !== false) {
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($this->_isHideDb($arr[0])) {
continue;
}
if (! in_array($arr[0], $retval)) {
foreach ($prefixes as $prefix) {
$starts_with = strpos(
@ -497,6 +503,9 @@ class Node
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle !== false) {
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($this->_isHideDb($arr[0])) {
continue;
}
if (! in_array($arr[0], $retval)) {
if ($pos <= 0 && $count < $maxItems) {
$retval[] = $arr[0];
@ -562,6 +571,9 @@ class Node
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle !== false) {
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
if ($this->_isHideDb($arr[0])) {
continue;
}
$prefix = strstr($arr[0], $dbSeparator, true);
if ($prefix === false) {
$prefix = $arr[0];
@ -600,6 +612,22 @@ class Node
return $retval;
}
/**
* Detemines whether a given database should be hidden according to 'hide_db'
*
* @param string $db database name
*
* @return boolean whether to hide
*/
private function _isHideDb($db) {
if (! empty($GLOBALS['cfg']['Server']['hide_db'])
&& preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db)
) {
return true;
}
return false;
}
/**
* Get the list of databases for 'SHOW DATABASES LIKE' queries.
* If a search clause is set it gets the highest priority while only_db gets