Remove the xkana global variable

Replaces it with Export::$xkana static property.

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
Maurício Meneghini Fauth 2025-01-10 14:04:56 -03:00
parent e479d26616
commit bf223b2abd
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
4 changed files with 5 additions and 28 deletions

View File

@ -7566,12 +7566,6 @@ parameters:
count: 2
path: src/Export/Export.php
-
message: '#^Parameter \#3 \$kana of static method PhpMyAdmin\\Encoding\:\:kanjiStrConv\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Export/Export.php
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:

View File

@ -1385,7 +1385,6 @@
<MixedAssignment>
<code><![CDATA[$GLOBALS['save_filename']]]></code>
<code><![CDATA[$GLOBALS['time_start']]]></code>
<code><![CDATA[$GLOBALS['xkana']]]></code>
<code><![CDATA[$dbSelect]]></code>
<code><![CDATA[$tableData]]></code>
<code><![CDATA[$tableNames]]></code>
@ -4613,7 +4612,6 @@
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<MixedArgument>
<code><![CDATA[$GLOBALS['xkana'] ?? '']]></code>
<code><![CDATA[$dbAlias]]></code>
<code><![CDATA[$dbAlias]]></code>
<code><![CDATA[$table]]></code>

View File

@ -52,9 +52,6 @@ final class ExportController implements InvocableController
$GLOBALS['save_filename'] ??= null;
$GLOBALS['time_start'] ??= null;
/** @var array<string, string> $postParams */
$postParams = $request->getParsedBody();
$quickOrCustom = $request->getParsedBodyParamAsStringOrNull('quick_or_custom');
$outputFormat = $request->getParsedBodyParamAsStringOrNull('output_format');
$compressionParam = $request->getParsedBodyParamAsString('compression', '');
@ -101,7 +98,9 @@ final class ExportController implements InvocableController
Export::$tableData = $tableData;
}
$this->setGlobalsFromRequest($postParams);
if ($request->hasBodyParam('xkana')) {
Export::$xkana = $request->getParsedBodyParamAsString('xkana');
}
// sanitize this parameter which will be used below in a file inclusion
$what = Core::securePath($request->getParsedBodyParamAsString('what', ''));
@ -466,19 +465,4 @@ final class ExportController implements InvocableController
return $this->responseFactory->createResponse()->write($this->export->dumpBuffer);
}
/**
* Please keep the parameters in order of their appearance in the form.
* Some of these parameters are not used.
*
* @param mixed[] $postParams
*/
private function setGlobalsFromRequest(array $postParams): void
{
if (! isset($postParams['xkana'])) {
return;
}
$GLOBALS['xkana'] = $postParams['xkana'];
}
}

View File

@ -87,6 +87,7 @@ class Export
/** @var resource|null */
public static mixed $fileHandle = null;
public static string $kanjiEncoding = '';
public static string $xkana = '';
public static string $maxSize = '';
public static int $memoryLimit = 0;
public static bool $onFlyCompression = false;
@ -155,7 +156,7 @@ class Export
// Kanji encoding convert feature
if (self::$outputKanjiConversion) {
$line = Encoding::kanjiStrConv($line, self::$kanjiEncoding, $GLOBALS['xkana'] ?? '');
$line = Encoding::kanjiStrConv($line, self::$kanjiEncoding, self::$xkana);
}
// If we have to buffer data, we will perform everything at once at the end