44
55namespace PhpMyAdmin ;
66
7+ use PhpMyAdmin \SqlParser \Statements \AlterStatement ;
8+ use PhpMyAdmin \SqlParser \Statements \CreateStatement ;
9+ use PhpMyAdmin \SqlParser \Statements \DropStatement ;
710use PhpMyAdmin \SqlParser \Utils \Query ;
811use PhpMyAdmin \SqlParser \Utils \StatementInfo ;
912
@@ -21,15 +24,18 @@ class ParseAnalyze
2124 * @param string $sqlQuery the query to parse
2225 * @param string $db the current database
2326 *
24- * @return array<int, StatementInfo|string>
25- * @psalm-return array{StatementInfo, string, string}
27+ * @return array{StatementInfo, string, string, bool}
2628 */
2729 public static function sqlQuery (string $ sqlQuery , string $ db ): array
2830 {
2931 $ info = Query::getAll ($ sqlQuery );
3032
3133 $ table = '' ;
3234
35+ $ reload = $ info ->statement instanceof AlterStatement
36+ || $ info ->statement instanceof CreateStatement
37+ || $ info ->statement instanceof DropStatement;
38+
3339 // If the targeted table (and database) are different than the ones that is
3440 // currently browsed, edit `$db` and `$table` to match them so other elements
3541 // (page headers, links, navigation panel) can be updated properly.
@@ -55,12 +61,12 @@ public static function sqlQuery(string $sqlQuery, string $db): array
5561 // There is no point checking if a reloading is required if we already decided
5662 // to reload. Also, no reload is required for AJAX requests.
5763 $ response = ResponseRenderer::getInstance ();
58- if (! $ info -> flags -> reload && ! $ response ->isAjax ()) {
64+ if (! $ reload && ! $ response ->isAjax ()) {
5965 // NOTE: Database names are case-insensitive.
60- $ info -> flags -> reload = strcasecmp ($ db , $ previousDb ) !== 0 ;
66+ $ reload = strcasecmp ($ db , $ previousDb ) !== 0 ;
6167 }
6268 }
6369
64- return [$ info , $ db , $ table ];
70+ return [$ info , $ db , $ table, $ reload ];
6571 }
6672}
0 commit comments