Remove the compression global variable
Replaces it with Export::$compression static property. Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
parent
17371f0c8d
commit
0ffbe20376
@ -2689,7 +2689,7 @@ parameters:
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
|
||||
message: '#^Only booleans are allowed in an if condition, string given\.$#'
|
||||
identifier: if.condNotBoolean
|
||||
count: 1
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
@ -2712,24 +2712,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$compression of method PhpMyAdmin\\Export\\Export\:\:compress\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 2
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$compression of method PhpMyAdmin\\Export\\Export\:\:getFinalFilename\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 2
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$compression of method PhpMyAdmin\\Export\\Export\:\:getMimeType\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#3 \$saveFilename of method PhpMyAdmin\\Export\\Export\:\:closeFile\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
@ -2754,6 +2736,12 @@ parameters:
|
||||
count: 2
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
message: '#^Static property PhpMyAdmin\\Export\\Export\:\:\$compression \(''''\|''gzip''\|''none''\|''zip''\) does not accept string\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 1
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
|
||||
|
||||
@ -1403,7 +1403,6 @@
|
||||
<code><![CDATA[$_SESSION['tmpval']['aliases']]]></code>
|
||||
</MixedArrayAssignment>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$GLOBALS['compression']]]></code>
|
||||
<code><![CDATA[$GLOBALS['knjenc']]]></code>
|
||||
<code><![CDATA[$GLOBALS['maxsize']]]></code>
|
||||
<code><![CDATA[$GLOBALS['save_filename']]]></code>
|
||||
@ -1429,15 +1428,18 @@
|
||||
<PossiblyInvalidPropertyAssignmentValue>
|
||||
<code><![CDATA[$this->export->compress(
|
||||
$this->export->dumpBuffer,
|
||||
$GLOBALS['compression'],
|
||||
Export::$compression,
|
||||
$filename,
|
||||
)]]></code>
|
||||
<code><![CDATA[$this->export->compress(
|
||||
$this->export->dumpBufferObjects,
|
||||
$GLOBALS['compression'],
|
||||
Export::$compression,
|
||||
$filename,
|
||||
)]]></code>
|
||||
</PossiblyInvalidPropertyAssignmentValue>
|
||||
<PropertyTypeCoercion>
|
||||
<code><![CDATA[$request->getParsedBodyParamAsString('compression')]]></code>
|
||||
</PropertyTypeCoercion>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[$asSeparateFiles]]></code>
|
||||
<code><![CDATA[$onServerParam]]></code>
|
||||
|
||||
@ -39,7 +39,6 @@
|
||||
|
||||
<globals>
|
||||
<var name="GLOBALS" type="array{
|
||||
compression: 'none'|'zip'|'gzip',
|
||||
file_handle: resource|null,
|
||||
from_cookie: bool,
|
||||
knjenc: string,
|
||||
|
||||
@ -49,7 +49,6 @@ final class ExportController implements InvocableController
|
||||
|
||||
public function __invoke(ServerRequest $request): Response
|
||||
{
|
||||
$GLOBALS['compression'] ??= null;
|
||||
$GLOBALS['file_handle'] ??= null;
|
||||
$GLOBALS['save_filename'] ??= null;
|
||||
$GLOBALS['table_select'] ??= null;
|
||||
@ -83,6 +82,10 @@ final class ExportController implements InvocableController
|
||||
Current::$charset = $request->getParsedBodyParamAsString('charset');
|
||||
}
|
||||
|
||||
if ($request->hasBodyParam('compression')) {
|
||||
Export::$compression = $request->getParsedBodyParamAsString('compression');
|
||||
}
|
||||
|
||||
$this->setGlobalsFromRequest($postParams);
|
||||
|
||||
// sanitize this parameter which will be used below in a file inclusion
|
||||
@ -122,7 +125,7 @@ final class ExportController implements InvocableController
|
||||
/**
|
||||
* init and variable checking
|
||||
*/
|
||||
$GLOBALS['compression'] = '';
|
||||
Export::$compression = '';
|
||||
Export::$saveOnServer = false;
|
||||
Export::$bufferNeeded = false;
|
||||
$GLOBALS['save_filename'] = '';
|
||||
@ -142,7 +145,7 @@ final class ExportController implements InvocableController
|
||||
}
|
||||
|
||||
if (in_array($compressionParam, $compressionMethods, true)) {
|
||||
$GLOBALS['compression'] = $compressionParam;
|
||||
Export::$compression = $compressionParam;
|
||||
Export::$bufferNeeded = true;
|
||||
}
|
||||
|
||||
@ -214,8 +217,7 @@ final class ExportController implements InvocableController
|
||||
&& isset(Current::$charset) && Current::$charset !== 'utf-8';
|
||||
|
||||
// Use on the fly compression?
|
||||
$GLOBALS['onfly_compression'] = $config->settings['CompressOnFly']
|
||||
&& $GLOBALS['compression'] === 'gzip';
|
||||
$GLOBALS['onfly_compression'] = $config->settings['CompressOnFly'] && Export::$compression === 'gzip';
|
||||
if ($GLOBALS['onfly_compression']) {
|
||||
$GLOBALS['memory_limit'] = $this->export->getMemoryLimit();
|
||||
}
|
||||
@ -231,16 +233,16 @@ final class ExportController implements InvocableController
|
||||
|
||||
$filename = $this->export->getFinalFilename(
|
||||
$exportPlugin,
|
||||
$GLOBALS['compression'],
|
||||
Export::$compression,
|
||||
Sanitize::sanitizeFilename(Util::expandUserString($filenameTemplate), true),
|
||||
);
|
||||
|
||||
$mimeType = $this->export->getMimeType($exportPlugin, $GLOBALS['compression']);
|
||||
$mimeType = $this->export->getMimeType($exportPlugin, Export::$compression);
|
||||
}
|
||||
|
||||
// For raw query export, filename will be export.extension
|
||||
if ($exportType === ExportType::Raw) {
|
||||
$filename = $this->export->getFinalFilename($exportPlugin, $GLOBALS['compression'], 'export');
|
||||
$filename = $this->export->getFinalFilename($exportPlugin, Export::$compression, 'export');
|
||||
}
|
||||
|
||||
// Open file on server if needed
|
||||
@ -422,17 +424,17 @@ final class ExportController implements InvocableController
|
||||
}
|
||||
|
||||
// Compression needed?
|
||||
if ($GLOBALS['compression']) {
|
||||
if (Export::$compression) {
|
||||
if ($separateFiles !== '') {
|
||||
$this->export->dumpBuffer = $this->export->compress(
|
||||
$this->export->dumpBufferObjects,
|
||||
$GLOBALS['compression'],
|
||||
Export::$compression,
|
||||
$filename,
|
||||
);
|
||||
} else {
|
||||
$this->export->dumpBuffer = $this->export->compress(
|
||||
$this->export->dumpBuffer,
|
||||
$GLOBALS['compression'],
|
||||
Export::$compression,
|
||||
$filename,
|
||||
);
|
||||
}
|
||||
@ -474,10 +476,6 @@ final class ExportController implements InvocableController
|
||||
$GLOBALS['maxsize'] = $postParams['maxsize'];
|
||||
}
|
||||
|
||||
if (isset($postParams['compression'])) {
|
||||
$GLOBALS['compression'] = $postParams['compression'];
|
||||
}
|
||||
|
||||
if (isset($postParams['knjenc'])) {
|
||||
$GLOBALS['knjenc'] = $postParams['knjenc'];
|
||||
}
|
||||
|
||||
@ -81,6 +81,9 @@ class Export
|
||||
public static bool $bufferNeeded = false;
|
||||
public static bool $singleTable = false;
|
||||
|
||||
/** @var ''|'none'|'zip'|'gzip' */
|
||||
public static string $compression = '';
|
||||
|
||||
public function __construct(private DatabaseInterface $dbi)
|
||||
{
|
||||
}
|
||||
@ -161,7 +164,7 @@ class Export
|
||||
);
|
||||
}
|
||||
|
||||
if ($GLOBALS['compression'] === 'gzip' && $this->gzencodeNeeded()) {
|
||||
if (self::$compression === 'gzip' && $this->gzencodeNeeded()) {
|
||||
// as a gzipped file
|
||||
// without the optional parameter level because it bugs
|
||||
$this->dumpBuffer = (string) gzencode($this->dumpBuffer);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user