|
9 | 9 |
|
10 | 10 | use PhpMyAdmin\Config\Settings\Server; |
11 | 11 | use PhpMyAdmin\ConfigStorage\Relation; |
12 | | -use PhpMyAdmin\Database\DatabaseList; |
13 | 12 | use PhpMyAdmin\Dbal\DatabaseName; |
14 | 13 | use PhpMyAdmin\Dbal\DbalInterface; |
15 | 14 | use PhpMyAdmin\Dbal\DbiExtension; |
@@ -141,6 +140,9 @@ class DatabaseInterface implements DbalInterface |
141 | 140 | /** @var float */ |
142 | 141 | public $lastQueryExecutionTime = 0; |
143 | 142 |
|
| 143 | + /** @var ListDatabase|null */ |
| 144 | + private $databaseList = null; |
| 145 | + |
144 | 146 | /** |
145 | 147 | * @param DbiExtension $ext Object to be used for database queries |
146 | 148 | */ |
@@ -701,14 +703,14 @@ public function getDatabasesFull( |
701 | 703 | // f.e. to apply hide_db and only_db |
702 | 704 | $drops = array_diff( |
703 | 705 | array_keys($databases), |
704 | | - (array) $GLOBALS['dblist']->databases |
| 706 | + (array) $this->getDatabaseList() |
705 | 707 | ); |
706 | 708 | foreach ($drops as $drop) { |
707 | 709 | unset($databases[$drop]); |
708 | 710 | } |
709 | 711 | } else { |
710 | 712 | $databases = []; |
711 | | - foreach ($GLOBALS['dblist']->databases as $databaseName) { |
| 713 | + foreach ($this->getDatabaseList() as $databaseName) { |
712 | 714 | // Compatibility with INFORMATION_SCHEMA output |
713 | 715 | $databases[$databaseName]['SCHEMA_NAME'] = $databaseName; |
714 | 716 |
|
@@ -843,7 +845,7 @@ public function getColumnsFull( |
843 | 845 |
|
844 | 846 | $columns = []; |
845 | 847 | if ($database === null) { |
846 | | - foreach ($GLOBALS['dblist']->databases as $database) { |
| 848 | + foreach ($this->getDatabaseList() as $database) { |
847 | 849 | $columns[$database] = $this->getColumnsFull($database, null, null, $link); |
848 | 850 | } |
849 | 851 |
|
@@ -1145,10 +1147,7 @@ public function postConnect(): void |
1145 | 1147 | /* Loads closest context to this version. */ |
1146 | 1148 | Context::loadClosest(($this->isMariaDb ? 'MariaDb' : 'MySql') . $this->versionInt); |
1147 | 1149 |
|
1148 | | - /** |
1149 | | - * the DatabaseList class as a stub for the ListDatabase class |
1150 | | - */ |
1151 | | - $GLOBALS['dblist'] = new DatabaseList(); |
| 1150 | + $this->databaseList = null; |
1152 | 1151 | } |
1153 | 1152 |
|
1154 | 1153 | /** |
@@ -1190,14 +1189,11 @@ public function setCollation(string $collation): void |
1190 | 1189 | public function postConnectControl(Relation $relation): void |
1191 | 1190 | { |
1192 | 1191 | // If Zero configuration mode enabled, check PMA tables in current db. |
1193 | | - if ($GLOBALS['cfg']['ZeroConf'] != true) { |
| 1192 | + if (! $GLOBALS['cfg']['ZeroConf']) { |
1194 | 1193 | return; |
1195 | 1194 | } |
1196 | 1195 |
|
1197 | | - /** |
1198 | | - * the DatabaseList class as a stub for the ListDatabase class |
1199 | | - */ |
1200 | | - $GLOBALS['dblist'] = new DatabaseList(); |
| 1196 | + $this->databaseList = null; |
1201 | 1197 |
|
1202 | 1198 | $relation->initRelationParamsCache(); |
1203 | 1199 | } |
@@ -2108,4 +2104,13 @@ public function prepare(string $query, $link = self::CONNECT_USER) |
2108 | 2104 | { |
2109 | 2105 | return $this->extension->prepare($this->links[$link], $query); |
2110 | 2106 | } |
| 2107 | + |
| 2108 | + public function getDatabaseList(): ListDatabase |
| 2109 | + { |
| 2110 | + if ($this->databaseList === null) { |
| 2111 | + $this->databaseList = new ListDatabase(); |
| 2112 | + } |
| 2113 | + |
| 2114 | + return $this->databaseList; |
| 2115 | + } |
2111 | 2116 | } |
0 commit comments