@@ -154,52 +154,50 @@ private function fillRelationParamsWithTableNames(array $relationParams): array|
154154 }
155155
156156 $ config = Config::getInstance ();
157- $ tabQuery = 'SHOW TABLES FROM '
158- . Util::backquote ($ config ->selectedServer ['pmadb ' ]);
159- $ tableRes = $ this ->dbi ->tryQueryAsControlUser ($ tabQuery );
160- if ($ tableRes === false ) {
157+ $ tables = $ this ->dbi ->getTables ($ config ->selectedServer ['pmadb ' ], Connection::TYPE_CONTROL );
158+ if ($ tables === []) {
161159 return null ;
162160 }
163161
164- while ($ currTable = $ tableRes -> fetchRow () ) {
165- if ($ currTable [ 0 ] == $ config ->selectedServer ['bookmarktable ' ]) {
166- $ relationParams ['bookmark ' ] = ( string ) $ currTable [ 0 ] ;
167- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['relation ' ]) {
168- $ relationParams ['relation ' ] = ( string ) $ currTable [ 0 ] ;
169- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['table_info ' ]) {
170- $ relationParams ['table_info ' ] = ( string ) $ currTable [ 0 ] ;
171- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['table_coords ' ]) {
172- $ relationParams ['table_coords ' ] = ( string ) $ currTable [ 0 ] ;
173- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['column_info ' ]) {
174- $ relationParams ['column_info ' ] = ( string ) $ currTable [ 0 ] ;
175- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['pdf_pages ' ]) {
176- $ relationParams ['pdf_pages ' ] = ( string ) $ currTable [ 0 ] ;
177- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['history ' ]) {
178- $ relationParams ['history ' ] = ( string ) $ currTable [ 0 ] ;
179- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['recent ' ]) {
180- $ relationParams ['recent ' ] = ( string ) $ currTable [ 0 ] ;
181- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['favorite ' ]) {
182- $ relationParams ['favorite ' ] = ( string ) $ currTable [ 0 ] ;
183- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['table_uiprefs ' ]) {
184- $ relationParams ['table_uiprefs ' ] = ( string ) $ currTable [ 0 ] ;
185- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['tracking ' ]) {
186- $ relationParams ['tracking ' ] = ( string ) $ currTable [ 0 ] ;
187- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['userconfig ' ]) {
188- $ relationParams ['userconfig ' ] = ( string ) $ currTable [ 0 ] ;
189- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['users ' ]) {
190- $ relationParams ['users ' ] = ( string ) $ currTable [ 0 ] ;
191- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['usergroups ' ]) {
192- $ relationParams ['usergroups ' ] = ( string ) $ currTable [ 0 ] ;
193- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['navigationhiding ' ]) {
194- $ relationParams ['navigationhiding ' ] = ( string ) $ currTable [ 0 ] ;
195- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['savedsearches ' ]) {
196- $ relationParams ['savedsearches ' ] = ( string ) $ currTable [ 0 ] ;
197- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['central_columns ' ]) {
198- $ relationParams ['central_columns ' ] = ( string ) $ currTable [ 0 ] ;
199- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['designer_settings ' ]) {
200- $ relationParams ['designer_settings ' ] = ( string ) $ currTable [ 0 ] ;
201- } elseif ($ currTable [ 0 ] == $ config ->selectedServer ['export_templates ' ]) {
202- $ relationParams ['export_templates ' ] = ( string ) $ currTable [ 0 ] ;
162+ foreach ($ tables as $ table ) {
163+ if ($ table == $ config ->selectedServer ['bookmarktable ' ]) {
164+ $ relationParams ['bookmark ' ] = $ table ;
165+ } elseif ($ table == $ config ->selectedServer ['relation ' ]) {
166+ $ relationParams ['relation ' ] = $ table ;
167+ } elseif ($ table == $ config ->selectedServer ['table_info ' ]) {
168+ $ relationParams ['table_info ' ] = $ table ;
169+ } elseif ($ table == $ config ->selectedServer ['table_coords ' ]) {
170+ $ relationParams ['table_coords ' ] = $ table ;
171+ } elseif ($ table == $ config ->selectedServer ['column_info ' ]) {
172+ $ relationParams ['column_info ' ] = $ table ;
173+ } elseif ($ table == $ config ->selectedServer ['pdf_pages ' ]) {
174+ $ relationParams ['pdf_pages ' ] = $ table ;
175+ } elseif ($ table == $ config ->selectedServer ['history ' ]) {
176+ $ relationParams ['history ' ] = $ table ;
177+ } elseif ($ table == $ config ->selectedServer ['recent ' ]) {
178+ $ relationParams ['recent ' ] = $ table ;
179+ } elseif ($ table == $ config ->selectedServer ['favorite ' ]) {
180+ $ relationParams ['favorite ' ] = $ table ;
181+ } elseif ($ table == $ config ->selectedServer ['table_uiprefs ' ]) {
182+ $ relationParams ['table_uiprefs ' ] = $ table ;
183+ } elseif ($ table == $ config ->selectedServer ['tracking ' ]) {
184+ $ relationParams ['tracking ' ] = $ table ;
185+ } elseif ($ table == $ config ->selectedServer ['userconfig ' ]) {
186+ $ relationParams ['userconfig ' ] = $ table ;
187+ } elseif ($ table == $ config ->selectedServer ['users ' ]) {
188+ $ relationParams ['users ' ] = $ table ;
189+ } elseif ($ table == $ config ->selectedServer ['usergroups ' ]) {
190+ $ relationParams ['usergroups ' ] = $ table ;
191+ } elseif ($ table == $ config ->selectedServer ['navigationhiding ' ]) {
192+ $ relationParams ['navigationhiding ' ] = $ table ;
193+ } elseif ($ table == $ config ->selectedServer ['savedsearches ' ]) {
194+ $ relationParams ['savedsearches ' ] = $ table ;
195+ } elseif ($ table == $ config ->selectedServer ['central_columns ' ]) {
196+ $ relationParams ['central_columns ' ] = $ table ;
197+ } elseif ($ table == $ config ->selectedServer ['designer_settings ' ]) {
198+ $ relationParams ['designer_settings ' ] = $ table ;
199+ } elseif ($ table == $ config ->selectedServer ['export_templates ' ]) {
200+ $ relationParams ['export_templates ' ] = $ table ;
203201 }
204202 }
205203
@@ -249,7 +247,6 @@ private function checkRelationsParam(): array
249247 || $ config ->selectedServer ['pmadb ' ] === ''
250248 || ! $ this ->dbi ->selectDb ($ config ->selectedServer ['pmadb ' ], Connection::TYPE_CONTROL )
251249 ) {
252- // No server selected -> no bookmark table
253250 $ config ->selectedServer ['pmadb ' ] = '' ;
254251
255252 return $ relationParams ;
@@ -258,22 +255,13 @@ private function checkRelationsParam(): array
258255 $ relationParams ['user ' ] = $ config ->selectedServer ['user ' ];
259256 $ relationParams ['db ' ] = $ config ->selectedServer ['pmadb ' ];
260257
261- // Now I just check if all tables that i need are present so I can for
262- // example enable relations but not pdf...
263- // I was thinking of checking if they have all required columns but I
264- // fear it might be too slow
265-
266258 $ relationParamsFilled = $ this ->fillRelationParamsWithTableNames ($ relationParams );
267259
268260 if ($ relationParamsFilled === null ) {
269- // query failed ... ?
270261 return $ relationParams ;
271262 }
272263
273- // Filling did success
274- $ relationParams = $ relationParamsFilled ;
275-
276- $ relationParams = $ this ->checkTableAccess ($ relationParams );
264+ $ relationParams = $ this ->checkTableAccess ($ relationParamsFilled );
277265
278266 $ allWorks = true ;
279267 foreach ($ workToTable as $ work => $ table ) {
@@ -1553,8 +1541,7 @@ public function fixPmaTables(string $db, bool $create = true): void
15531541
15541542 $ config ->selectedServer ['pmadb ' ] = $ db ;
15551543
1556- //NOTE: I am unsure why we do that, as it defeats the purpose of the session cache
1557- // Unset the cache
1544+ // Unset the cache as new tables might have been added
15581545 self ::$ cache = null ;
15591546 // Fill back the cache
15601547 $ this ->getRelationParameters ();
0 commit comments