Replace Export with OutputHandler

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2025-11-22 15:55:01 +00:00
parent 75ee3e8416
commit f89bfd594a
36 changed files with 122 additions and 137 deletions

View File

@ -9436,7 +9436,7 @@ parameters:
path: src/Plugins/Export/ExportPdf.php
-
message: '#^Parameter \#1 \$line of callable PhpMyAdmin\\Export\\OutputHandler expects string, mixed given\.$#'
message: '#^Parameter \#1 \$line of method PhpMyAdmin\\Export\\OutputHandler\:\:addLine\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Plugins/Export/ExportPdf.php

View File

@ -51,7 +51,7 @@ class OutputHandler
public bool $onFlyCompression = false;
public int $timeStart = 0;
public function __invoke(string $line): bool
public function addLine(string $line): bool
{
// Kanji encoding convert feature
if ($this->outputKanjiConversion) {

View File

@ -78,7 +78,7 @@ class Plugins
/** @psalm-suppress MixedMethodCall */
return new $class(
$container->get(Relation::class),
$container->get(Export::class),
$container->get(Export::class)->outputHandler,
$container->get(Transformations::class),
);
}
@ -158,7 +158,7 @@ class Plugins
$container = ContainerBuilder::getContainer();
$plugins[] = new $class(
$container->get(Relation::class),
$container->get(Export::class),
$container->get(Export::class)->outputHandler,
$container->get(Transformations::class),
);
} elseif ($type === 'Import' && is_subclass_of($class, ImportPlugin::class)) {

View File

@ -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->outputHandler->addLine($this->handleNHibernateXMLBody($db, $table, $aliases));
}
return ($this->export->outputHandler)($this->handleNHibernateCSBody($db, $table, $aliases));
return $this->outputHandler->addLine($this->handleNHibernateCSBody($db, $table, $aliases));
}
/**

View File

@ -164,7 +164,7 @@ class ExportCsv extends ExportPlugin
}
$schemaInsert = implode($this->separator, $insertFields);
if (! ($this->export->outputHandler)($schemaInsert . $this->terminated)) {
if (! $this->outputHandler->addLine($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->outputHandler->addLine($schemaInsert . $this->terminated)) {
return false;
}
}

View File

@ -155,7 +155,7 @@ class ExportExcel extends ExportPlugin
}
$schemaInsert = implode($this->separator, $insertFields);
if (! ($this->export->outputHandler)($schemaInsert . $this->terminated)) {
if (! $this->outputHandler->addLine($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->outputHandler->addLine($schemaInsert . $this->terminated)) {
return false;
}
}

View File

@ -106,7 +106,7 @@ class ExportHtmlword extends ExportPlugin
*/
public function exportHeader(): bool
{
return ($this->export->outputHandler)(
return $this->outputHandler->addLine(
'<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->outputHandler->addLine('</body></html>');
}
/**
@ -142,7 +142,7 @@ class ExportHtmlword extends ExportPlugin
$dbAlias = $db;
}
return ($this->export->outputHandler)(
return $this->outputHandler->addLine(
'<h1>' . __('Database') . ' ' . htmlspecialchars($dbAlias) . '</h1>',
);
}
@ -164,7 +164,7 @@ class ExportHtmlword extends ExportPlugin
$tableAlias = $this->getTableAlias($aliases, $db, $table);
if (
! ($this->export->outputHandler)(
! $this->outputHandler->addLine(
'<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->outputHandler->addLine('<table width="100%" cellspacing="1">')) {
return false;
}
@ -195,7 +195,7 @@ class ExportHtmlword extends ExportPlugin
}
$schemaInsert .= '</tr>';
if (! ($this->export->outputHandler)($schemaInsert)) {
if (! $this->outputHandler->addLine($schemaInsert)) {
return false;
}
}
@ -210,12 +210,12 @@ class ExportHtmlword extends ExportPlugin
}
$schemaInsert .= '</tr>';
if (! ($this->export->outputHandler)($schemaInsert)) {
if (! $this->outputHandler->addLine($schemaInsert)) {
return false;
}
}
return ($this->export->outputHandler)('</table>');
return $this->outputHandler->addLine('</table>');
}
/**
@ -480,7 +480,7 @@ class ExportHtmlword extends ExportPlugin
$dump .= $this->getTableDefStandIn($db, $table, $aliases);
}
return ($this->export->outputHandler)($dump);
return $this->outputHandler->addLine($dump);
}
/**

View File

@ -116,7 +116,7 @@ class ExportJson extends ExportPlugin
return false;
}
return ($this->export->outputHandler)('[' . "\n" . $data . ',' . "\n");
return $this->outputHandler->addLine('[' . "\n" . $data . ',' . "\n");
}
/**
@ -124,7 +124,7 @@ class ExportJson extends ExportPlugin
*/
public function exportFooter(): bool
{
return ($this->export->outputHandler)(']' . "\n");
return $this->outputHandler->addLine(']' . "\n");
}
/**
@ -144,7 +144,7 @@ class ExportJson extends ExportPlugin
return false;
}
return ($this->export->outputHandler)($data . ',' . "\n");
return $this->outputHandler->addLine($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->outputHandler->addLine(',')) {
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->outputHandler->addLine($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->outputHandler->addLine(',' . "\n")) {
return false;
}
}
@ -272,12 +272,12 @@ class ExportJson extends ExportPlugin
return false;
}
if (! ($this->export->outputHandler)($encodedData)) {
if (! $this->outputHandler->addLine($encodedData)) {
return false;
}
}
return ($this->export->outputHandler)("\n" . ']' . "\n" . $footer . "\n");
return $this->outputHandler->addLine("\n" . ']' . "\n" . $footer . "\n");
}
/**

View File

@ -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->outputHandler->addLine($head);
}
/**
@ -252,7 +252,7 @@ class ExportLatex extends ExportPlugin
. '% ' . __('Database:') . ' \'' . $dbAlias . '\'' . "\n"
. '% ' . "\n";
return ($this->export->outputHandler)($head);
return $this->outputHandler->addLine($head);
}
/**
@ -309,7 +309,7 @@ class ExportLatex extends ExportPlugin
. '} \\\\';
}
if (! ($this->export->outputHandler)($buffer)) {
if (! $this->outputHandler->addLine($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->outputHandler->addLine($buffer . ' \\endfirsthead ' . "\n")) {
return false;
}
if ($this->caption) {
if (
! ($this->export->outputHandler)(
! $this->outputHandler->addLine(
'\\caption{'
. Util::expandUserString(
$this->dataContinuedCaption,
@ -342,10 +342,10 @@ class ExportLatex extends ExportPlugin
}
}
if (! ($this->export->outputHandler)($buffer . '\\endhead \\endfoot' . "\n")) {
if (! $this->outputHandler->addLine($buffer . '\\endhead \\endfoot' . "\n")) {
return false;
}
} elseif (! ($this->export->outputHandler)('\\\\ \hline')) {
} elseif (! $this->outputHandler->addLine('\\\\ \hline')) {
return false;
}
@ -370,14 +370,14 @@ class ExportLatex extends ExportPlugin
}
$buffer .= ' \\\\ \\hline ' . "\n";
if (! ($this->export->outputHandler)($buffer)) {
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
}
$buffer = ' \\end{longtable}' . "\n";
return ($this->export->outputHandler)($buffer);
return $this->outputHandler->addLine($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->outputHandler->addLine($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->outputHandler->addLine($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->outputHandler->addLine($buffer)) {
return false;
}
}
$buffer = ' \\end{longtable}' . "\n";
return ($this->export->outputHandler)($buffer);
return $this->outputHandler->addLine($buffer);
}
/**

View File

@ -166,7 +166,7 @@ class ExportMediawiki extends ExportPlugin
$output .= '|}' . str_repeat($this->exportCRLF(), 2);
}
return ($this->export->outputHandler)($output);
return $this->outputHandler->addLine($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->outputHandler->addLine($output);
}
/**

View File

@ -142,7 +142,7 @@ class ExportOds extends ExportPlugin
{
$this->buffer .= '</office:spreadsheet></office:body></office:document-content>';
return ($this->export->outputHandler)(
return $this->outputHandler->addLine(
OpenDocument::create('application/vnd.oasis.opendocument.spreadsheet', $this->buffer),
);
}

View File

@ -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->outputHandler->addLine(OpenDocument::create(
'application/vnd.oasis.opendocument.text',
$this->buffer,
));

View File

@ -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->outputHandler->addLine($this->pdf->getPDFData());
}
/**

View File

@ -78,7 +78,7 @@ class ExportPhparray extends ExportPlugin
*/
public function exportHeader(): bool
{
($this->export->outputHandler)(
$this->outputHandler->addLine(
'<?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->outputHandler->addLine(
'/**' . "\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->outputHandler->addLine($buffer)) {
return false;
}
@ -183,7 +183,7 @@ class ExportPhparray extends ExportPlugin
}
$buffer .= ')';
if (! ($this->export->outputHandler)($buffer)) {
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
@ -193,7 +193,7 @@ class ExportPhparray extends ExportPlugin
$buffer .= "\n" . ');' . "\n";
return ($this->export->outputHandler)($buffer);
return $this->outputHandler->addLine($buffer);
}
/**

View File

@ -650,7 +650,7 @@ class ExportSql extends ExportPlugin
}
if ($text !== '') {
return ($this->export->outputHandler)($text);
return $this->outputHandler->addLine($text);
}
return false;
@ -733,7 +733,7 @@ class ExportSql extends ExportPlugin
DatabaseInterface::getInstance()->query('SET time_zone = "' . self::$oldTimezone . '"');
}
return ($this->export->outputHandler)($foot);
return $this->outputHandler->addLine($foot);
}
/**
@ -829,7 +829,7 @@ class ExportSql extends ExportPlugin
$this->sentCharset = true;
}
return ($this->export->outputHandler)($head);
return $this->outputHandler->addLine($head);
}
/**
@ -846,7 +846,7 @@ class ExportSql extends ExportPlugin
if ($this->structureOrData !== StructureOrData::Data && $this->dropDatabase) {
if (
! ($this->export->outputHandler)(
! $this->outputHandler->addLine(
'DROP DATABASE IF EXISTS '
. Util::backquoteCompat($dbAlias, $this->compatibility, $this->useSqlBackquotes)
. ';' . "\n",
@ -876,7 +876,7 @@ class ExportSql extends ExportPlugin
}
$createQuery .= ';' . "\n";
if (! ($this->export->outputHandler)($createQuery)) {
if (! $this->outputHandler->addLine($createQuery)) {
return false;
}
@ -892,14 +892,14 @@ class ExportSql extends ExportPlugin
private function exportUseStatement(string $db, string $compat): bool
{
if ($compat === 'NONE') {
return ($this->export->outputHandler)(
return $this->outputHandler->addLine(
'USE '
. Util::backquoteCompat($db, $compat, $this->useSqlBackquotes)
. ';' . "\n",
);
}
return ($this->export->outputHandler)('USE ' . $db . ';' . "\n");
return $this->outputHandler->addLine('USE ' . $db . ';' . "\n");
}
/**
@ -925,7 +925,7 @@ class ExportSql extends ExportPlugin
)
. $this->exportComment();
return ($this->export->outputHandler)($head);
return $this->outputHandler->addLine($head);
}
/**
@ -939,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->outputHandler->addLine($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->outputHandler->addLine($this->sqlAutoIncrements);
$this->sqlAutoIncrements = null;
}
//add views to the sql dump file
if ($this->sqlViews !== '') {
$result = ($this->export->outputHandler)($this->sqlViews);
$result = $this->outputHandler->addLine($this->sqlViews);
$this->sqlViews = '';
}
//add constraints to the sql dump file
if ($this->sqlConstraints !== null) {
$result = ($this->export->outputHandler)($this->sqlConstraints);
$result = $this->outputHandler->addLine($this->sqlConstraints);
$this->sqlConstraints = null;
}
@ -1015,7 +1015,7 @@ class ExportSql extends ExportPlugin
}
if ($text !== '') {
return ($this->export->outputHandler)($text);
return $this->outputHandler->addLine($text);
}
return false;
@ -1043,7 +1043,7 @@ class ExportSql extends ExportPlugin
. $this->exportComment()
. $this->exportComment(__('Metadata'))
. $this->exportComment();
if (! ($this->export->outputHandler)($comment)) {
if (! $this->outputHandler->addLine($comment)) {
return false;
}
@ -1121,7 +1121,7 @@ class ExportSql extends ExportPlugin
$comment .= $this->exportComment();
if (! ($this->export->outputHandler)($comment)) {
if (! $this->outputHandler->addLine($comment)) {
return false;
}
@ -1166,7 +1166,7 @@ class ExportSql extends ExportPlugin
$lastPage = "\n"
. 'SET @LAST_PAGE = LAST_INSERT_ID();'
. "\n";
if (! ($this->export->outputHandler)($lastPage)) {
if (! $this->outputHandler->addLine($lastPage)) {
return false;
}
@ -1975,7 +1975,7 @@ class ExportSql extends ExportPlugin
// but not in the case of export
$this->sqlConstraintsQuery = '';
return ($this->export->outputHandler)($dump);
return $this->outputHandler->addLine($dump);
}
/**
@ -2012,7 +2012,7 @@ class ExportSql extends ExportPlugin
. $this->exportComment()
. $this->possibleCRLF();
return ($this->export->outputHandler)($head);
return $this->outputHandler->addLine($head);
}
$result = $dbi->tryQuery($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
@ -2083,8 +2083,8 @@ class ExportSql extends ExportPlugin
)
. $this->exportComment()
. "\n";
($this->export->outputHandler)($truncatehead);
($this->export->outputHandler)($truncate);
$this->outputHandler->addLine($truncatehead);
$this->outputHandler->addLine($truncate);
}
// scheme for inserting fields
@ -2120,7 +2120,7 @@ class ExportSql extends ExportPlugin
)
. $this->exportComment()
. "\n";
if (! ($this->export->outputHandler)($head)) {
if (! $this->outputHandler->addLine($head)) {
return false;
}
}
@ -2128,7 +2128,7 @@ class ExportSql extends ExportPlugin
// We need to SET IDENTITY_INSERT ON for MSSQL
if ($currentRow === 0 && $this->compatibility === 'MSSQL') {
if (
! ($this->export->outputHandler)(
! $this->outputHandler->addLine(
'SET IDENTITY_INSERT '
. Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes)
. ' ON ;' . "\n",
@ -2207,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->outputHandler->addLine(';' . "\n")) {
return false;
}
@ -2223,20 +2223,20 @@ class ExportSql extends ExportPlugin
$insertLine = $schemaInsert . '(' . implode(', ', $values) . ')';
}
if (! ($this->export->outputHandler)(($currentRow === 1 ? '' : $separator . "\n") . $insertLine)) {
if (! $this->outputHandler->addLine(($currentRow === 1 ? '' : $separator . "\n") . $insertLine)) {
return false;
}
}
if ($currentRow > 0) {
if (! ($this->export->outputHandler)(';' . "\n")) {
if (! $this->outputHandler->addLine(';' . "\n")) {
return false;
}
}
// We need to SET IDENTITY_INSERT OFF for MSSQL
if ($this->compatibility === 'MSSQL' && $currentRow > 0) {
$outputSucceeded = ($this->export->outputHandler)(
$outputSucceeded = $this->outputHandler->addLine(
"\n" . 'SET IDENTITY_INSERT '
. Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes)
. ' OFF;' . "\n",

View File

@ -111,7 +111,7 @@ class ExportTexytext extends ExportPlugin
$dbAlias = $db;
}
return ($this->export->outputHandler)(
return $this->outputHandler->addLine(
'===' . __('Database') . ' ' . $dbAlias . "\n\n",
);
}
@ -133,7 +133,7 @@ class ExportTexytext extends ExportPlugin
$tableAlias = $this->getTableAlias($aliases, $db, $table);
if (
! ($this->export->outputHandler)(
! $this->outputHandler->addLine(
$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->outputHandler->addLine($textOutput)) {
return false;
}
}
@ -184,7 +184,7 @@ class ExportTexytext extends ExportPlugin
}
$textOutput .= "\n";
if (! ($this->export->outputHandler)($textOutput)) {
if (! $this->outputHandler->addLine($textOutput)) {
return false;
}
}
@ -429,7 +429,7 @@ class ExportTexytext extends ExportPlugin
$dump .= $this->getTableDefStandIn($db, $table, $aliases);
}
return ($this->export->outputHandler)($dump);
return $this->outputHandler->addLine($dump);
}
/**

View File

@ -194,7 +194,7 @@ class ExportXml extends ExportPlugin
|| $this->exportTriggers
|| $this->exportViews;
$charset = $this->export->outputHandler->outputCharsetConversion ? Current::$charset : 'utf-8';
$charset = $this->outputHandler->outputCharsetConversion ? Current::$charset : 'utf-8';
$config = Config::getInstance();
$head = '<?xml version="1.0" encoding="' . $charset . '"?>' . "\n"
@ -336,7 +336,7 @@ class ExportXml extends ExportPlugin
}
}
return ($this->export->outputHandler)($head);
return $this->outputHandler->addLine($head);
}
/**
@ -346,7 +346,7 @@ class ExportXml extends ExportPlugin
{
$foot = '</pma_xml_export>';
return ($this->export->outputHandler)($foot);
return $this->outputHandler->addLine($foot);
}
/**
@ -368,7 +368,7 @@ class ExportXml extends ExportPlugin
. ' -->' . "\n" . ' <database name="'
. htmlspecialchars($dbAlias) . '">' . "\n";
return ($this->export->outputHandler)($head);
return $this->outputHandler->addLine($head);
}
return true;
@ -382,7 +382,7 @@ class ExportXml extends ExportPlugin
public function exportDBFooter(string $db): bool
{
if ($this->exportContents) {
return ($this->export->outputHandler)(' </database>' . "\n");
return $this->outputHandler->addLine(' </database>' . "\n");
}
return true;
@ -417,7 +417,7 @@ class ExportXml extends ExportPlugin
$buffer = ' <!-- ' . __('Table') . ' '
. htmlspecialchars($tableAlias) . ' -->' . "\n";
if (! ($this->export->outputHandler)($buffer)) {
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
@ -441,7 +441,7 @@ class ExportXml extends ExportPlugin
$buffer .= ' </table>' . "\n";
if (! ($this->export->outputHandler)($buffer)) {
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
}

View File

@ -67,7 +67,7 @@ class ExportYaml extends ExportPlugin
*/
public function exportHeader(): bool
{
($this->export->outputHandler)('%YAML 1.1' . "\n" . '---' . "\n");
$this->outputHandler->addLine('%YAML 1.1' . "\n" . '---' . "\n");
return true;
}
@ -77,7 +77,7 @@ class ExportYaml extends ExportPlugin
*/
public function exportFooter(): bool
{
($this->export->outputHandler)('...' . "\n");
$this->outputHandler->addLine('...' . "\n");
return true;
}
@ -148,7 +148,7 @@ class ExportYaml extends ExportPlugin
$buffer .= ' ' . $columns[$i] . ': "' . $record[$i] . '"' . "\n";
}
if (! ($this->export->outputHandler)($buffer)) {
if (! $this->outputHandler->addLine($buffer)) {
return false;
}
}

View File

@ -8,7 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Plugins;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Export\OutputHandler;
use PhpMyAdmin\Export\StructureOrData;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
@ -37,7 +37,7 @@ abstract class ExportPlugin implements Plugin
final public function __construct(
public Relation $relation,
protected Export $export,
protected OutputHandler $outputHandler,
public Transformations $transformations,
) {
$this->properties = $this->setProperties();

View File

@ -69,7 +69,7 @@ class ExportTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$export = new Export($dbi);
$relation = new Relation($dbi);
$exportPlugin = new ExportPhparray($relation, new Export($dbi), new Transformations($dbi, $relation));
$exportPlugin = new ExportPhparray($relation, $export->outputHandler, new Transformations($dbi, $relation));
$export->outputHandler->setCompression('zip');
$finalFileName = $export->getFinalFilename($exportPlugin, 'myfilename');
@ -88,7 +88,7 @@ class ExportTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$export = new Export($dbi);
$relation = new Relation($dbi);
$exportPlugin = new ExportPhparray($relation, new Export($dbi), new Transformations($dbi, $relation));
$exportPlugin = new ExportPhparray($relation, $export->outputHandler, new Transformations($dbi, $relation));
$export->outputHandler->setCompression('zip');
$mimeType = $export->getMimeType($exportPlugin);
@ -138,7 +138,7 @@ class ExportTest extends AbstractTestCase
['test_table'],
['test_table'],
['test_table'],
new ExportSql($relation, $export, new Transformations($dbi, $relation)),
new ExportSql($relation, $export->outputHandler, new Transformations($dbi, $relation)),
[],
'',
);
@ -208,7 +208,7 @@ class ExportTest extends AbstractTestCase
$relation = new Relation($dbi);
$export->exportServer(
['test_db'],
new ExportSql($relation, $export, new Transformations($dbi, $relation)),
new ExportSql($relation, $export->outputHandler, new Transformations($dbi, $relation)),
[],
'',
);

View File

@ -6,7 +6,6 @@ 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;
@ -41,7 +40,7 @@ class ExportCodegenTest extends AbstractTestCase
$dbi = $this->createDatabaseInterface();
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->object = new ExportCodegen($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportCodegen($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -7,7 +7,6 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
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;
@ -47,7 +46,7 @@ class ExportCsvTest extends AbstractTestCase
Current::$lang = '';
$relation = new Relation($dbi);
$this->object = new ExportCsv($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportCsv($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -6,7 +6,6 @@ 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;
@ -43,7 +42,7 @@ class ExportExcelTest extends AbstractTestCase
$dbi = $this->createDatabaseInterface();
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->object = new ExportExcel($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportExcel($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -10,7 +10,6 @@ use PhpMyAdmin\ConfigStorage\Relation;
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;
@ -61,7 +60,7 @@ class ExportHtmlwordTest extends AbstractTestCase
$relation = new Relation($this->dbi);
$this->object = new ExportHtmlword(
$relation,
new Export($this->dbi),
new OutputHandler(),
new Transformations($this->dbi, $relation),
);
OutputHandler::$asFile = true;
@ -372,7 +371,7 @@ class ExportHtmlwordTest extends AbstractTestCase
$relation = new Relation($this->dbi);
$this->object = $this->getMockBuilder(ExportHtmlword::class)
->onlyMethods(['formatOneColumnDefinition'])
->setConstructorArgs([$relation, new Export($this->dbi), new Transformations($this->dbi, $relation)])
->setConstructorArgs([$relation, new OutputHandler(), new Transformations($this->dbi, $relation)])
->getMock();
$keys = [['Non_unique' => 0, 'Column_name' => 'name1'], ['Non_unique' => 1, 'Column_name' => 'name2']];

View File

@ -6,7 +6,6 @@ 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;
@ -38,7 +37,7 @@ class ExportJsonTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
OutputHandler::$asFile = true;
$relation = new Relation($dbi);
$this->object = new ExportJson($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportJson($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -10,7 +10,6 @@ use PhpMyAdmin\ConfigStorage\Relation;
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;
@ -56,7 +55,7 @@ class ExportLatexTest extends AbstractTestCase
Current::$database = 'db';
Current::$table = 'table';
$relation = new Relation($dbi);
$this->object = new ExportLatex($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportLatex($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -8,7 +8,6 @@ use PhpMyAdmin\Column;
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;
@ -49,7 +48,7 @@ class ExportMediawikiTest extends AbstractTestCase
Current::$table = '';
Current::$lang = 'en';
$relation = new Relation($dbi);
$this->object = new ExportMediawiki($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportMediawiki($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -7,7 +7,6 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
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;
@ -55,7 +54,7 @@ class ExportOdsTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
OutputHandler::$asFile = true;
$relation = new Relation($dbi);
$this->object = new ExportOds($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportOds($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -10,7 +10,6 @@ use PhpMyAdmin\ConfigStorage\Relation;
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;
@ -73,7 +72,7 @@ class ExportOdtTest extends AbstractTestCase
ExportPlugin::$singleTable = false;
Config::getInstance()->selectedServer['DisableIS'] = true;
$relation = new Relation($this->dbi);
$this->object = new ExportOdt($relation, new Export($this->dbi), new Transformations($this->dbi, $relation));
$this->object = new ExportOdt($relation, new OutputHandler(), new Transformations($this->dbi, $relation));
}
/**
@ -571,7 +570,7 @@ class ExportOdtTest extends AbstractTestCase
$relation = new Relation($this->dbi);
$this->object = $this->getMockBuilder(ExportOdt::class)
->onlyMethods(['formatOneColumnDefinition'])
->setConstructorArgs([$relation, new Export($this->dbi), new Transformations($this->dbi, $relation)])
->setConstructorArgs([$relation, new OutputHandler(), new Transformations($this->dbi, $relation)])
->getMock();
// case 1

View File

@ -6,7 +6,6 @@ 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;
@ -42,7 +41,7 @@ class ExportPdfTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
OutputHandler::$asFile = true;
$relation = new Relation($dbi);
$this->object = new ExportPdf($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportPdf($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -7,7 +7,6 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
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;
@ -44,7 +43,7 @@ class ExportPhparrayTest extends AbstractTestCase
Current::$table = '';
Current::$lang = 'en';
$relation = new Relation($dbi);
$this->object = new ExportPhparray($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportPhparray($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -12,7 +12,6 @@ use PhpMyAdmin\Current;
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;
@ -73,7 +72,7 @@ class ExportSqlTest extends AbstractTestCase
ExportPlugin::$singleTable = false;
$relation = new Relation($dbi);
$this->object = new ExportSql($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportSql($relation, new OutputHandler(), new Transformations($dbi, $relation));
$this->object->useSqlBackquotes(false);
}
@ -883,7 +882,7 @@ class ExportSqlTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->object = new ExportSql($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportSql($relation, new OutputHandler(), new Transformations($dbi, $relation));
$this->object->useSqlBackquotes(false);
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')

View File

@ -11,7 +11,6 @@ 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\Http\Factory\ServerRequestFactory;
use PhpMyAdmin\Identifiers\TableName;
@ -69,7 +68,7 @@ class ExportTexytextTest extends AbstractTestCase
$relation = new Relation($this->dbi);
$this->object = new ExportTexytext(
$relation,
new Export($this->dbi),
new OutputHandler(),
new Transformations($this->dbi, $relation),
);
}
@ -261,7 +260,7 @@ class ExportTexytextTest extends AbstractTestCase
$relation = new Relation($this->dbi);
$this->object = $this->getMockBuilder(ExportTexytext::class)
->onlyMethods(['formatOneColumnDefinition'])
->setConstructorArgs([$relation, new Export($this->dbi), new Transformations($this->dbi, $relation)])
->setConstructorArgs([$relation, new OutputHandler(), new Transformations($this->dbi, $relation)])
->getMock();
// case 1

View File

@ -8,7 +8,6 @@ use PhpMyAdmin\Config;
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;
@ -50,7 +49,7 @@ class ExportXmlTest extends AbstractTestCase
Current::$database = 'db';
Config::getInstance()->selectedServer['DisableIS'] = true;
$relation = new Relation($dbi);
$this->object = new ExportXml($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportXml($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -7,7 +7,6 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
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;
@ -44,7 +43,7 @@ class ExportYamlTest extends AbstractTestCase
Current::$table = '';
Current::$lang = 'en';
$relation = new Relation($dbi);
$this->object = new ExportYaml($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object = new ExportYaml($relation, new OutputHandler(), new Transformations($dbi, $relation));
}
/**

View File

@ -7,7 +7,7 @@ namespace PhpMyAdmin\Tests;
use PhpMyAdmin\Config;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Export\OutputHandler;
use PhpMyAdmin\Import\ImportSettings;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportPlugin;
@ -105,12 +105,12 @@ class PluginsTest extends AbstractTestCase
$dbi = DatabaseInterface::getInstance();
$relation = new Relation($dbi);
$transformations = new Transformations($dbi, $relation);
$export = new Export($dbi);
$outputHandler = new OutputHandler();
$exportList = [
new Plugins\Export\ExportJson($relation, $export, $transformations),
new Plugins\Export\ExportOds($relation, $export, $transformations),
new Plugins\Export\ExportSql($relation, $export, $transformations),
new Plugins\Export\ExportXml($relation, $export, $transformations),
new Plugins\Export\ExportJson($relation, $outputHandler, $transformations),
new Plugins\Export\ExportOds($relation, $outputHandler, $transformations),
new Plugins\Export\ExportSql($relation, $outputHandler, $transformations),
new Plugins\Export\ExportXml($relation, $outputHandler, $transformations),
];
$actual = Plugins::getChoice($exportList, 'xml');
$expected = [