diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4a5f043e80..c9172354e2 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2013,7 +2013,6 @@ - @@ -2047,7 +2046,6 @@ - $bookmarkVariables @@ -6685,8 +6683,6 @@ - - @@ -6781,8 +6777,6 @@ - - $active diff --git a/src/Controllers/Import/ImportController.php b/src/Controllers/Import/ImportController.php index 128e2aefea..23f99d8000 100644 --- a/src/Controllers/Import/ImportController.php +++ b/src/Controllers/Import/ImportController.php @@ -81,7 +81,6 @@ final class ImportController extends AbstractController $GLOBALS['error'] ??= null; $GLOBALS['max_sql_len'] ??= null; $GLOBALS['msg'] ??= null; - $GLOBALS['sql_query_disabled'] ??= null; $GLOBALS['executed_queries'] ??= null; $GLOBALS['run_query'] ??= null; $GLOBALS['reset_charset'] ??= null; @@ -287,7 +286,7 @@ final class ImportController extends AbstractController $GLOBALS['offset'] = 0; $GLOBALS['max_sql_len'] = 0; $GLOBALS['sql_query'] = ''; - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; ImportSettings::$goSql = false; $GLOBALS['executed_queries'] = 0; $GLOBALS['run_query'] = true; @@ -494,7 +493,7 @@ final class ImportController extends AbstractController } elseif (ImportSettings::$charsetOfFile !== '' && ImportSettings::$charsetOfFile !== 'utf-8') { $this->dbi->query('SET NAMES \'' . ImportSettings::$charsetOfFile . '\''); // We can not show query in this case, it is in different charset - $GLOBALS['sql_query_disabled'] = true; + ImportSettings::$sqlQueryDisabled = true; $GLOBALS['reset_charset'] = true; } diff --git a/src/Import/Import.php b/src/Import/Import.php index 40c1a3d425..701906d8f6 100644 --- a/src/Import/Import.php +++ b/src/Import/Import.php @@ -130,7 +130,6 @@ class Import { $GLOBALS['error'] ??= null; $GLOBALS['msg'] ??= null; - $GLOBALS['sql_query_disabled'] ??= null; $dbi = DatabaseInterface::getInstance(); $GLOBALS['result'] = $dbi->tryQuery($sql); @@ -167,7 +166,7 @@ class Import } } - if (! $GLOBALS['sql_query_disabled']) { + if (! ImportSettings::$sqlQueryDisabled) { $GLOBALS['sql_query'] .= $GLOBALS['msg'] . "\n"; } @@ -204,7 +203,6 @@ class Import $GLOBALS['skip_queries'] ??= null; $GLOBALS['executed_queries'] ??= null; $GLOBALS['max_sql_len'] ??= null; - $GLOBALS['sql_query_disabled'] ??= null; $GLOBALS['run_query'] ??= null; ImportSettings::$readMultiply = 1; @@ -228,7 +226,7 @@ class Import $GLOBALS['max_sql_len'], mb_strlen($this->importRunBuffer), ); - if (! $GLOBALS['sql_query_disabled']) { + if (! ImportSettings::$sqlQueryDisabled) { $GLOBALS['sql_query'] .= $this->importRunBuffer; } @@ -237,7 +235,7 @@ class Import if ($GLOBALS['run_query'] && $GLOBALS['executed_queries'] < 50) { ImportSettings::$goSql = true; - if (! $GLOBALS['sql_query_disabled']) { + if (! ImportSettings::$sqlQueryDisabled) { $GLOBALS['complete_query'] = $GLOBALS['sql_query']; $GLOBALS['display_query'] = $GLOBALS['sql_query']; } else { @@ -272,7 +270,7 @@ class Import || $GLOBALS['max_sql_len'] > 1000 ) { $GLOBALS['sql_query'] = ''; - $GLOBALS['sql_query_disabled'] = true; + ImportSettings::$sqlQueryDisabled = true; } } diff --git a/src/Import/ImportSettings.php b/src/Import/ImportSettings.php index 43f0a8a334..52e8d44096 100644 --- a/src/Import/ImportSettings.php +++ b/src/Import/ImportSettings.php @@ -11,4 +11,5 @@ final class ImportSettings public static int $readMultiply = 0; public static int $readLimit = 0; public static bool $goSql = false; + public static bool $sqlQueryDisabled = false; } diff --git a/tests/classes/Import/ImportTest.php b/tests/classes/Import/ImportTest.php index 45d35ae23a..0f239f2b49 100644 --- a/tests/classes/Import/ImportTest.php +++ b/tests/classes/Import/ImportTest.php @@ -8,6 +8,7 @@ use PhpMyAdmin\Config; use PhpMyAdmin\Current; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\Import\Import; +use PhpMyAdmin\Import\ImportSettings; use PhpMyAdmin\Tests\AbstractTestCase; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -34,7 +35,7 @@ class ImportTest extends AbstractTestCase $GLOBALS['display_query'] = null; $GLOBALS['skip_queries'] = null; $GLOBALS['max_sql_len'] = null; - $GLOBALS['sql_query_disabled'] = null; + ImportSettings::$sqlQueryDisabled = false; $GLOBALS['executed_queries'] = null; $this->import = new Import(); } diff --git a/tests/classes/Plugins/Import/ImportCsvTest.php b/tests/classes/Plugins/Import/ImportCsvTest.php index d7f4fc5838..0d64b22abb 100644 --- a/tests/classes/Plugins/Import/ImportCsvTest.php +++ b/tests/classes/Plugins/Import/ImportCsvTest.php @@ -121,7 +121,7 @@ class ImportCsvTest extends AbstractTestCase { //$sql_query_disabled will show the import SQL detail - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; $importHandle = new File($GLOBALS['import_file']); $importHandle->open(); @@ -150,7 +150,7 @@ class ImportCsvTest extends AbstractTestCase { //$sql_query_disabled will show the import SQL detail - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; $importHandle = new File($GLOBALS['import_file']); $importHandle->open(); @@ -207,7 +207,7 @@ class ImportCsvTest extends AbstractTestCase { //$sql_query_disabled will show the import SQL detail - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; $importHandle = new File($GLOBALS['import_file']); $importHandle->open(); @@ -237,7 +237,7 @@ class ImportCsvTest extends AbstractTestCase { //$sql_query_disabled will show the import SQL detail - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; $GLOBALS['import_type'] = 'query'; $GLOBALS['import_file'] = 'none'; $GLOBALS['csv_terminated'] = ','; @@ -280,7 +280,7 @@ class ImportCsvTest extends AbstractTestCase { //$sql_query_disabled will show the import SQL detail - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; $GLOBALS['import_type'] = 'query'; $GLOBALS['import_file'] = 'none'; $GLOBALS['csv_terminated'] = ','; diff --git a/tests/classes/Plugins/Import/ImportLdiTest.php b/tests/classes/Plugins/Import/ImportLdiTest.php index d013a87b17..fa3211f7a7 100644 --- a/tests/classes/Plugins/Import/ImportLdiTest.php +++ b/tests/classes/Plugins/Import/ImportLdiTest.php @@ -125,7 +125,7 @@ class ImportLdiTest extends AbstractTestCase { //$sql_query_disabled will show the import SQL detail - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; $dbi = self::createMock(DatabaseInterface::class); $dbi->expects(self::any())->method('quoteString') ->willReturnCallback(static fn (string $string): string => "'" . $string . "'"); @@ -174,7 +174,7 @@ class ImportLdiTest extends AbstractTestCase { //$sql_query_disabled will show the import SQL detail - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; $dbi = self::createMock(DatabaseInterface::class); $dbi->expects(self::any())->method('quoteString') ->willReturnCallback(static fn (string $string): string => "'" . $string . "'"); diff --git a/tests/classes/Plugins/Import/ImportMediawikiTest.php b/tests/classes/Plugins/Import/ImportMediawikiTest.php index f58b7e23e3..467b945282 100644 --- a/tests/classes/Plugins/Import/ImportMediawikiTest.php +++ b/tests/classes/Plugins/Import/ImportMediawikiTest.php @@ -37,7 +37,7 @@ class ImportMediawikiTest extends AbstractTestCase Current::$database = ''; $GLOBALS['skip_queries'] = null; $GLOBALS['max_sql_len'] = null; - $GLOBALS['sql_query_disabled'] = null; + ImportSettings::$sqlQueryDisabled = false; $GLOBALS['sql_query'] = ''; $GLOBALS['executed_queries'] = null; $GLOBALS['run_query'] = null; diff --git a/tests/classes/Plugins/Import/ImportOdsTest.php b/tests/classes/Plugins/Import/ImportOdsTest.php index 65e204d430..dc11d32bda 100644 --- a/tests/classes/Plugins/Import/ImportOdsTest.php +++ b/tests/classes/Plugins/Import/ImportOdsTest.php @@ -111,7 +111,7 @@ class ImportOdsTest extends AbstractTestCase //$sql_query_disabled will show the import SQL detail //$import_notice will show the import detail result - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; $GLOBALS['import_file'] = 'tests/test_data/db_test.ods'; $_REQUEST['ods_empty_rows'] = true; @@ -168,7 +168,7 @@ class ImportOdsTest extends AbstractTestCase //$sql_query_disabled will show the import SQL detail //$import_notice will show the import detail result - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; $GLOBALS['import_file'] = 'tests/test_data/import-slim.ods.xml'; $_REQUEST['ods_col_names'] = true; diff --git a/tests/classes/Plugins/Import/ImportShpTest.php b/tests/classes/Plugins/Import/ImportShpTest.php index b43e5ca7fb..25febe9935 100644 --- a/tests/classes/Plugins/Import/ImportShpTest.php +++ b/tests/classes/Plugins/Import/ImportShpTest.php @@ -130,7 +130,7 @@ class ImportShpTest extends AbstractTestCase //$sql_query_disabled will show the import SQL detail //$import_notice will show the import detail result - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; Current::$database = ''; //Test function called @@ -165,7 +165,7 @@ class ImportShpTest extends AbstractTestCase //$sql_query_disabled will show the import SQL detail //$import_notice will show the import detail result - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; Current::$database = ''; //Test function called diff --git a/tests/classes/Plugins/Import/ImportSqlTest.php b/tests/classes/Plugins/Import/ImportSqlTest.php index 0fb6e1fa96..4fe911cdda 100644 --- a/tests/classes/Plugins/Import/ImportSqlTest.php +++ b/tests/classes/Plugins/Import/ImportSqlTest.php @@ -72,7 +72,7 @@ class ImportSqlTest extends AbstractTestCase { //$sql_query_disabled will show the import SQL detail - $GLOBALS['sql_query_disabled'] = false; + ImportSettings::$sqlQueryDisabled = false; //Mock DBI $dbi = $this->getMockBuilder(DatabaseInterface::class) diff --git a/tests/classes/Plugins/Import/ImportXmlTest.php b/tests/classes/Plugins/Import/ImportXmlTest.php index 7ba43042f1..8dbfbc6524 100644 --- a/tests/classes/Plugins/Import/ImportXmlTest.php +++ b/tests/classes/Plugins/Import/ImportXmlTest.php @@ -40,7 +40,7 @@ class ImportXmlTest extends AbstractTestCase Current::$database = ''; $GLOBALS['skip_queries'] = null; $GLOBALS['max_sql_len'] = null; - $GLOBALS['sql_query_disabled'] = null; + ImportSettings::$sqlQueryDisabled = false; $GLOBALS['sql_query'] = ''; $GLOBALS['executed_queries'] = null; $GLOBALS['run_query'] = null;