Remove the output_charset_conversion global variable
Replaces it with Export::$outputCharsetConversion static property. Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
parent
0958b972c9
commit
716c4bb9d3
@ -2691,7 +2691,7 @@ parameters:
|
||||
-
|
||||
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
|
||||
identifier: if.condNotBoolean
|
||||
count: 2
|
||||
count: 1
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
@ -7635,7 +7635,7 @@ parameters:
|
||||
-
|
||||
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
|
||||
identifier: if.condNotBoolean
|
||||
count: 5
|
||||
count: 3
|
||||
path: src/Export/Export.php
|
||||
|
||||
-
|
||||
@ -12153,12 +12153,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportXml.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in a ternary operator condition, mixed given\.$#'
|
||||
identifier: ternary.condNotBoolean
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportXml.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
|
||||
@ -54,7 +54,6 @@
|
||||
memory_limit: int,
|
||||
old_tz: string,
|
||||
onfly_compression: bool,
|
||||
output_charset_conversion: bool,
|
||||
output_kanji_conversion: bool,
|
||||
plugin_scripts: string[],
|
||||
pma_auth_server: string,
|
||||
|
||||
@ -52,7 +52,6 @@ final class ExportController implements InvocableController
|
||||
$GLOBALS['compression'] ??= null;
|
||||
$GLOBALS['buffer_needed'] ??= null;
|
||||
$GLOBALS['file_handle'] ??= null;
|
||||
$GLOBALS['output_charset_conversion'] ??= null;
|
||||
$GLOBALS['output_kanji_conversion'] ??= null;
|
||||
$GLOBALS['single_table'] ??= null;
|
||||
$GLOBALS['save_filename'] ??= null;
|
||||
@ -206,7 +205,7 @@ final class ExportController implements InvocableController
|
||||
$GLOBALS['output_kanji_conversion'] = Encoding::canConvertKanji();
|
||||
|
||||
// Do we need to convert charset?
|
||||
$GLOBALS['output_charset_conversion'] = Export::$asFile
|
||||
Export::$outputCharsetConversion = Export::$asFile
|
||||
&& Encoding::isSupported()
|
||||
&& isset($GLOBALS['charset']) && $GLOBALS['charset'] !== 'utf-8';
|
||||
|
||||
@ -410,7 +409,7 @@ final class ExportController implements InvocableController
|
||||
}
|
||||
|
||||
// Convert the charset if required.
|
||||
if ($GLOBALS['output_charset_conversion']) {
|
||||
if (Export::$outputCharsetConversion) {
|
||||
$this->export->dumpBuffer = Encoding::convertString(
|
||||
'utf-8',
|
||||
$GLOBALS['charset'],
|
||||
|
||||
@ -76,6 +76,7 @@ class Export
|
||||
|
||||
public static bool $asFile = false;
|
||||
public static bool $saveOnServer = false;
|
||||
public static bool $outputCharsetConversion = false;
|
||||
|
||||
public function __construct(private DatabaseInterface $dbi)
|
||||
{
|
||||
@ -149,7 +150,7 @@ class Export
|
||||
$this->dumpBufferLength += strlen($line);
|
||||
|
||||
if ($this->dumpBufferLength > $GLOBALS['memory_limit']) {
|
||||
if ($GLOBALS['output_charset_conversion']) {
|
||||
if (self::$outputCharsetConversion) {
|
||||
$this->dumpBuffer = Encoding::convertString('utf-8', $GLOBALS['charset'], $this->dumpBuffer);
|
||||
}
|
||||
|
||||
@ -186,7 +187,7 @@ class Export
|
||||
}
|
||||
}
|
||||
} elseif (self::$asFile) {
|
||||
if ($GLOBALS['output_charset_conversion']) {
|
||||
if (self::$outputCharsetConversion) {
|
||||
$line = Encoding::convertString('utf-8', $GLOBALS['charset'], $line);
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\Database\Events;
|
||||
use PhpMyAdmin\Database\Routines;
|
||||
use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\StructureOrData;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
@ -193,7 +194,7 @@ class ExportXml extends ExportPlugin
|
||||
|| $this->exportTriggers
|
||||
|| $this->exportViews;
|
||||
|
||||
$charset = $GLOBALS['output_charset_conversion'] ? $GLOBALS['charset'] : 'utf-8';
|
||||
$charset = Export::$outputCharsetConversion ? $GLOBALS['charset'] : 'utf-8';
|
||||
|
||||
$config = Config::getInstance();
|
||||
$head = '<?xml version="1.0" encoding="' . $charset . '"?>' . "\n"
|
||||
|
||||
@ -168,7 +168,7 @@ class ExportCodegenTest extends AbstractTestCase
|
||||
public function testExportData(): void
|
||||
{
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -259,7 +259,7 @@ class ExportCsvTest extends AbstractTestCase
|
||||
{
|
||||
// case 1
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = true;
|
||||
@ -275,7 +275,7 @@ class ExportCsvTest extends AbstractTestCase
|
||||
|
||||
// case 2
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -220,7 +220,7 @@ class ExportExcelTest extends AbstractTestCase
|
||||
{
|
||||
// case 1
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = true;
|
||||
@ -236,7 +236,7 @@ class ExportExcelTest extends AbstractTestCase
|
||||
|
||||
// case 2
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -63,7 +63,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
new Transformations(),
|
||||
);
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
@ -293,7 +293,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
{
|
||||
// case 1
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -36,7 +36,7 @@ class ExportJsonTest extends AbstractTestCase
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -49,7 +49,7 @@ class ExportLatexTest extends AbstractTestCase
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -44,7 +44,7 @@ class ExportMediawikiTest extends AbstractTestCase
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -53,7 +53,7 @@ class ExportOdsTest extends AbstractTestCase
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -68,7 +68,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
|
||||
DatabaseInterface::$instance = $this->dbi;
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -39,7 +39,7 @@ class ExportPdfTest extends AbstractTestCase
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -39,7 +39,7 @@ class ExportPhparrayTest extends AbstractTestCase
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$GLOBALS['output_kanji_conversion'] = false;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
|
||||
@ -389,7 +389,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['charset'] = 'utf-8';
|
||||
$GLOBALS['old_tz'] = 'GMT';
|
||||
Export::$asFile = true;
|
||||
$GLOBALS['output_charset_conversion'] = 'utf-8';
|
||||
Export::$outputCharsetConversion = true;
|
||||
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
@ -420,7 +420,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$config->selectedServer['port'] = 80;
|
||||
$GLOBALS['old_tz'] = 'GMT';
|
||||
Export::$asFile = true;
|
||||
$GLOBALS['output_charset_conversion'] = 'utf-8';
|
||||
Export::$outputCharsetConversion = true;
|
||||
$GLOBALS['charset'] = 'utf-8';
|
||||
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
|
||||
@ -171,7 +171,7 @@ class ExportXmlTest extends AbstractTestCase
|
||||
|
||||
public function testExportHeader(): void
|
||||
{
|
||||
$GLOBALS['output_charset_conversion'] = 1;
|
||||
Export::$outputCharsetConversion = true;
|
||||
$GLOBALS['charset'] = 'iso-8859-1';
|
||||
$config = Config::getInstance();
|
||||
$config->selectedServer['port'] = 80;
|
||||
@ -283,7 +283,7 @@ class ExportXmlTest extends AbstractTestCase
|
||||
|
||||
// case 2 with isView as true and false
|
||||
|
||||
$GLOBALS['output_charset_conversion'] = 0;
|
||||
Export::$outputCharsetConversion = false;
|
||||
|
||||
$dbiDummy->addResult(
|
||||
'SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME`'
|
||||
@ -401,7 +401,7 @@ class ExportXmlTest extends AbstractTestCase
|
||||
public function testExportData(): void
|
||||
{
|
||||
Export::$asFile = true;
|
||||
$GLOBALS['output_charset_conversion'] = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['xml_export_contents' => 'On']);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user