OutputHandler
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
73f870ad4a
commit
13b34aa471
@ -2181,30 +2181,12 @@ parameters:
|
||||
count: 1
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$fileHandle of method PhpMyAdmin\\Export\\Export\:\:closeFile\(\) expects resource, resource\|null given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#3 \$tableStructure of method PhpMyAdmin\\Export\\Export\:\:exportDatabase\(\) expects array\<string\>, array\<mixed\> given\.$#'
|
||||
identifier: argument.type
|
||||
count: 2
|
||||
path: src/Controllers/Export/ExportController.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Export\\Export\:\:\$dumpBuffer \(string\) does not accept array\|bool\|string\.$#'
|
||||
identifier: assign.propertyType
|
||||
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: '#^Static property PhpMyAdmin\\Export\\Export\:\:\$tableData \(array\<string\>\) does not accept array\<mixed, mixed\>\.$#'
|
||||
identifier: assign.propertyType
|
||||
@ -6165,30 +6147,12 @@ parameters:
|
||||
count: 4
|
||||
path: src/Export/Export.php
|
||||
|
||||
-
|
||||
message: '#^Method PhpMyAdmin\\Export\\Export\:\:compress\(\) return type has no value type specified in iterable type array\.$#'
|
||||
identifier: missingType.iterableValue
|
||||
count: 1
|
||||
path: src/Export/Export.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in a negated boolean, string\|false given\.$#'
|
||||
identifier: booleanNot.exprNotBoolean
|
||||
count: 1
|
||||
path: src/Export/Export.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$identifier of static method PhpMyAdmin\\Util\:\:backquote\(\) expects string\|Stringable\|null, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Export/Export.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$stream of function fwrite expects resource, resource\|null given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Export/Export.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$dbAlias of method PhpMyAdmin\\Plugins\\ExportPlugin\:\:exportDBCreate\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
@ -6261,6 +6225,18 @@ parameters:
|
||||
count: 1
|
||||
path: src/Export/Options.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in a negated boolean, string\|false given\.$#'
|
||||
identifier: booleanNot.exprNotBoolean
|
||||
count: 1
|
||||
path: src/Export/OutputHandler.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Export\\OutputHandler\:\:\$dumpBuffer \(string\) does not accept string\|false\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 2
|
||||
path: src/Export/OutputHandler.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$id of class PhpMyAdmin\\Export\\Template constructor expects int, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
@ -9460,13 +9436,7 @@ parameters:
|
||||
path: src/Plugins/Export/ExportPdf.php
|
||||
|
||||
-
|
||||
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
|
||||
identifier: empty.notAllowed
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportPdf.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$line of method PhpMyAdmin\\Export\\Export\:\:outputHandler\(\) expects string, mixed given\.$#'
|
||||
message: '#^Parameter \#1 \$line of callable PhpMyAdmin\\Export\\OutputHandler expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportPdf.php
|
||||
|
||||
@ -1275,32 +1275,6 @@
|
||||
<MixedPropertyTypeCoercion>
|
||||
<code><![CDATA[$tableData]]></code>
|
||||
</MixedPropertyTypeCoercion>
|
||||
<PossiblyInvalidArgument>
|
||||
<code><![CDATA[$this->export->dumpBuffer]]></code>
|
||||
<code><![CDATA[$this->export->dumpBuffer]]></code>
|
||||
</PossiblyInvalidArgument>
|
||||
<PossiblyInvalidCast>
|
||||
<code><![CDATA[$this->export->dumpBuffer]]></code>
|
||||
<code><![CDATA[$this->export->dumpBuffer]]></code>
|
||||
</PossiblyInvalidCast>
|
||||
<PossiblyInvalidPropertyAssignmentValue>
|
||||
<code><![CDATA[$this->export->compress(
|
||||
$this->export->dumpBuffer,
|
||||
Export::$compression,
|
||||
$filename,
|
||||
)]]></code>
|
||||
<code><![CDATA[$this->export->compress(
|
||||
$this->export->dumpBufferObjects,
|
||||
Export::$compression,
|
||||
$filename,
|
||||
)]]></code>
|
||||
</PossiblyInvalidPropertyAssignmentValue>
|
||||
<PossiblyNullArgument>
|
||||
<code><![CDATA[Export::$fileHandle]]></code>
|
||||
</PossiblyNullArgument>
|
||||
<PropertyTypeCoercion>
|
||||
<code><![CDATA[$request->getParsedBodyParamAsString('compression')]]></code>
|
||||
</PropertyTypeCoercion>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[$asSeparateFiles]]></code>
|
||||
<code><![CDATA[$onServerParam]]></code>
|
||||
@ -4186,14 +4160,10 @@
|
||||
<MixedOperand>
|
||||
<code><![CDATA[$tmpSelect]]></code>
|
||||
</MixedOperand>
|
||||
<PossiblyNullArgument>
|
||||
<code><![CDATA[self::$fileHandle]]></code>
|
||||
</PossiblyNullArgument>
|
||||
<PossiblyNullArrayAccess>
|
||||
<code><![CDATA[$error['message']]]></code>
|
||||
</PossiblyNullArrayAccess>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[! ini_get('zlib.output_compression')]]></code>
|
||||
<code><![CDATA[empty($_POST['onserver_overwrite'])]]></code>
|
||||
<code><![CDATA[empty($postParams['structure_or_data_forced'])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
@ -4221,6 +4191,17 @@
|
||||
<code><![CDATA[empty($config->settings['SaveDir'])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Export/OutputHandler.php">
|
||||
<InvalidPropertyAssignmentValue>
|
||||
<code><![CDATA[$this->fileHandle]]></code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<PossiblyFalsePropertyAssignmentValue>
|
||||
<code><![CDATA[$zipExtension->createFile($dumpBuffer, $filename)]]></code>
|
||||
</PossiblyFalsePropertyAssignmentValue>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[! ini_get('zlib.output_compression')]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Export/Template.php">
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$state['data']]]></code>
|
||||
@ -6161,17 +6142,14 @@
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$pdf->getPDFData()]]></code>
|
||||
<code><![CDATA[$this->pdf->getPDFData()]]></code>
|
||||
</MixedArgument>
|
||||
<PossiblyInvalidPropertyAssignmentValue>
|
||||
<code><![CDATA[$_POST['pdf_report_title']]]></code>
|
||||
</PossiblyInvalidPropertyAssignmentValue>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$this->pdfReportTitle]]></code>
|
||||
</MixedAssignment>
|
||||
<PropertyNotSetInConstructor>
|
||||
<code><![CDATA[$pdf]]></code>
|
||||
</PropertyNotSetInConstructor>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[empty($_POST['pdf_report_title'])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportPhparray.php">
|
||||
<DeprecatedMethod>
|
||||
|
||||
@ -13,6 +13,7 @@ use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Encoding;
|
||||
use PhpMyAdmin\Exceptions\ExportException;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ResponseFactory;
|
||||
use PhpMyAdmin\Http\Response;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
@ -76,12 +77,8 @@ final readonly class ExportController implements InvocableController
|
||||
Current::$charset = $request->getParsedBodyParamAsString('charset');
|
||||
}
|
||||
|
||||
if ($request->hasBodyParam('compression')) {
|
||||
Export::$compression = $request->getParsedBodyParamAsString('compression');
|
||||
}
|
||||
|
||||
if ($request->hasBodyParam('knjenc')) {
|
||||
Export::$kanjiEncoding = $request->getParsedBodyParamAsString('knjenc');
|
||||
$this->export->outputHandler->kanjiEncoding = $request->getParsedBodyParamAsString('knjenc');
|
||||
}
|
||||
|
||||
if ($request->hasBodyParam('maxsize')) {
|
||||
@ -99,7 +96,7 @@ final readonly class ExportController implements InvocableController
|
||||
}
|
||||
|
||||
if ($request->hasBodyParam('xkana')) {
|
||||
Export::$xkana = $request->getParsedBodyParamAsString('xkana');
|
||||
$this->export->outputHandler->xkana = $request->getParsedBodyParamAsString('xkana');
|
||||
}
|
||||
|
||||
// sanitize this parameter which will be used below in a file inclusion
|
||||
@ -138,11 +135,6 @@ final readonly class ExportController implements InvocableController
|
||||
/**
|
||||
* init and variable checking
|
||||
*/
|
||||
Export::$compression = '';
|
||||
Export::$saveOnServer = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$saveFilename = '';
|
||||
Export::$fileHandle = null;
|
||||
$filename = '';
|
||||
$separateFiles = '';
|
||||
|
||||
@ -150,21 +142,21 @@ final readonly class ExportController implements InvocableController
|
||||
$isQuickExport = $quickOrCustom === 'quick';
|
||||
|
||||
if ($outputFormat === 'astext') {
|
||||
Export::$asFile = false;
|
||||
OutputHandler::$asFile = false;
|
||||
} else {
|
||||
Export::$asFile = true;
|
||||
OutputHandler::$asFile = true;
|
||||
if ($asSeparateFiles && $compressionParam === 'zip') {
|
||||
$separateFiles = $asSeparateFiles;
|
||||
}
|
||||
|
||||
if (in_array($compressionParam, $compressionMethods, true)) {
|
||||
Export::$compression = $compressionParam;
|
||||
Export::$bufferNeeded = true;
|
||||
$this->export->outputHandler->compression = $compressionParam;
|
||||
$this->export->outputHandler->bufferNeeded = true;
|
||||
}
|
||||
|
||||
if (($isQuickExport && $quickExportOnServer) || (! $isQuickExport && $onServerParam)) {
|
||||
// Will we save dump on server?
|
||||
Export::$saveOnServer = $this->config->settings['SaveDir'] !== '';
|
||||
$this->export->outputHandler->saveOnServer = $this->config->settings['SaveDir'] !== '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,33 +204,27 @@ final readonly class ExportController implements InvocableController
|
||||
}
|
||||
|
||||
register_shutdown_function([$this->export, 'shutdown']);
|
||||
// Start with empty buffer
|
||||
$this->export->dumpBuffer = '';
|
||||
$this->export->dumpBufferLength = 0;
|
||||
|
||||
// Array of dump buffers - used in separate file exports
|
||||
$this->export->dumpBufferObjects = [];
|
||||
|
||||
// We send fake headers to avoid browser timeout when buffering
|
||||
Export::$timeStart = time();
|
||||
$this->export->outputHandler->timeStart = time();
|
||||
|
||||
Export::$outputKanjiConversion = Encoding::canConvertKanji();
|
||||
$this->export->outputHandler->outputKanjiConversion = Encoding::canConvertKanji();
|
||||
|
||||
// Do we need to convert charset?
|
||||
Export::$outputCharsetConversion = Export::$asFile
|
||||
$this->export->outputHandler->outputCharsetConversion = OutputHandler::$asFile
|
||||
&& Encoding::isSupported()
|
||||
&& isset(Current::$charset) && Current::$charset !== 'utf-8'
|
||||
&& in_array(Current::$charset, Encoding::listEncodings(), true);
|
||||
|
||||
// Use on the fly compression?
|
||||
Export::$onFlyCompression = $this->config->settings['CompressOnFly'] && Export::$compression === 'gzip';
|
||||
if (Export::$onFlyCompression) {
|
||||
Export::$memoryLimit = $this->export->getMemoryLimit();
|
||||
$this->export->outputHandler->onFlyCompression = $this->config->settings['CompressOnFly'] && ($this->export->outputHandler)->compression === 'gzip';
|
||||
if ($this->export->outputHandler->onFlyCompression) {
|
||||
$this->export->outputHandler->memoryLimit = $this->export->getMemoryLimit();
|
||||
}
|
||||
|
||||
// Generate filename and mime type if needed
|
||||
$mimeType = '';
|
||||
if (Export::$asFile) {
|
||||
if (OutputHandler::$asFile) {
|
||||
$filenameTemplate = $request->getParsedBodyParamAsString('filename_template', '');
|
||||
|
||||
if ((bool) $rememberTemplate) {
|
||||
@ -247,21 +233,21 @@ final readonly class ExportController implements InvocableController
|
||||
|
||||
$filename = $this->export->getFinalFilename(
|
||||
$exportPlugin,
|
||||
Export::$compression,
|
||||
$this->export->outputHandler->compression,
|
||||
Sanitize::sanitizeFilename(Util::expandUserString($filenameTemplate), true),
|
||||
);
|
||||
|
||||
$mimeType = $this->export->getMimeType($exportPlugin, Export::$compression);
|
||||
$mimeType = $this->export->getMimeType($exportPlugin, $this->export->outputHandler->compression);
|
||||
}
|
||||
|
||||
// For raw query export, filename will be export.extension
|
||||
if ($exportType === ExportType::Raw) {
|
||||
$filename = $this->export->getFinalFilename($exportPlugin, Export::$compression, 'export');
|
||||
$filename = $this->export->getFinalFilename($exportPlugin, $this->export->outputHandler->compression, 'export');
|
||||
}
|
||||
|
||||
// Open file on server if needed
|
||||
if (Export::$saveOnServer) {
|
||||
[Export::$saveFilename, $message, Export::$fileHandle] = $this->export->openFile($filename, $isQuickExport);
|
||||
if ($this->export->outputHandler->saveOnServer) {
|
||||
$message = $this->export->openFile($filename, $isQuickExport);
|
||||
|
||||
// problem opening export file on server?
|
||||
if ($message !== null) {
|
||||
@ -270,7 +256,7 @@ final readonly class ExportController implements InvocableController
|
||||
|
||||
return $this->response->response();
|
||||
}
|
||||
} elseif (Export::$asFile) {
|
||||
} elseif (OutputHandler::$asFile) {
|
||||
/**
|
||||
* Send headers depending on whether the user chose to download a dump file
|
||||
* or not
|
||||
@ -300,8 +286,7 @@ final readonly class ExportController implements InvocableController
|
||||
|
||||
try {
|
||||
// Re - initialize
|
||||
$this->export->dumpBuffer = '';
|
||||
$this->export->dumpBufferLength = 0;
|
||||
$this->export->outputHandler->clearBuffer();
|
||||
|
||||
// TODO: This is a temporary hack to avoid GLOBALS. Replace this with something better.
|
||||
if ($exportPlugin instanceof ExportXml) {
|
||||
@ -404,7 +389,7 @@ final readonly class ExportController implements InvocableController
|
||||
// Ignore
|
||||
}
|
||||
|
||||
if (Export::$saveOnServer && Current::$message !== null) {
|
||||
if ($this->export->outputHandler->saveOnServer && Current::$message !== null) {
|
||||
$location = $this->export->getPageLocationAndSaveMessage($exportType, Current::$message);
|
||||
$this->response->redirect($location);
|
||||
|
||||
@ -414,47 +399,27 @@ final readonly class ExportController implements InvocableController
|
||||
/**
|
||||
* Send the dump as a file...
|
||||
*/
|
||||
if (! Export::$asFile) {
|
||||
if (! OutputHandler::$asFile) {
|
||||
echo $this->export->getHtmlForDisplayedExportFooter($exportType, Current::$database, Current::$table);
|
||||
|
||||
return $this->response->response();
|
||||
}
|
||||
|
||||
// Convert the charset if required.
|
||||
if (Export::$outputCharsetConversion) {
|
||||
$this->export->dumpBuffer = Encoding::convertString(
|
||||
'utf-8',
|
||||
Current::$charset ?? 'utf-8',
|
||||
$this->export->dumpBuffer,
|
||||
);
|
||||
}
|
||||
($this->export->outputHandler)->convertBufferCharset();
|
||||
|
||||
// Compression needed?
|
||||
if (Export::$compression !== '') {
|
||||
if ($separateFiles !== '') {
|
||||
$this->export->dumpBuffer = $this->export->compress(
|
||||
$this->export->dumpBufferObjects,
|
||||
Export::$compression,
|
||||
$filename,
|
||||
);
|
||||
} else {
|
||||
$this->export->dumpBuffer = $this->export->compress(
|
||||
$this->export->dumpBuffer,
|
||||
Export::$compression,
|
||||
$filename,
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->export->outputHandler->compress($separateFiles !== '', $filename);
|
||||
|
||||
/* If we saved on server, we have to close file now */
|
||||
if (Export::$saveOnServer) {
|
||||
$message = $this->export->closeFile(Export::$fileHandle, $this->export->dumpBuffer, Export::$saveFilename);
|
||||
if ($this->export->outputHandler->saveOnServer) {
|
||||
$message = $this->export->outputHandler->closeFile();
|
||||
$location = $this->export->getPageLocationAndSaveMessage($exportType, $message);
|
||||
$this->response->redirect($location);
|
||||
|
||||
return $this->response->response();
|
||||
}
|
||||
|
||||
return $this->responseFactory->createResponse()->write($this->export->dumpBuffer);
|
||||
return $this->responseFactory->createResponse()->write($this->export->outputHandler->getBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,15 +9,12 @@ namespace PhpMyAdmin\Export;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Encoding;
|
||||
use PhpMyAdmin\Exceptions\ExportException;
|
||||
use PhpMyAdmin\FlashMessenger;
|
||||
use PhpMyAdmin\Identifiers\DatabaseName;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\MessageType;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Export\ExportSql;
|
||||
use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
@ -26,22 +23,14 @@ use PhpMyAdmin\Plugins\SchemaPlugin;
|
||||
use PhpMyAdmin\Table\Table;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
use PhpMyAdmin\Utils\UserAgentParser;
|
||||
use PhpMyAdmin\ZipExtension;
|
||||
|
||||
use function __;
|
||||
use function array_filter;
|
||||
use function array_merge_recursive;
|
||||
use function error_get_last;
|
||||
use function fclose;
|
||||
use function file_exists;
|
||||
use function fopen;
|
||||
use function function_exists;
|
||||
use function fwrite;
|
||||
use function gzencode;
|
||||
use function header;
|
||||
use function htmlentities;
|
||||
use function htmlspecialchars;
|
||||
use function http_build_query;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
@ -50,57 +39,30 @@ use function ini_parse_quantity;
|
||||
use function is_array;
|
||||
use function is_file;
|
||||
use function is_numeric;
|
||||
use function is_string;
|
||||
use function is_writable;
|
||||
use function mb_strlen;
|
||||
use function mb_strtolower;
|
||||
use function mb_substr;
|
||||
use function ob_list_handlers;
|
||||
use function preg_match;
|
||||
use function preg_replace;
|
||||
use function str_contains;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
use function time;
|
||||
|
||||
use const ENT_COMPAT;
|
||||
|
||||
/**
|
||||
* PhpMyAdmin\Export\Export class
|
||||
*/
|
||||
class Export
|
||||
{
|
||||
public string $dumpBuffer = '';
|
||||
|
||||
public int $dumpBufferLength = 0;
|
||||
|
||||
/** @var string[] */
|
||||
public array $dumpBufferObjects = [];
|
||||
|
||||
public static bool $asFile = false;
|
||||
public static bool $saveOnServer = false;
|
||||
public static bool $outputCharsetConversion = false;
|
||||
public static bool $outputKanjiConversion = false;
|
||||
public static bool $bufferNeeded = false;
|
||||
public static bool $singleTable = false;
|
||||
|
||||
/** @var ''|'none'|'zip'|'gzip' */
|
||||
public static string $compression = '';
|
||||
|
||||
/** @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;
|
||||
/** @var array<string> */
|
||||
public static array $tableData = [];
|
||||
public static string $saveFilename = '';
|
||||
public static int $timeStart = 0;
|
||||
|
||||
public OutputHandler $outputHandler;
|
||||
|
||||
public function __construct(private DatabaseInterface $dbi)
|
||||
{
|
||||
$this->outputHandler = new OutputHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,131 +79,6 @@ class Export
|
||||
$_SESSION['pma_export_error'] = $error['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect ob_gzhandler
|
||||
*/
|
||||
public function isGzHandlerEnabled(): bool
|
||||
{
|
||||
/** @var string[] $handlers */
|
||||
$handlers = ob_list_handlers();
|
||||
|
||||
return in_array('ob_gzhandler', $handlers, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect whether gzencode is needed; it might not be needed if
|
||||
* the server is already compressing by itself
|
||||
*/
|
||||
public function gzencodeNeeded(): bool
|
||||
{
|
||||
/**
|
||||
* We should gzencode only if the function exists
|
||||
* but we don't want to compress twice, therefore
|
||||
* gzencode only if transparent compression is not enabled
|
||||
* but transparent compression does not apply when saving to server
|
||||
*/
|
||||
return function_exists('gzencode')
|
||||
&& ((! ini_get('zlib.output_compression')
|
||||
&& ! $this->isGzHandlerEnabled())
|
||||
|| self::$saveOnServer
|
||||
|| (new UserAgentParser(Core::getEnv('HTTP_USER_AGENT')))->getUserBrowserAgent() === 'CHROME');
|
||||
}
|
||||
|
||||
/**
|
||||
* Output handler for all exports, if needed buffering, it stores data into
|
||||
* $this->dumpBuffer, otherwise it prints them out.
|
||||
*
|
||||
* @param string $line the insert statement
|
||||
*/
|
||||
public function outputHandler(string $line): bool
|
||||
{
|
||||
// Kanji encoding convert feature
|
||||
if (self::$outputKanjiConversion) {
|
||||
$line = Encoding::kanjiStrConv($line, self::$kanjiEncoding, self::$xkana);
|
||||
}
|
||||
|
||||
// If we have to buffer data, we will perform everything at once at the end
|
||||
if (self::$bufferNeeded) {
|
||||
$this->dumpBuffer .= $line;
|
||||
if (self::$onFlyCompression) {
|
||||
$this->dumpBufferLength += strlen($line);
|
||||
|
||||
if ($this->dumpBufferLength > self::$memoryLimit) {
|
||||
if (self::$outputCharsetConversion) {
|
||||
$this->dumpBuffer = Encoding::convertString(
|
||||
'utf-8',
|
||||
Current::$charset ?? 'utf-8',
|
||||
$this->dumpBuffer,
|
||||
);
|
||||
}
|
||||
|
||||
if (self::$compression === 'gzip' && $this->gzencodeNeeded()) {
|
||||
// as a gzipped file
|
||||
// without the optional parameter level because it bugs
|
||||
$this->dumpBuffer = (string) gzencode($this->dumpBuffer);
|
||||
}
|
||||
|
||||
if (self::$saveOnServer) {
|
||||
$writeResult = @fwrite(self::$fileHandle, $this->dumpBuffer);
|
||||
// Here, use strlen rather than mb_strlen to get the length
|
||||
// in bytes to compare against the number of bytes written.
|
||||
if ($writeResult === false || $writeResult !== strlen($this->dumpBuffer)) {
|
||||
Current::$message = Message::error(
|
||||
__('Insufficient space to save the file %s.'),
|
||||
);
|
||||
Current::$message->addParam(self::$saveFilename);
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
echo $this->dumpBuffer;
|
||||
}
|
||||
|
||||
$this->dumpBuffer = '';
|
||||
$this->dumpBufferLength = 0;
|
||||
}
|
||||
} else {
|
||||
$timeNow = time();
|
||||
if (self::$timeStart >= $timeNow + 30) {
|
||||
self::$timeStart = $timeNow;
|
||||
header('X-pmaPing: Pong');
|
||||
}
|
||||
}
|
||||
} elseif (self::$asFile) {
|
||||
if (self::$outputCharsetConversion) {
|
||||
$line = Encoding::convertString('utf-8', Current::$charset ?? 'utf-8', $line);
|
||||
}
|
||||
|
||||
if (self::$saveOnServer && $line !== '') {
|
||||
$writeResult = self::$fileHandle !== null ? @fwrite(self::$fileHandle, $line) : false;
|
||||
// Here, use strlen rather than mb_strlen to get the length
|
||||
// in bytes to compare against the number of bytes written.
|
||||
if ($writeResult === 0 || $writeResult === false || $writeResult !== strlen($line)) {
|
||||
Current::$message = Message::error(
|
||||
__('Insufficient space to save the file %s.'),
|
||||
);
|
||||
Current::$message->addParam(self::$saveFilename);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$timeNow = time();
|
||||
if (self::$timeStart >= $timeNow + 30) {
|
||||
self::$timeStart = $timeNow;
|
||||
header('X-pmaPing: Pong');
|
||||
}
|
||||
} else {
|
||||
// We export as file - output normally
|
||||
echo $line;
|
||||
}
|
||||
} else {
|
||||
// We export as html - replace special chars
|
||||
echo htmlspecialchars($line, ENT_COMPAT);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML containing the footer for a displayed export
|
||||
*
|
||||
@ -355,10 +192,8 @@ class Export
|
||||
*
|
||||
* @param string $filename the export filename
|
||||
* @param bool $quickExport whether it's a quick export or not
|
||||
*
|
||||
* @psalm-return array{string, Message|null, resource|null}
|
||||
*/
|
||||
public function openFile(string $filename, bool $quickExport): array
|
||||
public function openFile(string $filename, bool $quickExport): Message|null
|
||||
{
|
||||
$fileHandle = null;
|
||||
$message = null;
|
||||
@ -403,83 +238,10 @@ class Export
|
||||
}
|
||||
}
|
||||
|
||||
return [$saveFilename, $message, $fileHandle];
|
||||
}
|
||||
$this->outputHandler->saveFilename = $saveFilename;
|
||||
$this->outputHandler->fileHandle = $fileHandle;
|
||||
|
||||
/**
|
||||
* Close the export file
|
||||
*
|
||||
* @param resource $fileHandle the export file handle
|
||||
* @param string $dumpBuffer the current dump buffer
|
||||
* @param string $saveFilename the export filename
|
||||
*
|
||||
* @return Message a message object (or empty string)
|
||||
*/
|
||||
public function closeFile(
|
||||
$fileHandle,
|
||||
string $dumpBuffer,
|
||||
string $saveFilename,
|
||||
): Message {
|
||||
$writeResult = @fwrite($fileHandle, $dumpBuffer);
|
||||
fclose($fileHandle);
|
||||
// Here, use strlen rather than mb_strlen to get the length
|
||||
// in bytes to compare against the number of bytes written.
|
||||
if ($dumpBuffer !== '' && $writeResult !== strlen($dumpBuffer)) {
|
||||
return new Message(
|
||||
__('Insufficient space to save the file %s.'),
|
||||
MessageType::Error,
|
||||
[$saveFilename],
|
||||
);
|
||||
}
|
||||
|
||||
return new Message(
|
||||
__('Dump has been saved to file %s.'),
|
||||
MessageType::Success,
|
||||
[$saveFilename],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compress the export buffer
|
||||
*
|
||||
* @param string[]|string $dumpBuffer the current dump buffer
|
||||
* @param string $compression the compression mode
|
||||
* @param string $filename the filename
|
||||
*/
|
||||
public function compress(array|string $dumpBuffer, string $compression, string $filename): array|string|bool
|
||||
{
|
||||
if ($compression === 'zip' && function_exists('gzcompress')) {
|
||||
$zipExtension = new ZipExtension();
|
||||
$filename = substr($filename, 0, -4); // remove extension (.zip)
|
||||
$dumpBuffer = $zipExtension->createFile($dumpBuffer, $filename);
|
||||
} elseif ($compression === 'gzip' && $this->gzencodeNeeded() && is_string($dumpBuffer)) {
|
||||
// without the optional parameter level because it bugs
|
||||
$dumpBuffer = gzencode($dumpBuffer);
|
||||
}
|
||||
|
||||
return $dumpBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the dump buffer for a particular table in an array
|
||||
* Used in separate files export
|
||||
*
|
||||
* @param string $objectName the name of current object to be stored
|
||||
* @param bool $append optional boolean to append to an existing index or not
|
||||
*/
|
||||
public function saveObjectInBuffer(string $objectName, bool $append = false): void
|
||||
{
|
||||
if ($this->dumpBuffer !== '') {
|
||||
if ($append && isset($this->dumpBufferObjects[$objectName])) {
|
||||
$this->dumpBufferObjects[$objectName] .= $this->dumpBuffer;
|
||||
} else {
|
||||
$this->dumpBufferObjects[$objectName] = $this->dumpBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
// Re - initialize
|
||||
$this->dumpBuffer = '';
|
||||
$this->dumpBufferLength = 0;
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -550,7 +312,7 @@ class Export
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->saveObjectInBuffer($currentDb);
|
||||
$this->outputHandler->saveObjectInBuffer($currentDb);
|
||||
}
|
||||
}
|
||||
|
||||
@ -586,7 +348,7 @@ class Export
|
||||
}
|
||||
|
||||
if ($separateFiles === 'database') {
|
||||
$this->saveObjectInBuffer('database', true);
|
||||
$this->outputHandler->saveObjectInBuffer('database', true);
|
||||
}
|
||||
|
||||
$structureOrData = $exportPlugin->getStructureOrData();
|
||||
@ -599,7 +361,7 @@ class Export
|
||||
$exportPlugin->exportRoutines($db->getName(), $aliases);
|
||||
|
||||
if ($separateFiles === 'database') {
|
||||
$this->saveObjectInBuffer('routines');
|
||||
$this->outputHandler->saveObjectInBuffer('routines');
|
||||
}
|
||||
}
|
||||
|
||||
@ -673,7 +435,7 @@ class Export
|
||||
|
||||
// this buffer was filled, we save it and go to the next one
|
||||
if ($separateFiles === 'database') {
|
||||
$this->saveObjectInBuffer('table_' . $table);
|
||||
$this->outputHandler->saveObjectInBuffer('table_' . $table);
|
||||
}
|
||||
|
||||
// now export the triggers (needs to be done after the data because
|
||||
@ -694,7 +456,7 @@ class Export
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->saveObjectInBuffer('table_' . $table, true);
|
||||
$this->outputHandler->saveObjectInBuffer('table_' . $table, true);
|
||||
}
|
||||
|
||||
if ($exportPlugin instanceof ExportSql && $exportPlugin->hasCreateView()) {
|
||||
@ -712,7 +474,7 @@ class Export
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->saveObjectInBuffer('view_' . $view);
|
||||
$this->outputHandler->saveObjectInBuffer('view_' . $view);
|
||||
}
|
||||
}
|
||||
|
||||
@ -728,12 +490,12 @@ class Export
|
||||
$exportPlugin->exportMetadata($db->getName(), $tables, $metadataTypes);
|
||||
|
||||
if ($separateFiles === 'database') {
|
||||
$this->saveObjectInBuffer('metadata');
|
||||
$this->outputHandler->saveObjectInBuffer('metadata');
|
||||
}
|
||||
}
|
||||
|
||||
if ($separateFiles === 'database') {
|
||||
$this->saveObjectInBuffer('extra');
|
||||
$this->outputHandler->saveObjectInBuffer('extra');
|
||||
}
|
||||
|
||||
if (
|
||||
@ -750,7 +512,7 @@ class Export
|
||||
return;
|
||||
}
|
||||
|
||||
$this->saveObjectInBuffer('events');
|
||||
$this->outputHandler->saveObjectInBuffer('events');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
257
src/Export/OutputHandler.php
Normal file
257
src/Export/OutputHandler.php
Normal file
@ -0,0 +1,257 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Export;
|
||||
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Encoding;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\MessageType;
|
||||
use PhpMyAdmin\Utils\UserAgentParser;
|
||||
use PhpMyAdmin\ZipExtension;
|
||||
|
||||
use function __;
|
||||
use function fclose;
|
||||
use function function_exists;
|
||||
use function fwrite;
|
||||
use function gzencode;
|
||||
use function header;
|
||||
use function htmlspecialchars;
|
||||
use function in_array;
|
||||
use function ini_get;
|
||||
use function is_string;
|
||||
use function ob_list_handlers;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
use function time;
|
||||
|
||||
use const ENT_COMPAT;
|
||||
|
||||
class OutputHandler
|
||||
{
|
||||
private string $dumpBuffer = '';
|
||||
private int $dumpBufferLength = 0;
|
||||
/** @var string[] */
|
||||
private array $dumpBufferObjects = [];
|
||||
|
||||
public bool $outputCharsetConversion = false;
|
||||
public bool $outputKanjiConversion = false;
|
||||
|
||||
public static bool $asFile = false;
|
||||
public bool $saveOnServer = false;
|
||||
public string $saveFilename = '';
|
||||
/** @var resource|null */
|
||||
public mixed $fileHandle = null;
|
||||
/** @var ''|'none'|'zip'|'gzip' */
|
||||
public string $compression = '';
|
||||
public string $kanjiEncoding = '';
|
||||
public string $xkana = '';
|
||||
public int $memoryLimit = 0;
|
||||
public bool $onFlyCompression = false;
|
||||
public int $timeStart = 0;
|
||||
public bool $bufferNeeded = false;
|
||||
|
||||
public function __invoke(string $line): bool
|
||||
{
|
||||
// Kanji encoding convert feature
|
||||
if ($this->outputKanjiConversion) {
|
||||
$line = Encoding::kanjiStrConv($line, $this->kanjiEncoding, $this->xkana);
|
||||
}
|
||||
|
||||
// If we have to buffer data, we will perform everything at once at the end
|
||||
if ($this->bufferNeeded) {
|
||||
$this->dumpBuffer .= $line;
|
||||
if ($this->onFlyCompression) {
|
||||
$this->dumpBufferLength += strlen($line);
|
||||
|
||||
if ($this->dumpBufferLength > $this->memoryLimit) {
|
||||
if ($this->outputCharsetConversion) {
|
||||
$this->dumpBuffer = Encoding::convertString(
|
||||
'utf-8',
|
||||
Current::$charset ?? 'utf-8',
|
||||
$this->dumpBuffer,
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->compression === 'gzip' && $this->gzencodeNeeded()) {
|
||||
// as a gzipped file
|
||||
// without the optional parameter level because it bugs
|
||||
$this->dumpBuffer = (string) gzencode($this->dumpBuffer);
|
||||
}
|
||||
|
||||
if ($this->saveOnServer && $this->fileHandle !== null) {
|
||||
$writeResult = @fwrite($this->fileHandle, $this->dumpBuffer);
|
||||
// Here, use strlen rather than mb_strlen to get the length
|
||||
// in bytes to compare against the number of bytes written.
|
||||
if ($writeResult !== strlen($this->dumpBuffer)) {
|
||||
Current::$message = Message::error(
|
||||
__('Insufficient space to save the file %s.'),
|
||||
);
|
||||
Current::$message->addParam($this->saveFilename);
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
echo $this->dumpBuffer;
|
||||
}
|
||||
|
||||
$this->dumpBuffer = '';
|
||||
$this->dumpBufferLength = 0;
|
||||
}
|
||||
} else {
|
||||
$timeNow = time();
|
||||
if ($this->timeStart >= $timeNow + 30) {
|
||||
$this->timeStart = $timeNow;
|
||||
header('X-pmaPing: Pong');
|
||||
}
|
||||
}
|
||||
} elseif (self::$asFile) {
|
||||
if ($this->outputCharsetConversion) {
|
||||
$line = Encoding::convertString('utf-8', Current::$charset ?? 'utf-8', $line);
|
||||
}
|
||||
|
||||
if ($this->saveOnServer && $this->fileHandle !== null && $line !== '') {
|
||||
$writeResult = @fwrite($this->fileHandle, $line);
|
||||
// Here, use strlen rather than mb_strlen to get the length
|
||||
// in bytes to compare against the number of bytes written.
|
||||
if ($writeResult !== strlen($line)) {
|
||||
Current::$message = Message::error(
|
||||
__('Insufficient space to save the file %s.'),
|
||||
);
|
||||
Current::$message->addParam($this->saveFilename);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$timeNow = time();
|
||||
if ($this->timeStart >= $timeNow + 30) {
|
||||
$this->timeStart = $timeNow;
|
||||
header('X-pmaPing: Pong');
|
||||
}
|
||||
} else {
|
||||
// We export as file - output normally
|
||||
echo $line;
|
||||
}
|
||||
} else {
|
||||
// We export as html - replace special chars
|
||||
echo htmlspecialchars($line, ENT_COMPAT);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the dump buffer for a particular table in an array
|
||||
* Used in separate files export
|
||||
*
|
||||
* @param string $objectName the name of current object to be stored
|
||||
* @param bool $append optional boolean to append to an existing index or not
|
||||
*/
|
||||
public function saveObjectInBuffer(string $objectName, bool $append = false): void
|
||||
{
|
||||
if ($this->dumpBuffer !== '') {
|
||||
if ($append && isset($this->dumpBufferObjects[$objectName])) {
|
||||
$this->dumpBufferObjects[$objectName] .= $this->dumpBuffer;
|
||||
} else {
|
||||
$this->dumpBufferObjects[$objectName] = $this->dumpBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
// Re - initialize
|
||||
$this->dumpBuffer = '';
|
||||
$this->dumpBufferLength = 0;
|
||||
}
|
||||
|
||||
public function compress(bool $separateFiles, string $filename): void
|
||||
{
|
||||
$dumpBuffer = $separateFiles
|
||||
? $this->dumpBufferObjects
|
||||
: $this->dumpBuffer;
|
||||
if ($this->compression === 'zip' && function_exists('gzcompress')) {
|
||||
$zipExtension = new ZipExtension();
|
||||
$filename = substr($filename, 0, -4); // remove extension (.zip)
|
||||
$this->dumpBuffer = $zipExtension->createFile($dumpBuffer, $filename);
|
||||
} elseif ($this->compression === 'gzip' && $this->gzencodeNeeded() && is_string($dumpBuffer)) {
|
||||
// without the optional parameter level because it bugs
|
||||
$this->dumpBuffer = gzencode($dumpBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public function closeFile(): Message
|
||||
{
|
||||
$writeResult = false;
|
||||
if ($this->fileHandle !== null) {
|
||||
$writeResult = @fwrite($this->fileHandle, $this->dumpBuffer);
|
||||
fclose($this->fileHandle);
|
||||
$this->fileHandle = null;
|
||||
}
|
||||
|
||||
// Here, use strlen rather than mb_strlen to get the length
|
||||
// in bytes to compare against the number of bytes written.
|
||||
if ($this->dumpBuffer !== '' && $writeResult !== strlen($this->dumpBuffer)) {
|
||||
return new Message(
|
||||
__('Insufficient space to save the file %s.'),
|
||||
MessageType::Error,
|
||||
[$this->saveFilename],
|
||||
);
|
||||
}
|
||||
|
||||
return new Message(
|
||||
__('Dump has been saved to file %s.'),
|
||||
MessageType::Success,
|
||||
[$this->saveFilename],
|
||||
);
|
||||
}
|
||||
|
||||
public function clearBuffer(): void
|
||||
{
|
||||
$this->dumpBuffer = '';
|
||||
$this->dumpBufferLength = 0;
|
||||
}
|
||||
|
||||
public function getBuffer(): string
|
||||
{
|
||||
return $this->dumpBuffer;
|
||||
}
|
||||
|
||||
public function convertBufferCharset(): void
|
||||
{
|
||||
if (! $this->outputCharsetConversion || $this->dumpBuffer === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dumpBuffer = Encoding::convertString('utf-8', Current::$charset ?? 'utf-8', $this->dumpBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect whether gzencode is needed; it might not be needed if
|
||||
* the server is already compressing by itself
|
||||
*/
|
||||
private function gzencodeNeeded(): bool
|
||||
{
|
||||
/**
|
||||
* We should gzencode only if the function exists
|
||||
* but we don't want to compress twice, therefore
|
||||
* gzencode only if transparent compression is not enabled
|
||||
* but transparent compression does not apply when saving to server
|
||||
*/
|
||||
return function_exists('gzencode')
|
||||
&& ((! ini_get('zlib.output_compression')
|
||||
&& ! $this->isGzHandlerEnabled())
|
||||
|| $this->saveOnServer
|
||||
|| (new UserAgentParser(Core::getEnv('HTTP_USER_AGENT')))->getUserBrowserAgent() === 'CHROME');
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect ob_gzhandler
|
||||
*/
|
||||
private function isGzHandlerEnabled(): bool
|
||||
{
|
||||
/** @var string[] $handlers */
|
||||
$handlers = ob_list_handlers();
|
||||
|
||||
return in_array('ob_gzhandler', $handlers, true);
|
||||
}
|
||||
}
|
||||
@ -97,10 +97,10 @@ class ExportCodegen extends ExportPlugin
|
||||
array $aliases = [],
|
||||
): bool {
|
||||
if ($this->format === self::HANDLER_NHIBERNATE_XML) {
|
||||
return $this->export->outputHandler($this->handleNHibernateXMLBody($db, $table, $aliases));
|
||||
return ($this->export->outputHandler)($this->handleNHibernateXMLBody($db, $table, $aliases));
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($this->handleNHibernateCSBody($db, $table, $aliases));
|
||||
return ($this->export->outputHandler)($this->handleNHibernateCSBody($db, $table, $aliases));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -164,7 +164,7 @@ class ExportCsv extends ExportPlugin
|
||||
}
|
||||
|
||||
$schemaInsert = implode($this->separator, $insertFields);
|
||||
if (! $this->export->outputHandler($schemaInsert . $this->terminated)) {
|
||||
if (! ($this->export->outputHandler)($schemaInsert . $this->terminated)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -218,7 +218,7 @@ class ExportCsv extends ExportPlugin
|
||||
}
|
||||
|
||||
$schemaInsert = implode($this->separator, $insertValues);
|
||||
if (! $this->export->outputHandler($schemaInsert . $this->terminated)) {
|
||||
if (! ($this->export->outputHandler)($schemaInsert . $this->terminated)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ class ExportExcel extends ExportPlugin
|
||||
}
|
||||
|
||||
$schemaInsert = implode($this->separator, $insertFields);
|
||||
if (! $this->export->outputHandler($schemaInsert . $this->terminated)) {
|
||||
if (! ($this->export->outputHandler)($schemaInsert . $this->terminated)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -206,7 +206,7 @@ class ExportExcel extends ExportPlugin
|
||||
}
|
||||
|
||||
$schemaInsert = implode($this->separator, $insertValues);
|
||||
if (! $this->export->outputHandler($schemaInsert . $this->terminated)) {
|
||||
if (! ($this->export->outputHandler)($schemaInsert . $this->terminated)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
*/
|
||||
public function exportHeader(): bool
|
||||
{
|
||||
return $this->export->outputHandler(
|
||||
return ($this->export->outputHandler)(
|
||||
'<html xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:x="urn:schemas-microsoft-com:office:word"
|
||||
xmlns="http://www.w3.org/TR/REC-html40">
|
||||
@ -127,7 +127,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
*/
|
||||
public function exportFooter(): bool
|
||||
{
|
||||
return $this->export->outputHandler('</body></html>');
|
||||
return ($this->export->outputHandler)('</body></html>');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -142,7 +142,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
$dbAlias = $db;
|
||||
}
|
||||
|
||||
return $this->export->outputHandler(
|
||||
return ($this->export->outputHandler)(
|
||||
'<h1>' . __('Database') . ' ' . htmlspecialchars($dbAlias) . '</h1>',
|
||||
);
|
||||
}
|
||||
@ -164,7 +164,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
$tableAlias = $this->getTableAlias($aliases, $db, $table);
|
||||
|
||||
if (
|
||||
! $this->export->outputHandler(
|
||||
! ($this->export->outputHandler)(
|
||||
'<h2>'
|
||||
. __('Dumping data for table') . ' ' . htmlspecialchars($tableAlias)
|
||||
. '</h2>',
|
||||
@ -173,7 +173,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $this->export->outputHandler('<table width="100%" cellspacing="1">')) {
|
||||
if (! ($this->export->outputHandler)('<table width="100%" cellspacing="1">')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
}
|
||||
|
||||
$schemaInsert .= '</tr>';
|
||||
if (! $this->export->outputHandler($schemaInsert)) {
|
||||
if (! ($this->export->outputHandler)($schemaInsert)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -210,12 +210,12 @@ class ExportHtmlword extends ExportPlugin
|
||||
}
|
||||
|
||||
$schemaInsert .= '</tr>';
|
||||
if (! $this->export->outputHandler($schemaInsert)) {
|
||||
if (! ($this->export->outputHandler)($schemaInsert)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->export->outputHandler('</table>');
|
||||
return ($this->export->outputHandler)('</table>');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -480,7 +480,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
$dump .= $this->getTableDefStandIn($db, $table, $aliases);
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($dump);
|
||||
return ($this->export->outputHandler)($dump);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -116,7 +116,7 @@ class ExportJson extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->export->outputHandler('[' . "\n" . $data . ',' . "\n");
|
||||
return ($this->export->outputHandler)('[' . "\n" . $data . ',' . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,7 +124,7 @@ class ExportJson extends ExportPlugin
|
||||
*/
|
||||
public function exportFooter(): bool
|
||||
{
|
||||
return $this->export->outputHandler(']' . "\n");
|
||||
return ($this->export->outputHandler)(']' . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,7 +144,7 @@ class ExportJson extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($data . ',' . "\n");
|
||||
return ($this->export->outputHandler)($data . ',' . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,7 +165,7 @@ class ExportJson extends ExportPlugin
|
||||
$tableAlias = $this->getTableAlias($aliases, $db, $table);
|
||||
|
||||
if (! $this->first) {
|
||||
if (! $this->export->outputHandler(',')) {
|
||||
if (! ($this->export->outputHandler)(',')) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -208,7 +208,7 @@ class ExportJson extends ExportPlugin
|
||||
): bool {
|
||||
[$header, $footer] = explode('"@@DATA@@"', $buffer);
|
||||
|
||||
if (! $this->export->outputHandler($header . "\n" . '[' . "\n")) {
|
||||
if (! ($this->export->outputHandler)($header . "\n" . '[' . "\n")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ class ExportJson extends ExportPlugin
|
||||
|
||||
// Output table name as comment if this is the first record of the table
|
||||
if ($recordCnt > 1) {
|
||||
if (! $this->export->outputHandler(',' . "\n")) {
|
||||
if (! ($this->export->outputHandler)(',' . "\n")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -272,12 +272,12 @@ class ExportJson extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $this->export->outputHandler($encodedData)) {
|
||||
if (! ($this->export->outputHandler)($encodedData)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->export->outputHandler("\n" . ']' . "\n" . $footer . "\n");
|
||||
return ($this->export->outputHandler)("\n" . ']' . "\n" . $footer . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -233,7 +233,7 @@ class ExportLatex extends ExportPlugin
|
||||
. '% ' . __('Server version:') . ' ' . DatabaseInterface::getInstance()->getVersionString() . "\n"
|
||||
. '% ' . __('PHP Version:') . ' ' . PHP_VERSION . "\n";
|
||||
|
||||
return $this->export->outputHandler($head);
|
||||
return ($this->export->outputHandler)($head);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,7 +252,7 @@ class ExportLatex extends ExportPlugin
|
||||
. '% ' . __('Database:') . ' \'' . $dbAlias . '\'' . "\n"
|
||||
. '% ' . "\n";
|
||||
|
||||
return $this->export->outputHandler($head);
|
||||
return ($this->export->outputHandler)($head);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -309,7 +309,7 @@ class ExportLatex extends ExportPlugin
|
||||
. '} \\\\';
|
||||
}
|
||||
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
if (! ($this->export->outputHandler)($buffer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -322,13 +322,13 @@ class ExportLatex extends ExportPlugin
|
||||
}
|
||||
|
||||
$buffer = mb_substr($buffer, 0, -2) . '\\\\ \\hline \hline ';
|
||||
if (! $this->export->outputHandler($buffer . ' \\endfirsthead ' . "\n")) {
|
||||
if (! ($this->export->outputHandler)($buffer . ' \\endfirsthead ' . "\n")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->caption) {
|
||||
if (
|
||||
! $this->export->outputHandler(
|
||||
! ($this->export->outputHandler)(
|
||||
'\\caption{'
|
||||
. Util::expandUserString(
|
||||
$this->dataContinuedCaption,
|
||||
@ -342,10 +342,10 @@ class ExportLatex extends ExportPlugin
|
||||
}
|
||||
}
|
||||
|
||||
if (! $this->export->outputHandler($buffer . '\\endhead \\endfoot' . "\n")) {
|
||||
if (! ($this->export->outputHandler)($buffer . '\\endhead \\endfoot' . "\n")) {
|
||||
return false;
|
||||
}
|
||||
} elseif (! $this->export->outputHandler('\\\\ \hline')) {
|
||||
} elseif (! ($this->export->outputHandler)('\\\\ \hline')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -370,14 +370,14 @@ class ExportLatex extends ExportPlugin
|
||||
}
|
||||
|
||||
$buffer .= ' \\\\ \\hline ' . "\n";
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
if (! ($this->export->outputHandler)($buffer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$buffer = ' \\end{longtable}' . "\n";
|
||||
|
||||
return $this->export->outputHandler($buffer);
|
||||
return ($this->export->outputHandler)($buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -443,7 +443,7 @@ class ExportLatex extends ExportPlugin
|
||||
*/
|
||||
$buffer = "\n" . '%' . "\n" . '% ' . __('Structure:') . ' '
|
||||
. $tableAlias . "\n" . '%' . "\n" . ' \\begin{longtable}{';
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
if (! ($this->export->outputHandler)($buffer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -513,7 +513,7 @@ class ExportLatex extends ExportPlugin
|
||||
|
||||
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . "\n";
|
||||
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
if (! ($this->export->outputHandler)($buffer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -565,14 +565,14 @@ class ExportLatex extends ExportPlugin
|
||||
$buffer = str_replace("\000", ' & ', $localBuffer);
|
||||
$buffer .= ' \\\\ \\hline ' . "\n";
|
||||
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
if (! ($this->export->outputHandler)($buffer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$buffer = ' \\end{longtable}' . "\n";
|
||||
|
||||
return $this->export->outputHandler($buffer);
|
||||
return ($this->export->outputHandler)($buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -166,7 +166,7 @@ class ExportMediawiki extends ExportPlugin
|
||||
$output .= '|}' . str_repeat($this->exportCRLF(), 2);
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($output);
|
||||
return ($this->export->outputHandler)($output);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,7 +240,7 @@ class ExportMediawiki extends ExportPlugin
|
||||
// End table construction
|
||||
$output .= '|}' . str_repeat($this->exportCRLF(), 2);
|
||||
|
||||
return $this->export->outputHandler($output);
|
||||
return ($this->export->outputHandler)($output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -142,11 +142,8 @@ class ExportOds extends ExportPlugin
|
||||
{
|
||||
$this->buffer .= '</office:spreadsheet></office:body></office:document-content>';
|
||||
|
||||
return $this->export->outputHandler(
|
||||
OpenDocument::create(
|
||||
'application/vnd.oasis.opendocument.spreadsheet',
|
||||
$this->buffer,
|
||||
),
|
||||
return ($this->export->outputHandler)(
|
||||
OpenDocument::create('application/vnd.oasis.opendocument.spreadsheet', $this->buffer),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ class ExportOdt extends ExportPlugin
|
||||
{
|
||||
$this->buffer .= '</office:text></office:body></office:document-content>';
|
||||
|
||||
return $this->export->outputHandler(OpenDocument::create(
|
||||
return ($this->export->outputHandler)(OpenDocument::create(
|
||||
'application/vnd.oasis.opendocument.text',
|
||||
$this->buffer,
|
||||
));
|
||||
|
||||
@ -104,7 +104,7 @@ class ExportPdf extends ExportPlugin
|
||||
public function exportFooter(): bool
|
||||
{
|
||||
// instead of $pdf->Output():
|
||||
return $this->export->outputHandler($this->pdf->getPDFData());
|
||||
return ($this->export->outputHandler)($this->pdf->getPDFData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -78,7 +78,7 @@ class ExportPhparray extends ExportPlugin
|
||||
*/
|
||||
public function exportHeader(): bool
|
||||
{
|
||||
$this->export->outputHandler(
|
||||
($this->export->outputHandler)(
|
||||
'<?php' . "\n"
|
||||
. '/**' . "\n"
|
||||
. ' * Export to PHP Array plugin for phpMyAdmin' . "\n"
|
||||
@ -101,7 +101,7 @@ class ExportPhparray extends ExportPlugin
|
||||
$dbAlias = $db;
|
||||
}
|
||||
|
||||
$this->export->outputHandler(
|
||||
($this->export->outputHandler)(
|
||||
'/**' . "\n"
|
||||
. ' * Database ' . $this->commentString(Util::backquote($dbAlias))
|
||||
. "\n" . ' */' . "\n",
|
||||
@ -160,7 +160,7 @@ class ExportPhparray extends ExportPlugin
|
||||
. $this->commentString(Util::backquote($dbAlias)) . '.'
|
||||
. $this->commentString(Util::backquote($tableAlias)) . ' */' . "\n";
|
||||
$buffer .= '$' . $tableFixed . ' = array(';
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
if (! ($this->export->outputHandler)($buffer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ class ExportPhparray extends ExportPlugin
|
||||
}
|
||||
|
||||
$buffer .= ')';
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
if (! ($this->export->outputHandler)($buffer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ class ExportPhparray extends ExportPlugin
|
||||
|
||||
$buffer .= "\n" . ');' . "\n";
|
||||
|
||||
return $this->export->outputHandler($buffer);
|
||||
return ($this->export->outputHandler)($buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -19,6 +19,7 @@ use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Exceptions\ExportException;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Export\StructureOrData;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
@ -649,7 +650,7 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
|
||||
if ($text !== '') {
|
||||
return $this->export->outputHandler($text);
|
||||
return ($this->export->outputHandler)($text);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -732,7 +733,7 @@ class ExportSql extends ExportPlugin
|
||||
DatabaseInterface::getInstance()->query('SET time_zone = "' . self::$oldTimezone . '"');
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($foot);
|
||||
return ($this->export->outputHandler)($foot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -801,7 +802,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
$head .= $this->possibleCRLF();
|
||||
|
||||
if (Export::$asFile) {
|
||||
if (OutputHandler::$asFile) {
|
||||
// we are saving as file, therefore we provide charset information
|
||||
// so that a utility like the mysql client can interpret
|
||||
// the file correctly
|
||||
@ -828,7 +829,7 @@ class ExportSql extends ExportPlugin
|
||||
$this->sentCharset = true;
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($head);
|
||||
return ($this->export->outputHandler)($head);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -845,13 +846,9 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
if ($this->structureOrData !== StructureOrData::Data && $this->dropDatabase) {
|
||||
if (
|
||||
! $this->export->outputHandler(
|
||||
! ($this->export->outputHandler)(
|
||||
'DROP DATABASE IF EXISTS '
|
||||
. Util::backquoteCompat(
|
||||
$dbAlias,
|
||||
$this->compatibility,
|
||||
$this->useSqlBackquotes,
|
||||
)
|
||||
. Util::backquoteCompat($dbAlias, $this->compatibility, $this->useSqlBackquotes)
|
||||
. ';' . "\n",
|
||||
)
|
||||
) {
|
||||
@ -879,7 +876,7 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
|
||||
$createQuery .= ';' . "\n";
|
||||
if (! $this->export->outputHandler($createQuery)) {
|
||||
if (! ($this->export->outputHandler)($createQuery)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -895,18 +892,14 @@ class ExportSql extends ExportPlugin
|
||||
private function exportUseStatement(string $db, string $compat): bool
|
||||
{
|
||||
if ($compat === 'NONE') {
|
||||
return $this->export->outputHandler(
|
||||
return ($this->export->outputHandler)(
|
||||
'USE '
|
||||
. Util::backquoteCompat(
|
||||
$db,
|
||||
$compat,
|
||||
$this->useSqlBackquotes,
|
||||
)
|
||||
. Util::backquoteCompat($db, $compat, $this->useSqlBackquotes)
|
||||
. ';' . "\n",
|
||||
);
|
||||
}
|
||||
|
||||
return $this->export->outputHandler('USE ' . $db . ';' . "\n");
|
||||
return ($this->export->outputHandler)('USE ' . $db . ';' . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -932,7 +925,7 @@ class ExportSql extends ExportPlugin
|
||||
)
|
||||
. $this->exportComment();
|
||||
|
||||
return $this->export->outputHandler($head);
|
||||
return ($this->export->outputHandler)($head);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -946,25 +939,25 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
//add indexes to the sql dump file
|
||||
if ($this->sqlIndexes !== null) {
|
||||
$result = $this->export->outputHandler($this->sqlIndexes);
|
||||
$result = ($this->export->outputHandler)($this->sqlIndexes);
|
||||
$this->sqlIndexes = null;
|
||||
}
|
||||
|
||||
//add auto increments to the sql dump file
|
||||
if ($this->sqlAutoIncrements !== null) {
|
||||
$result = $this->export->outputHandler($this->sqlAutoIncrements);
|
||||
$result = ($this->export->outputHandler)($this->sqlAutoIncrements);
|
||||
$this->sqlAutoIncrements = null;
|
||||
}
|
||||
|
||||
//add views to the sql dump file
|
||||
if ($this->sqlViews !== '') {
|
||||
$result = $this->export->outputHandler($this->sqlViews);
|
||||
$result = ($this->export->outputHandler)($this->sqlViews);
|
||||
$this->sqlViews = '';
|
||||
}
|
||||
|
||||
//add constraints to the sql dump file
|
||||
if ($this->sqlConstraints !== null) {
|
||||
$result = $this->export->outputHandler($this->sqlConstraints);
|
||||
$result = ($this->export->outputHandler)($this->sqlConstraints);
|
||||
$this->sqlConstraints = null;
|
||||
}
|
||||
|
||||
@ -1022,7 +1015,7 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
|
||||
if ($text !== '') {
|
||||
return $this->export->outputHandler($text);
|
||||
return ($this->export->outputHandler)($text);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1050,7 +1043,7 @@ class ExportSql extends ExportPlugin
|
||||
. $this->exportComment()
|
||||
. $this->exportComment(__('Metadata'))
|
||||
. $this->exportComment();
|
||||
if (! $this->export->outputHandler($comment)) {
|
||||
if (! ($this->export->outputHandler)($comment)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1128,7 +1121,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
$comment .= $this->exportComment();
|
||||
|
||||
if (! $this->export->outputHandler($comment)) {
|
||||
if (! ($this->export->outputHandler)($comment)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1173,7 +1166,7 @@ class ExportSql extends ExportPlugin
|
||||
$lastPage = "\n"
|
||||
. 'SET @LAST_PAGE = LAST_INSERT_ID();'
|
||||
. "\n";
|
||||
if (! $this->export->outputHandler($lastPage)) {
|
||||
if (! ($this->export->outputHandler)($lastPage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1982,7 +1975,7 @@ class ExportSql extends ExportPlugin
|
||||
// but not in the case of export
|
||||
$this->sqlConstraintsQuery = '';
|
||||
|
||||
return $this->export->outputHandler($dump);
|
||||
return ($this->export->outputHandler)($dump);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2019,7 +2012,7 @@ class ExportSql extends ExportPlugin
|
||||
. $this->exportComment()
|
||||
. $this->possibleCRLF();
|
||||
|
||||
return $this->export->outputHandler($head);
|
||||
return ($this->export->outputHandler)($head);
|
||||
}
|
||||
|
||||
$result = $dbi->tryQuery($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
@ -2090,8 +2083,8 @@ class ExportSql extends ExportPlugin
|
||||
)
|
||||
. $this->exportComment()
|
||||
. "\n";
|
||||
$this->export->outputHandler($truncatehead);
|
||||
$this->export->outputHandler($truncate);
|
||||
($this->export->outputHandler)($truncatehead);
|
||||
($this->export->outputHandler)($truncate);
|
||||
}
|
||||
|
||||
// scheme for inserting fields
|
||||
@ -2127,7 +2120,7 @@ class ExportSql extends ExportPlugin
|
||||
)
|
||||
. $this->exportComment()
|
||||
. "\n";
|
||||
if (! $this->export->outputHandler($head)) {
|
||||
if (! ($this->export->outputHandler)($head)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2135,13 +2128,9 @@ class ExportSql extends ExportPlugin
|
||||
// We need to SET IDENTITY_INSERT ON for MSSQL
|
||||
if ($currentRow === 0 && $this->compatibility === 'MSSQL') {
|
||||
if (
|
||||
! $this->export->outputHandler(
|
||||
! ($this->export->outputHandler)(
|
||||
'SET IDENTITY_INSERT '
|
||||
. Util::backquoteCompat(
|
||||
$tableAlias,
|
||||
$this->compatibility,
|
||||
$this->useSqlBackquotes,
|
||||
)
|
||||
. Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes)
|
||||
. ' ON ;' . "\n",
|
||||
)
|
||||
) {
|
||||
@ -2218,7 +2207,7 @@ class ExportSql extends ExportPlugin
|
||||
$insertLine = '(' . implode(', ', $values) . ')';
|
||||
$insertLineSize = mb_strlen($insertLine);
|
||||
if ($this->maxQuerySize > 0 && $querySize + $insertLineSize > $this->maxQuerySize) {
|
||||
if (! $this->export->outputHandler(';' . "\n")) {
|
||||
if (! ($this->export->outputHandler)(';' . "\n")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2234,26 +2223,22 @@ class ExportSql extends ExportPlugin
|
||||
$insertLine = $schemaInsert . '(' . implode(', ', $values) . ')';
|
||||
}
|
||||
|
||||
if (! $this->export->outputHandler(($currentRow === 1 ? '' : $separator . "\n") . $insertLine)) {
|
||||
if (! ($this->export->outputHandler)(($currentRow === 1 ? '' : $separator . "\n") . $insertLine)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($currentRow > 0) {
|
||||
if (! $this->export->outputHandler(';' . "\n")) {
|
||||
if (! ($this->export->outputHandler)(';' . "\n")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// We need to SET IDENTITY_INSERT OFF for MSSQL
|
||||
if ($this->compatibility === 'MSSQL' && $currentRow > 0) {
|
||||
$outputSucceeded = $this->export->outputHandler(
|
||||
$outputSucceeded = ($this->export->outputHandler)(
|
||||
"\n" . 'SET IDENTITY_INSERT '
|
||||
. Util::backquoteCompat(
|
||||
$tableAlias,
|
||||
$this->compatibility,
|
||||
$this->useSqlBackquotes,
|
||||
)
|
||||
. Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes)
|
||||
. ' OFF;' . "\n",
|
||||
);
|
||||
if (! $outputSucceeded) {
|
||||
|
||||
@ -111,7 +111,7 @@ class ExportTexytext extends ExportPlugin
|
||||
$dbAlias = $db;
|
||||
}
|
||||
|
||||
return $this->export->outputHandler(
|
||||
return ($this->export->outputHandler)(
|
||||
'===' . __('Database') . ' ' . $dbAlias . "\n\n",
|
||||
);
|
||||
}
|
||||
@ -133,7 +133,7 @@ class ExportTexytext extends ExportPlugin
|
||||
$tableAlias = $this->getTableAlias($aliases, $db, $table);
|
||||
|
||||
if (
|
||||
! $this->export->outputHandler(
|
||||
! ($this->export->outputHandler)(
|
||||
$tableAlias !== ''
|
||||
? '== ' . __('Dumping data for table') . ' ' . $tableAlias . "\n\n"
|
||||
: '==' . __('Dumping data for query result') . "\n\n",
|
||||
@ -158,7 +158,7 @@ class ExportTexytext extends ExportPlugin
|
||||
}
|
||||
|
||||
$textOutput .= "\n|------\n";
|
||||
if (! $this->export->outputHandler($textOutput)) {
|
||||
if (! ($this->export->outputHandler)($textOutput)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -184,7 +184,7 @@ class ExportTexytext extends ExportPlugin
|
||||
}
|
||||
|
||||
$textOutput .= "\n";
|
||||
if (! $this->export->outputHandler($textOutput)) {
|
||||
if (! ($this->export->outputHandler)($textOutput)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -429,7 +429,7 @@ class ExportTexytext extends ExportPlugin
|
||||
$dump .= $this->getTableDefStandIn($db, $table, $aliases);
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($dump);
|
||||
return ($this->export->outputHandler)($dump);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -12,7 +12,6 @@ use PhpMyAdmin\Database\Routines;
|
||||
use PhpMyAdmin\Database\RoutineType;
|
||||
use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\StructureOrData;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
@ -195,7 +194,7 @@ class ExportXml extends ExportPlugin
|
||||
|| $this->exportTriggers
|
||||
|| $this->exportViews;
|
||||
|
||||
$charset = Export::$outputCharsetConversion ? Current::$charset : 'utf-8';
|
||||
$charset = $this->export->outputHandler->outputCharsetConversion ? Current::$charset : 'utf-8';
|
||||
|
||||
$config = Config::getInstance();
|
||||
$head = '<?xml version="1.0" encoding="' . $charset . '"?>' . "\n"
|
||||
@ -337,7 +336,7 @@ class ExportXml extends ExportPlugin
|
||||
}
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($head);
|
||||
return ($this->export->outputHandler)($head);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -347,7 +346,7 @@ class ExportXml extends ExportPlugin
|
||||
{
|
||||
$foot = '</pma_xml_export>';
|
||||
|
||||
return $this->export->outputHandler($foot);
|
||||
return ($this->export->outputHandler)($foot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,7 +368,7 @@ class ExportXml extends ExportPlugin
|
||||
. ' -->' . "\n" . ' <database name="'
|
||||
. htmlspecialchars($dbAlias) . '">' . "\n";
|
||||
|
||||
return $this->export->outputHandler($head);
|
||||
return ($this->export->outputHandler)($head);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -383,7 +382,7 @@ class ExportXml extends ExportPlugin
|
||||
public function exportDBFooter(string $db): bool
|
||||
{
|
||||
if ($this->exportContents) {
|
||||
return $this->export->outputHandler(' </database>' . "\n");
|
||||
return ($this->export->outputHandler)(' </database>' . "\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -418,7 +417,7 @@ class ExportXml extends ExportPlugin
|
||||
|
||||
$buffer = ' <!-- ' . __('Table') . ' '
|
||||
. htmlspecialchars($tableAlias) . ' -->' . "\n";
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
if (! ($this->export->outputHandler)($buffer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -442,7 +441,7 @@ class ExportXml extends ExportPlugin
|
||||
|
||||
$buffer .= ' </table>' . "\n";
|
||||
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
if (! ($this->export->outputHandler)($buffer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ class ExportYaml extends ExportPlugin
|
||||
*/
|
||||
public function exportHeader(): bool
|
||||
{
|
||||
$this->export->outputHandler('%YAML 1.1' . "\n" . '---' . "\n");
|
||||
($this->export->outputHandler)('%YAML 1.1' . "\n" . '---' . "\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -77,7 +77,7 @@ class ExportYaml extends ExportPlugin
|
||||
*/
|
||||
public function exportFooter(): bool
|
||||
{
|
||||
$this->export->outputHandler('...' . "\n");
|
||||
($this->export->outputHandler)('...' . "\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -148,7 +148,7 @@ class ExportYaml extends ExportPlugin
|
||||
$buffer .= ' ' . $columns[$i] . ': "' . $record[$i] . '"' . "\n";
|
||||
}
|
||||
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
if (! ($this->export->outputHandler)($buffer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Export\ExportSql;
|
||||
@ -66,9 +66,6 @@ class TableMover
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setting required export settings.
|
||||
Export::$asFile = true;
|
||||
|
||||
// Selecting the database could avoid some problems with replicated
|
||||
// databases, when moving table from replicated one to not replicated one.
|
||||
$this->dbi->selectDb($targetDb);
|
||||
@ -484,6 +481,8 @@ class TableMover
|
||||
* @var ExportSql $exportSqlPlugin
|
||||
*/
|
||||
$exportSqlPlugin = Plugins::getPlugin('export', 'sql', ExportType::Table);
|
||||
// Setting required export settings.
|
||||
OutputHandler::$asFile = true;
|
||||
// It is better that all identifiers are quoted
|
||||
$exportSqlPlugin->useSqlBackquotes(true);
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\FlashMessenger;
|
||||
use PhpMyAdmin\Identifiers\DatabaseName;
|
||||
use PhpMyAdmin\Message;
|
||||
@ -92,9 +93,7 @@ class ExportTest extends AbstractTestCase
|
||||
|
||||
public function testExportDatabase(): void
|
||||
{
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = false;
|
||||
OutputHandler::$asFile = false;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
@ -150,9 +149,7 @@ class ExportTest extends AbstractTestCase
|
||||
|
||||
public function testExportServer(): void
|
||||
{
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = false;
|
||||
OutputHandler::$asFile = false;
|
||||
$config = Config::getInstance();
|
||||
$config->selectedServer['DisableIS'] = false;
|
||||
$config->selectedServer['only_db'] = '';
|
||||
|
||||
@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportCodegen;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
@ -164,11 +165,7 @@ class ExportCodegenTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['codegen_format' => '1']);
|
||||
|
||||
@ -8,6 +8,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportCsv;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
@ -44,7 +45,6 @@ class ExportCsvTest extends AbstractTestCase
|
||||
Current::$database = '';
|
||||
Current::$table = '';
|
||||
Current::$lang = '';
|
||||
Export::$saveFilename = '';
|
||||
|
||||
$relation = new Relation($dbi);
|
||||
$this->object = new ExportCsv($relation, new Export($dbi), new Transformations($dbi, $relation));
|
||||
@ -255,27 +255,7 @@ class ExportCsvTest extends AbstractTestCase
|
||||
public function testExportData(): void
|
||||
{
|
||||
// case 1
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = true;
|
||||
Export::$fileHandle = null;
|
||||
|
||||
ob_start();
|
||||
self::assertFalse($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
'SELECT * FROM `test_db`.`test_table`;',
|
||||
));
|
||||
ob_get_clean();
|
||||
|
||||
// case 2
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['csv_terminated' => ';', 'csv_columns' => 'On']);
|
||||
|
||||
@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportExcel;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
@ -216,27 +217,7 @@ class ExportExcelTest extends AbstractTestCase
|
||||
public function testExportData(): void
|
||||
{
|
||||
// case 1
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = true;
|
||||
Export::$fileHandle = null;
|
||||
|
||||
ob_start();
|
||||
self::assertFalse($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
'SELECT * FROM `test_db`.`test_table`;',
|
||||
));
|
||||
ob_get_clean();
|
||||
|
||||
// case 2
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['excel_columns' => 'On']);
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Identifiers\TableName;
|
||||
use PhpMyAdmin\Identifiers\TriggerName;
|
||||
@ -63,11 +64,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
new Export($this->dbi),
|
||||
new Transformations($this->dbi, $relation),
|
||||
);
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
Current::$database = '';
|
||||
Current::$table = '';
|
||||
Current::$lang = '';
|
||||
@ -293,11 +290,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
public function testExportData(): void
|
||||
{
|
||||
// case 1
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['htmlword_columns' => 'On']);
|
||||
|
||||
@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Plugins\Export\ExportJson;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
|
||||
@ -35,11 +36,7 @@ class ExportJsonTest extends AbstractTestCase
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
$relation = new Relation($dbi);
|
||||
$this->object = new ExportJson($relation, new Export($dbi), new Transformations($dbi, $relation));
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportLatex;
|
||||
use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
@ -49,11 +50,7 @@ class ExportLatexTest extends AbstractTestCase
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
ExportPlugin::$exportType = ExportType::Table;
|
||||
ExportPlugin::$singleTable = false;
|
||||
Current::$database = 'db';
|
||||
|
||||
@ -9,6 +9,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportMediawiki;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
@ -43,11 +44,7 @@ class ExportMediawikiTest extends AbstractTestCase
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
Current::$database = '';
|
||||
Current::$table = '';
|
||||
Current::$lang = 'en';
|
||||
|
||||
@ -8,6 +8,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportOds;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
@ -52,11 +53,7 @@ class ExportOdsTest extends AbstractTestCase
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
$relation = new Relation($dbi);
|
||||
$this->object = new ExportOds($relation, new Export($dbi), new Transformations($dbi, $relation));
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Identifiers\TableName;
|
||||
use PhpMyAdmin\Identifiers\TriggerName;
|
||||
@ -67,11 +68,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->dummyDbi = $this->createDbiDummy();
|
||||
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
|
||||
DatabaseInterface::$instance = $this->dbi;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
ExportPlugin::$exportType = ExportType::Table;
|
||||
ExportPlugin::$singleTable = false;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = true;
|
||||
|
||||
@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportPdf;
|
||||
use PhpMyAdmin\Plugins\Export\Helpers\Pdf;
|
||||
@ -39,11 +40,7 @@ class ExportPdfTest extends AbstractTestCase
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
$relation = new Relation($dbi);
|
||||
$this->object = new ExportPdf($relation, new Export($dbi), new Transformations($dbi, $relation));
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Plugins\Export\ExportPhparray;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
|
||||
@ -38,11 +39,7 @@ class ExportPhparrayTest extends AbstractTestCase
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$outputCharsetConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = true;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = true;
|
||||
Current::$database = '';
|
||||
Current::$table = '';
|
||||
Current::$lang = 'en';
|
||||
|
||||
@ -13,6 +13,7 @@ use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Exceptions\ExportException;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportSql;
|
||||
use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
@ -67,10 +68,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
Current::$table = '';
|
||||
Current::$lang = 'en';
|
||||
Config::getInstance()->selectedServer['DisableIS'] = true;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = false;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = false;
|
||||
ExportPlugin::$exportType = ExportType::Table;
|
||||
ExportPlugin::$singleTable = false;
|
||||
|
||||
@ -385,8 +383,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
{
|
||||
Current::$charset = 'utf-8';
|
||||
ExportSql::$oldTimezone = 'GMT';
|
||||
Export::$asFile = true;
|
||||
Export::$outputCharsetConversion = true;
|
||||
OutputHandler::$asFile = true;
|
||||
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
@ -416,8 +413,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$config->selectedServer['host'] = 'localhost';
|
||||
$config->selectedServer['port'] = 80;
|
||||
ExportSql::$oldTimezone = 'GMT';
|
||||
Export::$asFile = true;
|
||||
Export::$outputCharsetConversion = true;
|
||||
OutputHandler::$asFile = true;
|
||||
Current::$charset = 'utf-8';
|
||||
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
|
||||
@ -12,6 +12,7 @@ use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Identifiers\TableName;
|
||||
use PhpMyAdmin\Identifiers\TriggerName;
|
||||
@ -58,10 +59,7 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
$this->dummyDbi = $this->createDbiDummy();
|
||||
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
|
||||
DatabaseInterface::$instance = $this->dbi;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = false;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = false;
|
||||
ExportPlugin::$exportType = ExportType::Table;
|
||||
ExportPlugin::$singleTable = false;
|
||||
Current::$database = '';
|
||||
|
||||
@ -9,6 +9,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportXml;
|
||||
use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
@ -43,10 +44,7 @@ class ExportXmlTest extends AbstractTestCase
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = false;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = false;
|
||||
ExportPlugin::$exportType = ExportType::Table;
|
||||
ExportPlugin::$singleTable = false;
|
||||
Current::$database = 'db';
|
||||
@ -168,7 +166,6 @@ class ExportXmlTest extends AbstractTestCase
|
||||
|
||||
public function testExportHeader(): void
|
||||
{
|
||||
Export::$outputCharsetConversion = true;
|
||||
Current::$charset = 'iso-8859-1';
|
||||
$config = Config::getInstance();
|
||||
$config->selectedServer['port'] = 80;
|
||||
@ -290,8 +287,6 @@ class ExportXmlTest extends AbstractTestCase
|
||||
|
||||
// case 2 with isView as true and false
|
||||
|
||||
Export::$outputCharsetConversion = false;
|
||||
|
||||
$dbiDummy->addResult(
|
||||
'SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME`'
|
||||
. " FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME` = 'd<\\\"b' LIMIT 1",
|
||||
@ -408,8 +403,7 @@ class ExportXmlTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
Export::$asFile = true;
|
||||
Export::$outputCharsetConversion = false;
|
||||
OutputHandler::$asFile = true;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['xml_export_contents' => 'On']);
|
||||
|
||||
@ -8,6 +8,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Plugins\Export\ExportYaml;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
|
||||
@ -38,10 +39,7 @@ class ExportYamlTest extends AbstractTestCase
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Export::$outputKanjiConversion = false;
|
||||
Export::$bufferNeeded = false;
|
||||
Export::$asFile = false;
|
||||
Export::$saveOnServer = false;
|
||||
OutputHandler::$asFile = false;
|
||||
Current::$database = '';
|
||||
Current::$table = '';
|
||||
Current::$lang = 'en';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user