Extract DatabaseInterface dep from export plugins
Uses DI instead. Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
parent
19024e17d1
commit
d617866e49
@ -8655,54 +8655,18 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/AuthenticationPluginFactory.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 2
|
||||
path: src/Plugins/Export/ExportCodegen.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#4 \$column of method PhpMyAdmin\\Plugins\\ExportPlugin\:\:getColumnAlias\(\) expects string, string\|null given\.$#'
|
||||
identifier: argument.type
|
||||
count: 2
|
||||
path: src/Plugins/Export/ExportCodegen.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 2
|
||||
path: src/Plugins/Export/ExportCsv.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 2
|
||||
path: src/Plugins/Export/ExportExcel.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#3 \$subject of function str_replace expects array\<string\>\|string, string\|null given\.$#'
|
||||
identifier: argument.type
|
||||
count: 3
|
||||
path: src/Plugins/Export/ExportExcel.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 4
|
||||
path: src/Plugins/Export/ExportHtmlword.php
|
||||
|
||||
-
|
||||
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
|
||||
identifier: notEqual.notAllowed
|
||||
@ -8710,16 +8674,7 @@ parameters:
|
||||
path: src/Plugins/Export/ExportHtmlword.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 2
|
||||
path: src/Plugins/Export/ExportJson.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#4 \$aliases of method PhpMyAdmin\\Plugins\\Export\\ExportJson\:\:doExportForQuery\(\) expects array\<string, array\{tables\: array\<string, array\{columns\: array\<string, string\>\}\>\}\>\|null, array\<mixed\> given\.$#'
|
||||
message: '#^Parameter \#3 \$aliases of method PhpMyAdmin\\Plugins\\Export\\ExportJson\:\:doExportForQuery\(\) expects array\<string, array\{tables\: array\<string, array\{columns\: array\<string, string\>\}\>\}\>\|null, array\<mixed\> given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportJson.php
|
||||
@ -8733,15 +8688,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportLatex.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 4
|
||||
path: src/Plugins/Export/ExportLatex.php
|
||||
|
||||
-
|
||||
message: '#^Cannot call method fetchAssoc\(\) on PhpMyAdmin\\Dbal\\ResultInterface\|false\.$#'
|
||||
identifier: method.nonObject
|
||||
@ -8772,24 +8718,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportLatex.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 3
|
||||
path: src/Plugins/Export/ExportMediawiki.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 2
|
||||
path: src/Plugins/Export/ExportOds.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$string of function bin2hex expects string, string\|null given\.$#'
|
||||
identifier: argument.type
|
||||
@ -8802,15 +8730,6 @@ parameters:
|
||||
count: 3
|
||||
path: src/Plugins/Export/ExportOds.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 5
|
||||
path: src/Plugins/Export/ExportOdt.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in an if condition, array\|false given\.$#'
|
||||
identifier: if.condNotBoolean
|
||||
@ -8841,15 +8760,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportOdt.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportPdf.php
|
||||
|
||||
-
|
||||
message: '#^Class PhpMyAdmin\\Plugins\\Export\\ExportPdf has an uninitialized property \$pdf\. Give it default value or assign it in the constructor\.$#'
|
||||
identifier: property.uninitialized
|
||||
@ -8868,15 +8778,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportPdf.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 2
|
||||
path: src/Plugins/Export/ExportPhparray.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$subject of function preg_match expects string, string\|null given\.$#'
|
||||
identifier: argument.type
|
||||
@ -8892,15 +8793,6 @@ parameters:
|
||||
count: 4
|
||||
path: src/Plugins/Export/ExportSql.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 15
|
||||
path: src/Plugins/Export/ExportSql.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access property \$database on PhpMyAdmin\\SqlParser\\Components\\Expression\|null\.$#'
|
||||
identifier: property.nonObject
|
||||
@ -9039,15 +8931,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportSql.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 5
|
||||
path: src/Plugins/Export/ExportTexytext.php
|
||||
|
||||
-
|
||||
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
|
||||
identifier: empty.notAllowed
|
||||
@ -9069,15 +8952,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportXml.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 3
|
||||
path: src/Plugins/Export/ExportXml.php
|
||||
|
||||
-
|
||||
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
|
||||
identifier: empty.notAllowed
|
||||
@ -9096,15 +8970,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportXml.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 2
|
||||
path: src/Plugins/Export/ExportYaml.php
|
||||
|
||||
-
|
||||
message: '#^Binary operation "\+" between \(float\|int\) and mixed results in an error\.$#'
|
||||
identifier: binaryOp.invalid
|
||||
|
||||
@ -5812,34 +5812,12 @@
|
||||
</UnsafeInstantiation>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportCodegen.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<PossiblyNullArgument>
|
||||
<code><![CDATA[$row[0]]]></code>
|
||||
<code><![CDATA[$row[0]]]></code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportCsv.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportExcel.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportHtmlword.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$comments[$fieldName]]]></code>
|
||||
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
|
||||
@ -5858,10 +5836,6 @@
|
||||
</PossiblyUndefinedVariable>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportJson.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<MixedArgumentTypeCoercion>
|
||||
<code><![CDATA[$aliases]]></code>
|
||||
</MixedArgumentTypeCoercion>
|
||||
@ -5869,10 +5843,6 @@
|
||||
<file src="src/Plugins/Export/ExportLatex.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
|
||||
@ -5899,32 +5869,16 @@
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportMediawiki.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<PossiblyNullOperand>
|
||||
<code><![CDATA[$row[$i]]]></code>
|
||||
</PossiblyNullOperand>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportOds.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<PossiblyNullArgument>
|
||||
<code><![CDATA[$row[$j]]]></code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportOdt.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$comments[$fieldName]]]></code>
|
||||
<code><![CDATA[$foreigner['foreign_field']]]></code>
|
||||
@ -5951,9 +5905,6 @@
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportPdf.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$this->pdf->getPDFData()]]></code>
|
||||
</MixedArgument>
|
||||
@ -5964,12 +5915,6 @@
|
||||
<code><![CDATA[$pdf]]></code>
|
||||
</PropertyNotSetInConstructor>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportPhparray.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportSql.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code><![CDATA[$token->value]]></code>
|
||||
@ -5979,21 +5924,6 @@
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<LessSpecificReturnStatement>
|
||||
<code><![CDATA[(int) $fromConfig]]></code>
|
||||
@ -6056,13 +5986,6 @@
|
||||
</UnnecessaryVarAnnotation>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportTexytext.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$comments[$fieldName]]]></code>
|
||||
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
|
||||
@ -6083,9 +6006,6 @@
|
||||
<file src="src/Plugins/Export/ExportXml.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<InvalidArgument>
|
||||
<code><![CDATA[$events]]></code>
|
||||
@ -6102,12 +6022,6 @@
|
||||
<code><![CDATA[empty($config->selectedServer['port'])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/ExportYaml.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="src/Plugins/Export/Helpers/Pdf.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
|
||||
@ -82,6 +82,7 @@ class Plugins
|
||||
$container->get(Relation::class),
|
||||
$container->get(OutputHandler::class),
|
||||
$container->get(Transformations::class),
|
||||
$container->get(DatabaseInterface::class),
|
||||
);
|
||||
}
|
||||
|
||||
@ -162,6 +163,7 @@ class Plugins
|
||||
$container->get(Relation::class),
|
||||
$container->get(OutputHandler::class),
|
||||
$container->get(Transformations::class),
|
||||
$container->get(DatabaseInterface::class),
|
||||
);
|
||||
} elseif ($type === 'Import' && is_subclass_of($class, ImportPlugin::class)) {
|
||||
$plugins[] = new $class(
|
||||
|
||||
@ -8,7 +8,6 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Plugins\Export;
|
||||
|
||||
use PhpMyAdmin\Config\Settings\Export;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\StructureOrData;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\Plugins\Export\Helpers\TableProperty;
|
||||
@ -144,13 +143,7 @@ class ExportCodegen extends ExportPlugin
|
||||
$dbAlias = $this->getDbAlias($aliases, $db);
|
||||
$tableAlias = $this->getTableAlias($aliases, $db, $table);
|
||||
|
||||
$result = DatabaseInterface::getInstance()->query(
|
||||
sprintf(
|
||||
'DESC %s.%s',
|
||||
Util::backquote($db),
|
||||
Util::backquote($table),
|
||||
),
|
||||
);
|
||||
$result = $this->dbi->query(sprintf('DESC %s.%s', Util::backquote($db), Util::backquote($table)));
|
||||
|
||||
/** @var TableProperty[] $tableProperties */
|
||||
$tableProperties = [];
|
||||
@ -252,13 +245,7 @@ class ExportCodegen extends ExportPlugin
|
||||
$lines[] = ' <class '
|
||||
. 'name="' . self::cgMakeIdentifier($tableAlias) . '" '
|
||||
. 'table="' . self::cgMakeIdentifier($tableAlias) . '">';
|
||||
$result = DatabaseInterface::getInstance()->query(
|
||||
sprintf(
|
||||
'DESC %s.%s',
|
||||
Util::backquote($db),
|
||||
Util::backquote($table),
|
||||
),
|
||||
);
|
||||
$result = $this->dbi->query(sprintf('DESC %s.%s', Util::backquote($db), Util::backquote($table)));
|
||||
|
||||
while ($row = $result->fetchRow()) {
|
||||
$row[0] = $this->getColumnAlias($aliases, $db, $table, $row[0]);
|
||||
|
||||
@ -138,8 +138,7 @@ class ExportCsv extends ExportPlugin
|
||||
string $sqlQuery,
|
||||
array $aliases = [],
|
||||
): void {
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
|
||||
$charsNeedingEnclosure = $this->separator . $this->enclosed . $this->terminated;
|
||||
|
||||
@ -220,7 +219,7 @@ class ExportCsv extends ExportPlugin
|
||||
public function exportRawQuery(string $db, string $sqlQuery): void
|
||||
{
|
||||
if ($db !== '') {
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->exportData($db, '', $sqlQuery);
|
||||
|
||||
@ -134,11 +134,10 @@ class ExportExcel extends ExportPlugin
|
||||
string $sqlQuery,
|
||||
array $aliases = [],
|
||||
): void {
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
/**
|
||||
* Gets the data from the database
|
||||
*/
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if ($this->columns) {
|
||||
@ -218,7 +217,7 @@ class ExportExcel extends ExportPlugin
|
||||
public function exportRawQuery(string $db, string $sqlQuery): void
|
||||
{
|
||||
if ($db !== '') {
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->exportData($db, '', $sqlQuery);
|
||||
|
||||
@ -172,11 +172,10 @@ class ExportHtmlword extends ExportPlugin
|
||||
|
||||
$this->outputHandler->addLine('<table width="100%" cellspacing="1">');
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
/**
|
||||
* Gets the data from the database
|
||||
*/
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if ($this->columns) {
|
||||
@ -240,8 +239,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
* Get the unique keys in the view
|
||||
*/
|
||||
$uniqueKeys = [];
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$keys = $dbi->getTableIndexes($db, $view);
|
||||
$keys = $this->dbi->getTableIndexes($db, $view);
|
||||
foreach ($keys as $key) {
|
||||
if ($key['Non_unique'] != 0) {
|
||||
continue;
|
||||
@ -250,7 +248,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
$uniqueKeys[] = $key['Column_name'];
|
||||
}
|
||||
|
||||
$columns = $dbi->getColumns($db, $view);
|
||||
$columns = $this->dbi->getColumns($db, $view);
|
||||
foreach ($columns as $column) {
|
||||
$colAs = $this->getColumnAlias($aliases, $db, $view, $column->field);
|
||||
|
||||
@ -278,11 +276,10 @@ class ExportHtmlword extends ExportPlugin
|
||||
|
||||
$schemaInsert = '';
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
$dbi->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
$foreigners = $this->doRelation && $relationParameters->relationFeature !== null
|
||||
@ -329,12 +326,12 @@ class ExportHtmlword extends ExportPlugin
|
||||
|
||||
$schemaInsert .= '</tr>';
|
||||
|
||||
$columns = $dbi->getColumns($db, $table);
|
||||
$columns = $this->dbi->getColumns($db, $table);
|
||||
/**
|
||||
* Get the unique keys in the table
|
||||
*/
|
||||
$uniqueKeys = [];
|
||||
$keys = $dbi->getTableIndexes($db, $table);
|
||||
$keys = $this->dbi->getTableIndexes($db, $table);
|
||||
foreach ($keys as $key) {
|
||||
if ($key['Non_unique'] != 0) {
|
||||
continue;
|
||||
@ -447,7 +444,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
$dump .= $this->getTableDef($db, $table, $aliases);
|
||||
break;
|
||||
case 'triggers':
|
||||
$triggers = Triggers::getDetails(DatabaseInterface::getInstance(), $db, $table);
|
||||
$triggers = Triggers::getDetails($this->dbi, $db, $table);
|
||||
if ($triggers !== []) {
|
||||
$dump .= '<h2>'
|
||||
. __('Triggers') . ' ' . htmlspecialchars($tableAlias)
|
||||
|
||||
@ -182,7 +182,7 @@ class ExportJson extends ExportPlugin
|
||||
throw new ExportException('Failure during data export.');
|
||||
}
|
||||
|
||||
$this->doExportForQuery(DatabaseInterface::getInstance(), $sqlQuery, $buffer, $aliases, $db, $table);
|
||||
$this->doExportForQuery($sqlQuery, $buffer, $aliases, $db, $table);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,7 +199,6 @@ class ExportJson extends ExportPlugin
|
||||
* >|null $aliases
|
||||
*/
|
||||
private function doExportForQuery(
|
||||
DatabaseInterface $dbi,
|
||||
string $sqlQuery,
|
||||
string $buffer,
|
||||
array|null $aliases,
|
||||
@ -210,9 +209,9 @@ class ExportJson extends ExportPlugin
|
||||
|
||||
$this->outputHandler->addLine($header . "\n" . '[' . "\n");
|
||||
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$columnsCnt = $result->numFields();
|
||||
$fieldsMeta = $dbi->getFieldsMeta($result);
|
||||
$fieldsMeta = $this->dbi->getFieldsMeta($result);
|
||||
|
||||
$columns = [];
|
||||
foreach ($fieldsMeta as $i => $field) {
|
||||
@ -287,12 +286,11 @@ class ExportJson extends ExportPlugin
|
||||
throw new ExportException('Failure during data export.');
|
||||
}
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
if ($db !== '') {
|
||||
$dbi->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->doExportForQuery($dbi, $sqlQuery, $buffer, null, $db, null);
|
||||
$this->doExportForQuery($sqlQuery, $buffer, null, $db, null);
|
||||
}
|
||||
|
||||
public function setExportOptions(ServerRequest $request, Export $exportConfig): void
|
||||
|
||||
@ -231,7 +231,7 @@ class ExportLatex extends ExportPlugin
|
||||
$head .= "\n"
|
||||
. '% ' . __('Generation Time:') . ' '
|
||||
. Util::localisedDate(new DateTimeImmutable()) . "\n"
|
||||
. '% ' . __('Server version:') . ' ' . DatabaseInterface::getInstance()->getVersionString() . "\n"
|
||||
. '% ' . __('Server version:') . ' ' . $this->dbi->getVersionString() . "\n"
|
||||
. '% ' . __('PHP Version:') . ' ' . PHP_VERSION . "\n";
|
||||
|
||||
$this->outputHandler->addLine($head);
|
||||
@ -273,8 +273,7 @@ class ExportLatex extends ExportPlugin
|
||||
$dbAlias = $this->getDbAlias($aliases, $db);
|
||||
$tableAlias = $this->getTableAlias($aliases, $db, $table);
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$result = $dbi->tryQuery($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->tryQuery($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
|
||||
$columnsCnt = $result->numFields();
|
||||
$columns = [];
|
||||
@ -378,7 +377,7 @@ class ExportLatex extends ExportPlugin
|
||||
public function exportRawQuery(string $db, string $sqlQuery): void
|
||||
{
|
||||
if ($db !== '') {
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->exportData($db, '', $sqlQuery);
|
||||
@ -408,8 +407,7 @@ class ExportLatex extends ExportPlugin
|
||||
* Get the unique keys in the table
|
||||
*/
|
||||
$uniqueKeys = [];
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$keys = $dbi->getTableIndexes($db, $table);
|
||||
$keys = $this->dbi->getTableIndexes($db, $table);
|
||||
foreach ($keys as $key) {
|
||||
if ($key['Non_unique'] != 0) {
|
||||
continue;
|
||||
@ -421,7 +419,7 @@ class ExportLatex extends ExportPlugin
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
$dbi->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
$foreigners = $this->doRelation && $relationParameters->relationFeature !== null ?
|
||||
@ -502,7 +500,7 @@ class ExportLatex extends ExportPlugin
|
||||
|
||||
$this->outputHandler->addLine($buffer);
|
||||
|
||||
$fields = $dbi->getColumns($db, $table);
|
||||
$fields = $this->dbi->getColumns($db, $table);
|
||||
foreach ($fields as $row) {
|
||||
$extractedColumnSpec = Util::extractColumnSpec($row->type);
|
||||
$type = $extractedColumnSpec['print_type'];
|
||||
|
||||
@ -109,7 +109,7 @@ class ExportMediawiki extends ExportPlugin
|
||||
|
||||
$output = '';
|
||||
if ($exportMode === 'create_table') {
|
||||
$columns = DatabaseInterface::getInstance()->getColumns($db, $table);
|
||||
$columns = $this->dbi->getColumns($db, $table);
|
||||
$columns = array_values($columns);
|
||||
|
||||
// Print structure comment
|
||||
@ -204,11 +204,10 @@ class ExportMediawiki extends ExportPlugin
|
||||
$output .= "|+'''" . $tableAlias . "'''" . $this->exportCRLF();
|
||||
}
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
// Add the table headers
|
||||
if ($this->headers) {
|
||||
// Get column names
|
||||
$columnNames = $dbi->getColumnNames($db, $table);
|
||||
$columnNames = $this->dbi->getColumnNames($db, $table);
|
||||
|
||||
// Add column names as table headers
|
||||
if ($columnNames !== []) {
|
||||
@ -225,7 +224,7 @@ class ExportMediawiki extends ExportPlugin
|
||||
}
|
||||
|
||||
// Get the table data from the database
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$fieldsCnt = $result->numFields();
|
||||
|
||||
while ($row = $result->fetchRow()) {
|
||||
@ -253,7 +252,7 @@ class ExportMediawiki extends ExportPlugin
|
||||
public function exportRawQuery(string $db, string $sqlQuery): void
|
||||
{
|
||||
if ($db !== '') {
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->exportData($db, '', $sqlQuery);
|
||||
|
||||
@ -161,11 +161,10 @@ class ExportOds extends ExportPlugin
|
||||
array $aliases = [],
|
||||
): void {
|
||||
$tableAlias = $this->getTableAlias($aliases, $db, $table);
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
// Gets the data from the database
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$fieldsCnt = $result->numFields();
|
||||
$fieldsMeta = $dbi->getFieldsMeta($result);
|
||||
$fieldsMeta = $this->dbi->getFieldsMeta($result);
|
||||
|
||||
$this->buffer .= '<table:table table:name="' . htmlspecialchars($tableAlias) . '">';
|
||||
|
||||
@ -266,7 +265,7 @@ class ExportOds extends ExportPlugin
|
||||
public function exportRawQuery(string $db, string $sqlQuery): void
|
||||
{
|
||||
if ($db !== '') {
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->exportData($db, '', $sqlQuery);
|
||||
|
||||
@ -201,11 +201,10 @@ class ExportOdt extends ExportPlugin
|
||||
array $aliases = [],
|
||||
): void {
|
||||
$tableAlias = $this->getTableAlias($aliases, $db, $table);
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
// Gets the data from the database
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$fieldsCnt = $result->numFields();
|
||||
$fieldsMeta = $dbi->getFieldsMeta($result);
|
||||
$fieldsMeta = $this->dbi->getFieldsMeta($result);
|
||||
|
||||
$this->buffer .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
. ' text:is-list-header="true">';
|
||||
@ -288,7 +287,7 @@ class ExportOdt extends ExportPlugin
|
||||
public function exportRawQuery(string $db, string $sqlQuery): void
|
||||
{
|
||||
if ($db !== '') {
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->exportData($db, '', $sqlQuery);
|
||||
@ -306,11 +305,10 @@ class ExportOdt extends ExportPlugin
|
||||
public function getTableDefStandIn(string $db, string $view, array $aliases = []): string
|
||||
{
|
||||
$viewAlias = $this->getTableAlias($aliases, $db, $view);
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
$dbi->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
|
||||
/**
|
||||
* Displays the table structure
|
||||
@ -336,7 +334,7 @@ class ExportOdt extends ExportPlugin
|
||||
. '</table:table-cell>'
|
||||
. '</table:table-row>';
|
||||
|
||||
$columns = $dbi->getColumns($db, $view);
|
||||
$columns = $this->dbi->getColumns($db, $view);
|
||||
foreach ($columns as $column) {
|
||||
$colAs = $this->getColumnAlias($aliases, $db, $view, $column->field);
|
||||
|
||||
@ -362,11 +360,10 @@ class ExportOdt extends ExportPlugin
|
||||
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
$dbi->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
$foreigners = $this->doRelation && $relationParameters->relationFeature !== null ?
|
||||
@ -428,7 +425,7 @@ class ExportOdt extends ExportPlugin
|
||||
|
||||
$this->buffer .= '</table:table-row>';
|
||||
|
||||
$columns = $dbi->getColumns($db, $table);
|
||||
$columns = $this->dbi->getColumns($db, $table);
|
||||
foreach ($columns as $column) {
|
||||
$fieldName = $column->field;
|
||||
$colAs = $this->getColumnAlias($aliases, $db, $table, $column->field);
|
||||
@ -567,7 +564,7 @@ class ExportOdt extends ExportPlugin
|
||||
$this->getTableDef($db, $table, $aliases);
|
||||
break;
|
||||
case 'triggers':
|
||||
$triggers = Triggers::getDetails(DatabaseInterface::getInstance(), $db, $table);
|
||||
$triggers = Triggers::getDetails($this->dbi, $db, $table);
|
||||
if ($triggers !== []) {
|
||||
$this->buffer .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
. ' text:is-list-header="true">'
|
||||
|
||||
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Plugins\Export;
|
||||
|
||||
use PhpMyAdmin\Config\Settings\Export;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\StructureOrData;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\Plugins\Export\Helpers\Pdf;
|
||||
@ -147,7 +146,7 @@ class ExportPdf extends ExportPlugin
|
||||
|
||||
if ($db !== '') {
|
||||
$this->pdf->setCurrentDb($db);
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->pdf->mysqlReport($sqlQuery);
|
||||
|
||||
@ -124,8 +124,7 @@ class ExportPhparray extends ExportPlugin
|
||||
$dbAlias = $this->getDbAlias($aliases, $db);
|
||||
$tableAlias = $this->getTableAlias($aliases, $db, $table);
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
|
||||
$columnsCnt = $result->numFields();
|
||||
$columns = [];
|
||||
@ -198,7 +197,7 @@ class ExportPhparray extends ExportPlugin
|
||||
public function exportRawQuery(string $db, string $sqlQuery): void
|
||||
{
|
||||
if ($db !== '') {
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->exportData($db, '', $sqlQuery);
|
||||
|
||||
@ -252,9 +252,8 @@ class ExportSql extends ExportPlugin
|
||||
);
|
||||
$generalOptions->addProperty($leaf);
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
// compatibility maximization
|
||||
$compats = $dbi->getCompatibilities();
|
||||
$compats = $this->dbi->getCompatibilities();
|
||||
if ($compats !== []) {
|
||||
$this->addCompatOptions($compats, $generalOptions);
|
||||
}
|
||||
@ -309,7 +308,7 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
|
||||
if (ExportPlugin::$exportType === ExportType::Table) {
|
||||
$dropClause = $dbi->getTable(Current::$database, Current::$table)->isView()
|
||||
$dropClause = $this->dbi->getTable(Current::$database, Current::$table)->isView()
|
||||
? '<code>DROP VIEW</code>'
|
||||
: '<code>DROP TABLE</code>';
|
||||
} else {
|
||||
@ -566,11 +565,10 @@ class ExportSql extends ExportPlugin
|
||||
. $delimiter . "\n";
|
||||
}
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
if ($type === 'FUNCTION') {
|
||||
$definition = Routines::getFunctionDefinition($dbi, $db, $routine);
|
||||
$definition = Routines::getFunctionDefinition($this->dbi, $db, $routine);
|
||||
} else {
|
||||
$definition = Routines::getProcedureDefinition($dbi, $db, $routine);
|
||||
$definition = Routines::getProcedureDefinition($this->dbi, $db, $routine);
|
||||
}
|
||||
|
||||
$flag = false;
|
||||
@ -621,9 +619,8 @@ class ExportSql extends ExportPlugin
|
||||
$text = '';
|
||||
$delimiter = '$$';
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$procedureNames = Routines::getNames($dbi, $db, RoutineType::Procedure);
|
||||
$functionNames = Routines::getNames($dbi, $db, RoutineType::Function);
|
||||
$procedureNames = Routines::getNames($this->dbi, $db, RoutineType::Procedure);
|
||||
$functionNames = Routines::getNames($this->dbi, $db, RoutineType::Function);
|
||||
|
||||
if ($procedureNames || $functionNames) {
|
||||
$text .= "\n"
|
||||
@ -735,7 +732,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
/* Restore timezone */
|
||||
if ($this->utcTime) {
|
||||
DatabaseInterface::getInstance()->query('SET time_zone = "' . self::$oldTimezone . '"');
|
||||
$this->dbi->query('SET time_zone = "' . self::$oldTimezone . '"');
|
||||
}
|
||||
|
||||
$this->outputHandler->addLine($foot);
|
||||
@ -747,9 +744,7 @@ class ExportSql extends ExportPlugin
|
||||
*/
|
||||
public function exportHeader(): void
|
||||
{
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
|
||||
$dbi->tryQuery('SET SQL_MODE="' . ($this->compatibility !== 'NONE' ? $this->compatibility : '') . '"');
|
||||
$this->dbi->tryQuery('SET SQL_MODE="' . ($this->compatibility !== 'NONE' ? $this->compatibility : '') . '"');
|
||||
|
||||
$head = $this->exportComment('phpMyAdmin SQL Dump')
|
||||
. $this->exportComment('version ' . Version::VERSION)
|
||||
@ -767,7 +762,7 @@ class ExportSql extends ExportPlugin
|
||||
. Util::localisedDate(new DateTimeImmutable()),
|
||||
)
|
||||
. $this->exportComment(
|
||||
__('Server version:') . ' ' . $dbi->getVersionString(),
|
||||
__('Server version:') . ' ' . $this->dbi->getVersionString(),
|
||||
)
|
||||
. $this->exportComment(__('PHP Version:') . ' ' . PHP_VERSION)
|
||||
. $this->possibleCRLF();
|
||||
@ -801,8 +796,8 @@ class ExportSql extends ExportPlugin
|
||||
/* Change timezone if we should export timestamps in UTC */
|
||||
if ($this->utcTime) {
|
||||
$head .= 'SET time_zone = "+00:00";' . "\n";
|
||||
self::$oldTimezone = $dbi->fetchValue('SELECT @@session.time_zone');
|
||||
$dbi->query('SET time_zone = "+00:00"');
|
||||
self::$oldTimezone = $this->dbi->fetchValue('SELECT @@session.time_zone');
|
||||
$this->dbi->query('SET time_zone = "+00:00"');
|
||||
}
|
||||
|
||||
$head .= $this->possibleCRLF();
|
||||
@ -820,7 +815,7 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
|
||||
if ($setNames === 'utf8') {
|
||||
$setNames = $dbi->getDefaultCharset();
|
||||
$setNames = $this->dbi->getDefaultCharset();
|
||||
}
|
||||
|
||||
$head .= "\n"
|
||||
@ -863,7 +858,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
$createQuery = 'CREATE DATABASE IF NOT EXISTS '
|
||||
. Util::backquoteCompat($dbAlias, $this->compatibility, $this->useSqlBackquotes);
|
||||
$collation = DatabaseInterface::getInstance()->getDbCollation($db);
|
||||
$collation = $this->dbi->getDbCollation($db);
|
||||
if (str_contains($collation, '_')) {
|
||||
$createQuery .= ' DEFAULT CHARACTER SET '
|
||||
. mb_substr(
|
||||
@ -977,10 +972,9 @@ class ExportSql extends ExportPlugin
|
||||
$text = '';
|
||||
$delimiter = '$$';
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$eventNames = $dbi->fetchSingleColumn(
|
||||
$eventNames = $this->dbi->fetchSingleColumn(
|
||||
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE'
|
||||
. ' EVENT_SCHEMA= ' . $dbi->quoteString($db),
|
||||
. ' EVENT_SCHEMA= ' . $this->dbi->quoteString($db),
|
||||
);
|
||||
|
||||
if ($eventNames !== []) {
|
||||
@ -998,7 +992,7 @@ class ExportSql extends ExportPlugin
|
||||
. $delimiter . "\n";
|
||||
}
|
||||
|
||||
$eventDef = Events::getDefinition($dbi, $db, $eventName);
|
||||
$eventDef = Events::getDefinition($this->dbi, $db, $eventName);
|
||||
if (
|
||||
$eventDef !== null
|
||||
&& $eventDef !== ''
|
||||
@ -1129,7 +1123,6 @@ class ExportSql extends ExportPlugin
|
||||
continue;
|
||||
}
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
// special case, designer pages and their coordinates
|
||||
if ($type === RelationParameters::PDF_PAGES) {
|
||||
if ($relationParameters->pdfFeature === null) {
|
||||
@ -1139,16 +1132,16 @@ class ExportSql extends ExportPlugin
|
||||
$sqlQuery = 'SELECT `page_nr`, `page_descr` FROM '
|
||||
. Util::backquote($relationParameters->pdfFeature->database)
|
||||
. '.' . Util::backquote($relationParameters->pdfFeature->pdfPages)
|
||||
. ' WHERE `db_name` = ' . $dbi->quoteString($db);
|
||||
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db);
|
||||
|
||||
$result = $dbi->fetchResult($sqlQuery, 'page_nr', 'page_descr');
|
||||
$result = $this->dbi->fetchResult($sqlQuery, 'page_nr', 'page_descr');
|
||||
|
||||
foreach (array_keys($result) as $page) {
|
||||
// insert row for pdf_page
|
||||
$sqlQueryRow = 'SELECT `db_name`, `page_descr` FROM '
|
||||
. Util::backquote($relationParameters->pdfFeature->database)
|
||||
. '.' . Util::backquote($relationParameters->pdfFeature->pdfPages)
|
||||
. ' WHERE `db_name` = ' . $dbi->quoteString($db)
|
||||
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db)
|
||||
. ' AND `page_nr` = ' . (int) $page;
|
||||
|
||||
$this->exportData(
|
||||
@ -1198,9 +1191,9 @@ class ExportSql extends ExportPlugin
|
||||
$sqlQuery .= Util::backquote($relationParameters->db)
|
||||
. '.' . Util::backquote((string) $relationParams[$type])
|
||||
. ' WHERE ' . Util::backquote($dbNameColumn)
|
||||
. ' = ' . $dbi->quoteString($db);
|
||||
. ' = ' . $this->dbi->quoteString($db);
|
||||
if ($table !== null) {
|
||||
$sqlQuery .= ' AND `table_name` = ' . $dbi->quoteString($table);
|
||||
$sqlQuery .= ' AND `table_name` = ' . $this->dbi->quoteString($table);
|
||||
}
|
||||
|
||||
$this->exportData((string) $relationParameters->db, (string) $relationParams[$type], $sqlQuery, $aliases);
|
||||
@ -1234,7 +1227,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
$createQuery .= Util::backquote($viewAlias) . ' (' . "\n";
|
||||
$tmp = [];
|
||||
$columns = DatabaseInterface::getInstance()->getColumns($db, $view);
|
||||
$columns = $this->dbi->getColumns($db, $view);
|
||||
foreach ($columns as $column) {
|
||||
$colAlias = $this->getColumnAlias($aliases, $db, $view, $column->field);
|
||||
|
||||
@ -1266,8 +1259,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
$createQuery .= Util::backquote($viewAlias) . '(' . "\n";
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$columns = $dbi->getColumns($db, $view);
|
||||
$columns = $this->dbi->getColumns($db, $view);
|
||||
|
||||
$firstCol = true;
|
||||
foreach ($columns as $column) {
|
||||
@ -1290,13 +1282,13 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
|
||||
if ($column->default !== null) {
|
||||
$createQuery .= ' DEFAULT ' . $dbi->quoteString($column->default);
|
||||
$createQuery .= ' DEFAULT ' . $this->dbi->quoteString($column->default);
|
||||
} elseif ($column->isNull) {
|
||||
$createQuery .= ' DEFAULT NULL';
|
||||
}
|
||||
|
||||
if ($column->comment !== '') {
|
||||
$createQuery .= ' COMMENT ' . $dbi->quoteString($column->comment);
|
||||
$createQuery .= ' COMMENT ' . $this->dbi->quoteString($column->comment);
|
||||
}
|
||||
|
||||
$firstCol = false;
|
||||
@ -1337,15 +1329,14 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
$schemaCreate = $this->getTableStatus($db, $table);
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
if ($this->dropTable && $dbi->getTable($db, $table)->isView()) {
|
||||
if ($this->dropTable && $this->dbi->getTable($db, $table)->isView()) {
|
||||
$schemaCreate .= 'DROP VIEW IF EXISTS '
|
||||
. Util::backquoteCompat($tableAlias, 'NONE', $this->useSqlBackquotes) . ';'
|
||||
. "\n";
|
||||
}
|
||||
|
||||
// no need to generate a DROP VIEW here, it was done earlier
|
||||
if ($this->dropTable && ! $dbi->getTable($db, $table)->isView()) {
|
||||
if ($this->dropTable && ! $this->dbi->getTable($db, $table)->isView()) {
|
||||
$schemaCreate .= 'DROP TABLE IF EXISTS '
|
||||
. Util::backquoteCompat($tableAlias, 'NONE', $this->useSqlBackquotes) . ';'
|
||||
. "\n";
|
||||
@ -1354,9 +1345,9 @@ class ExportSql extends ExportPlugin
|
||||
// Complete table dump,
|
||||
// Whether to quote table and column names or not
|
||||
if ($this->useSqlBackquotes) {
|
||||
$dbi->query('SET SQL_QUOTE_SHOW_CREATE = 1');
|
||||
$this->dbi->query('SET SQL_QUOTE_SHOW_CREATE = 1');
|
||||
} else {
|
||||
$dbi->query('SET SQL_QUOTE_SHOW_CREATE = 0');
|
||||
$this->dbi->query('SET SQL_QUOTE_SHOW_CREATE = 0');
|
||||
}
|
||||
|
||||
// I don't see the reason why this unbuffered query could cause problems,
|
||||
@ -1369,13 +1360,13 @@ class ExportSql extends ExportPlugin
|
||||
// Note: SHOW CREATE TABLE, at least in MySQL 5.1.23, does not
|
||||
// produce a displayable result for the default value of a BIT
|
||||
// column, nor does the mysqldump command. See MySQL bug 35796
|
||||
$dbi->tryQuery('USE ' . Util::backquote($db));
|
||||
$result = $dbi->tryQuery(
|
||||
$this->dbi->tryQuery('USE ' . Util::backquote($db));
|
||||
$result = $this->dbi->tryQuery(
|
||||
'SHOW CREATE TABLE ' . Util::backquote($db) . '.'
|
||||
. Util::backquote($table),
|
||||
);
|
||||
// an error can happen, for example the table is crashed
|
||||
$tmpError = $dbi->getError();
|
||||
$tmpError = $this->dbi->getError();
|
||||
if ($tmpError !== '') {
|
||||
$message = sprintf(__('Error reading structure for table %s:'), $db . '.' . $table);
|
||||
$message .= ' ' . $tmpError;
|
||||
@ -1814,7 +1805,7 @@ class ExportSql extends ExportPlugin
|
||||
public function exportRawQuery(string $db, string $sqlQuery): void
|
||||
{
|
||||
if ($db !== '') {
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->exportData($db, '', $sqlQuery);
|
||||
@ -1857,7 +1848,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
$dump = '';
|
||||
$delimiter = '$$';
|
||||
$triggers = Triggers::getDetails(DatabaseInterface::getInstance(), $db, $table);
|
||||
$triggers = Triggers::getDetails($this->dbi, $db, $table);
|
||||
if ($triggers !== []) {
|
||||
$dump .= $this->possibleCRLF()
|
||||
. $this->exportComment()
|
||||
@ -1984,9 +1975,8 @@ class ExportSql extends ExportPlugin
|
||||
string $sqlQuery,
|
||||
array $aliases = [],
|
||||
): void {
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
// Do not export data for merge tables
|
||||
if ($dbi->getTable($db, $table)->isMerge()) {
|
||||
if ($this->dbi->getTable($db, $table)->isMerge()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1996,7 +1986,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
// Do not export data for a VIEW, unless asked to export the view as a table
|
||||
// (For a VIEW, this is called only when exporting a single VIEW)
|
||||
if ($dbi->getTable($db, $table)->isView() && ! $this->viewsAsTables) {
|
||||
if ($this->dbi->getTable($db, $table)->isView() && ! $this->viewsAsTables) {
|
||||
$head = $this->possibleCRLF()
|
||||
. $this->exportComment()
|
||||
. $this->exportComment('VIEW ' . $formattedTableName)
|
||||
@ -2009,9 +1999,9 @@ class ExportSql extends ExportPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
$result = $dbi->tryQuery($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->tryQuery($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
// a possible error: the table has crashed
|
||||
$tmpError = $dbi->getError();
|
||||
$tmpError = $this->dbi->getError();
|
||||
if ($tmpError !== '') {
|
||||
$message = sprintf(__('Error reading data for table %s:'), $db . '.' . $table);
|
||||
$message .= ' ' . $tmpError;
|
||||
@ -2026,7 +2016,7 @@ class ExportSql extends ExportPlugin
|
||||
$fieldsCnt = $result->numFields();
|
||||
|
||||
// Get field information
|
||||
$fieldsMeta = $dbi->getFieldsMeta($result);
|
||||
$fieldsMeta = $this->dbi->getFieldsMeta($result);
|
||||
|
||||
$fieldSet = [];
|
||||
/** @infection-ignore-all */
|
||||
@ -2164,7 +2154,7 @@ class ExportSql extends ExportPlugin
|
||||
$values[] = "''";
|
||||
} else {
|
||||
// something else -> treat as a string
|
||||
$values[] = $dbi->quoteString($row[$j]);
|
||||
$values[] = $this->dbi->quoteString($row[$j]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2532,10 +2522,9 @@ class ExportSql extends ExportPlugin
|
||||
$newCrlf = "\n";
|
||||
$schemaCreate = '';
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$result = $dbi->tryQuery(
|
||||
$result = $this->dbi->tryQuery(
|
||||
'SHOW TABLE STATUS FROM ' . Util::backquote($db)
|
||||
. ' WHERE Name = ' . $dbi->quoteString($table),
|
||||
. ' WHERE Name = ' . $this->dbi->quoteString($table),
|
||||
);
|
||||
if ($result !== false && $result->numRows() > 0) {
|
||||
$tmpres = $result->fetchAssoc();
|
||||
|
||||
@ -139,11 +139,10 @@ class ExportTexytext extends ExportPlugin
|
||||
: '==' . __('Dumping data for query result') . "\n\n",
|
||||
);
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
/**
|
||||
* Gets the data from the database
|
||||
*/
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if ($this->columns) {
|
||||
@ -192,7 +191,7 @@ class ExportTexytext extends ExportPlugin
|
||||
public function exportRawQuery(string $db, string $sqlQuery): void
|
||||
{
|
||||
if ($db !== '') {
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->exportData($db, '', $sqlQuery);
|
||||
@ -215,8 +214,7 @@ class ExportTexytext extends ExportPlugin
|
||||
* Get the unique keys in the table
|
||||
*/
|
||||
$uniqueKeys = [];
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$keys = $dbi->getTableIndexes($db, $view);
|
||||
$keys = $this->dbi->getTableIndexes($db, $view);
|
||||
foreach ($keys as $key) {
|
||||
if ($key['Non_unique'] != 0) {
|
||||
continue;
|
||||
@ -228,7 +226,7 @@ class ExportTexytext extends ExportPlugin
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
$dbi->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
|
||||
/**
|
||||
* Displays the table structure
|
||||
@ -241,7 +239,7 @@ class ExportTexytext extends ExportPlugin
|
||||
. '|' . __('Default')
|
||||
. "\n|------\n";
|
||||
|
||||
$columns = $dbi->getColumns($db, $view);
|
||||
$columns = $this->dbi->getColumns($db, $view);
|
||||
foreach ($columns as $column) {
|
||||
$colAs = $this->getColumnAlias($aliases, $db, $view, $column->field);
|
||||
|
||||
@ -271,8 +269,7 @@ class ExportTexytext extends ExportPlugin
|
||||
* Get the unique keys in the table
|
||||
*/
|
||||
$uniqueKeys = [];
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$keys = $dbi->getTableIndexes($db, $table);
|
||||
$keys = $this->dbi->getTableIndexes($db, $table);
|
||||
foreach ($keys as $key) {
|
||||
if ($key['Non_unique'] != 0) {
|
||||
continue;
|
||||
@ -284,7 +281,7 @@ class ExportTexytext extends ExportPlugin
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
$dbi->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
$foreigners = $this->doRelation && $relationParameters->relationFeature !== null ?
|
||||
@ -316,7 +313,7 @@ class ExportTexytext extends ExportPlugin
|
||||
|
||||
$textOutput .= "\n|------\n";
|
||||
|
||||
$columns = $dbi->getColumns($db, $table);
|
||||
$columns = $this->dbi->getColumns($db, $table);
|
||||
foreach ($columns as $column) {
|
||||
$colAs = $this->getColumnAlias($aliases, $db, $table, $column->field);
|
||||
|
||||
@ -402,7 +399,7 @@ class ExportTexytext extends ExportPlugin
|
||||
$dump .= $this->getTableDef($db, $table, $aliases);
|
||||
break;
|
||||
case 'triggers':
|
||||
$triggers = Triggers::getDetails(DatabaseInterface::getInstance(), $db, $table);
|
||||
$triggers = Triggers::getDetails($this->dbi, $db, $table);
|
||||
if ($triggers !== []) {
|
||||
$dump .= '== ' . __('Triggers') . ' ' . $tableAlias . "\n\n";
|
||||
$dump .= $this->getTriggers($triggers);
|
||||
|
||||
@ -156,11 +156,10 @@ class ExportXml extends ExportPlugin
|
||||
foreach ($names as $name) {
|
||||
$head .= ' <pma:' . $type . ' name="' . htmlspecialchars($name) . '">' . "\n";
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$definition = match ($type) {
|
||||
'function' => Routines::getFunctionDefinition($dbi, $db, $name),
|
||||
'procedure' => Routines::getProcedureDefinition($dbi, $db, $name),
|
||||
default => Events::getDefinition($dbi, $db, $name),
|
||||
'function' => Routines::getFunctionDefinition($this->dbi, $db, $name),
|
||||
'procedure' => Routines::getProcedureDefinition($this->dbi, $db, $name),
|
||||
default => Events::getDefinition($this->dbi, $db, $name),
|
||||
};
|
||||
|
||||
// Do some formatting
|
||||
@ -200,11 +199,10 @@ class ExportXml extends ExportPlugin
|
||||
$head .= ':' . $config->selectedServer['port'];
|
||||
}
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$head .= "\n"
|
||||
. '- ' . __('Generation Time:') . ' '
|
||||
. Util::localisedDate(new DateTimeImmutable()) . "\n"
|
||||
. '- ' . __('Server version:') . ' ' . $dbi->getVersionString() . "\n"
|
||||
. '- ' . __('Server version:') . ' ' . $this->dbi->getVersionString() . "\n"
|
||||
. '- ' . __('PHP Version:') . ' ' . PHP_VERSION . "\n"
|
||||
. '-->' . "\n\n";
|
||||
|
||||
@ -215,10 +213,10 @@ class ExportXml extends ExportPlugin
|
||||
. '>' . "\n";
|
||||
|
||||
if ($exportStruct) {
|
||||
$result = $dbi->fetchSingleRow(
|
||||
$result = $this->dbi->fetchSingleRow(
|
||||
'SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME`'
|
||||
. ' FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`'
|
||||
. ' = ' . $dbi->quoteString(Current::$database) . ' LIMIT 1',
|
||||
. ' = ' . $this->dbi->quoteString(Current::$database) . ' LIMIT 1',
|
||||
);
|
||||
$dbCollation = $result['DEFAULT_COLLATION_NAME'];
|
||||
$dbCharset = $result['DEFAULT_CHARACTER_SET_NAME'];
|
||||
@ -237,7 +235,7 @@ class ExportXml extends ExportPlugin
|
||||
|
||||
foreach ($this->tables as $table) {
|
||||
// Export tables and views
|
||||
$result = $dbi->fetchResult(
|
||||
$result = $this->dbi->fetchResult(
|
||||
'SHOW CREATE TABLE ' . Util::backquote(Current::$database) . '.'
|
||||
. Util::backquote($table),
|
||||
0,
|
||||
@ -249,7 +247,7 @@ class ExportXml extends ExportPlugin
|
||||
|
||||
$tbl = (string) $result[$table][1];
|
||||
|
||||
$isView = $dbi->getTable(Current::$database, $table)->isView();
|
||||
$isView = $this->dbi->getTable(Current::$database, $table)->isView();
|
||||
|
||||
$type = $isView ? 'view' : 'table';
|
||||
|
||||
@ -275,7 +273,7 @@ class ExportXml extends ExportPlugin
|
||||
}
|
||||
|
||||
// Export triggers
|
||||
$triggers = Triggers::getDetails($dbi, Current::$database, $table);
|
||||
$triggers = Triggers::getDetails($this->dbi, Current::$database, $table);
|
||||
|
||||
foreach ($triggers as $trigger) {
|
||||
$code = $trigger->getCreateSql();
|
||||
@ -298,7 +296,7 @@ class ExportXml extends ExportPlugin
|
||||
$head .= $this->exportDefinitions(
|
||||
Current::$database,
|
||||
'function',
|
||||
Routines::getNames($dbi, Current::$database, RoutineType::Function),
|
||||
Routines::getNames($this->dbi, Current::$database, RoutineType::Function),
|
||||
);
|
||||
}
|
||||
|
||||
@ -306,15 +304,15 @@ class ExportXml extends ExportPlugin
|
||||
$head .= $this->exportDefinitions(
|
||||
Current::$database,
|
||||
'procedure',
|
||||
Routines::getNames($dbi, Current::$database, RoutineType::Procedure),
|
||||
Routines::getNames($this->dbi, Current::$database, RoutineType::Procedure),
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->exportEvents) {
|
||||
// Export events
|
||||
$events = $dbi->fetchSingleColumn(
|
||||
$events = $this->dbi->fetchSingleColumn(
|
||||
'SELECT EVENT_NAME FROM information_schema.EVENTS '
|
||||
. 'WHERE EVENT_SCHEMA=' . $dbi->quoteString(Current::$database),
|
||||
. 'WHERE EVENT_SCHEMA=' . $this->dbi->quoteString(Current::$database),
|
||||
);
|
||||
$head .= $this->exportDefinitions(Current::$database, 'event', $events);
|
||||
}
|
||||
@ -393,9 +391,8 @@ class ExportXml extends ExportPlugin
|
||||
string $sqlQuery,
|
||||
array $aliases = [],
|
||||
): void {
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
// Do not export data for merge tables
|
||||
if ($dbi->getTable($db, $table)->isMerge()) {
|
||||
if ($this->dbi->getTable($db, $table)->isMerge()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -404,7 +401,7 @@ class ExportXml extends ExportPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
|
||||
$columnsCnt = $result->numFields();
|
||||
$columns = $result->getFieldNames();
|
||||
|
||||
@ -95,11 +95,10 @@ class ExportYaml extends ExportPlugin
|
||||
): void {
|
||||
$dbAlias = $this->getDbAlias($aliases, $db);
|
||||
$tableAlias = $this->getTableAlias($aliases, $db, $table);
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$result = $this->dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
|
||||
|
||||
$columnsCnt = $result->numFields();
|
||||
$fieldsMeta = $dbi->getFieldsMeta($result);
|
||||
$fieldsMeta = $this->dbi->getFieldsMeta($result);
|
||||
|
||||
$columns = [];
|
||||
foreach ($fieldsMeta as $i => $field) {
|
||||
@ -158,7 +157,7 @@ class ExportYaml extends ExportPlugin
|
||||
public function exportRawQuery(string $db, string $sqlQuery): void
|
||||
{
|
||||
if ($db !== '') {
|
||||
DatabaseInterface::getInstance()->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
|
||||
$this->exportData($db, '', $sqlQuery);
|
||||
|
||||
@ -10,6 +10,7 @@ namespace PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Config\Settings\Export;
|
||||
use PhpMyAdmin\ConfigStorage\Foreigners;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Export\StructureOrData;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
@ -41,6 +42,7 @@ abstract class ExportPlugin implements Plugin
|
||||
protected readonly Relation $relation,
|
||||
protected readonly OutputHandler $outputHandler,
|
||||
protected readonly Transformations $transformations,
|
||||
protected readonly DatabaseInterface $dbi,
|
||||
) {
|
||||
$this->properties = $this->setProperties();
|
||||
}
|
||||
|
||||
@ -70,7 +70,12 @@ class ExportTest extends AbstractTestCase
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$export = new Export($dbi, new OutputHandler());
|
||||
$relation = new Relation($dbi);
|
||||
$exportPlugin = new ExportPhparray($relation, $export->outputHandler, new Transformations($dbi, $relation));
|
||||
$exportPlugin = new ExportPhparray(
|
||||
$relation,
|
||||
$export->outputHandler,
|
||||
new Transformations($dbi, $relation),
|
||||
$dbi,
|
||||
);
|
||||
|
||||
$export->outputHandler->setCompression('zip');
|
||||
$finalFileName = $export->getFinalFilename($exportPlugin, 'myfilename');
|
||||
@ -89,7 +94,12 @@ class ExportTest extends AbstractTestCase
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$export = new Export($dbi, new OutputHandler());
|
||||
$relation = new Relation($dbi);
|
||||
$exportPlugin = new ExportPhparray($relation, $export->outputHandler, new Transformations($dbi, $relation));
|
||||
$exportPlugin = new ExportPhparray(
|
||||
$relation,
|
||||
$export->outputHandler,
|
||||
new Transformations($dbi, $relation),
|
||||
$dbi,
|
||||
);
|
||||
|
||||
$export->outputHandler->setCompression('zip');
|
||||
$mimeType = $export->getMimeType($exportPlugin);
|
||||
@ -139,7 +149,7 @@ class ExportTest extends AbstractTestCase
|
||||
['test_table'],
|
||||
['test_table'],
|
||||
['test_table'],
|
||||
new ExportSql($relation, $export->outputHandler, new Transformations($dbi, $relation)),
|
||||
new ExportSql($relation, $export->outputHandler, new Transformations($dbi, $relation), $dbi),
|
||||
[],
|
||||
SeparateFiles::None,
|
||||
);
|
||||
@ -209,7 +219,7 @@ class ExportTest extends AbstractTestCase
|
||||
$relation = new Relation($dbi);
|
||||
$export->exportServer(
|
||||
['test_db'],
|
||||
new ExportSql($relation, $export->outputHandler, new Transformations($dbi, $relation)),
|
||||
new ExportSql($relation, $export->outputHandler, new Transformations($dbi, $relation), $dbi),
|
||||
[],
|
||||
SeparateFiles::None,
|
||||
);
|
||||
|
||||
@ -7,7 +7,6 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\Settings\Export;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportCodegen;
|
||||
@ -148,10 +147,7 @@ final class ExportCodegenTest extends AbstractTestCase
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['codegen_format' => '1']);
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportCodegen = $this->getExportCodegen($dbi);
|
||||
$exportCodegen = $this->getExportCodegen();
|
||||
$exportCodegen->setExportOptions($request, new Export());
|
||||
|
||||
ob_start();
|
||||
@ -199,10 +195,7 @@ final class ExportCodegenTest extends AbstractTestCase
|
||||
|
||||
public function testHandleNHibernateCSBody(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportCodegen = $this->getExportCodegen($dbi);
|
||||
$exportCodegen = $this->getExportCodegen();
|
||||
|
||||
$method = new ReflectionMethod(ExportCodegen::class, 'handleNHibernateCSBody');
|
||||
$result = $method->invoke($exportCodegen, 'test_db', 'test_table');
|
||||
@ -256,10 +249,7 @@ final class ExportCodegenTest extends AbstractTestCase
|
||||
|
||||
public function testHandleNHibernateXMLBody(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportCodegen = $this->getExportCodegen($dbi);
|
||||
$exportCodegen = $this->getExportCodegen();
|
||||
|
||||
$method = new ReflectionMethod(ExportCodegen::class, 'handleNHibernateXMLBody');
|
||||
$result = $method->invoke($exportCodegen, 'test_db', 'test_table');
|
||||
@ -284,11 +274,11 @@ final class ExportCodegenTest extends AbstractTestCase
|
||||
);
|
||||
}
|
||||
|
||||
private function getExportCodegen(DatabaseInterface|null $dbi = null): ExportCodegen
|
||||
private function getExportCodegen(): ExportCodegen
|
||||
{
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportCodegen($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportCodegen($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\Settings\Export;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportCsv;
|
||||
@ -247,16 +246,13 @@ final class ExportCsvTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
// case 1
|
||||
OutputHandler::$asFile = true;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['csv_terminated' => ';', 'csv_columns' => 'On']);
|
||||
|
||||
$exportCsv = $this->getExportCsv($dbi);
|
||||
$exportCsv = $this->getExportCsv();
|
||||
$exportCsv->setExportOptions($request, new Export());
|
||||
$exportCsv->exportHeader();
|
||||
|
||||
@ -312,11 +308,11 @@ final class ExportCsvTest extends AbstractTestCase
|
||||
);
|
||||
}
|
||||
|
||||
private function getExportCsv(DatabaseInterface|null $dbi = null): ExportCsv
|
||||
private function getExportCsv(): ExportCsv
|
||||
{
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportCsv($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportCsv($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\Settings\Export;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Plugins\Export\ExportExcel;
|
||||
@ -191,10 +190,7 @@ final class ExportExcelTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportExcel = $this->getExportExcel($dbi);
|
||||
$exportExcel = $this->getExportExcel();
|
||||
|
||||
// case 1
|
||||
OutputHandler::$asFile = true;
|
||||
@ -217,11 +213,11 @@ final class ExportExcelTest extends AbstractTestCase
|
||||
);
|
||||
}
|
||||
|
||||
private function getExportExcel(DatabaseInterface|null $dbi = null): ExportExcel
|
||||
private function getExportExcel(): ExportExcel
|
||||
{
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportExcel($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportExcel($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,10 +265,7 @@ final class ExportHtmlwordTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportHtmlword = $this->getExportHtmlword($dbi);
|
||||
$exportHtmlword = $this->getExportHtmlword();
|
||||
|
||||
// case 1
|
||||
OutputHandler::$asFile = true;
|
||||
@ -319,8 +316,6 @@ final class ExportHtmlwordTest extends AbstractTestCase
|
||||
->with('database', 'view')
|
||||
->willReturn([$column]);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportHtmlword = $this->getExportHtmlword($dbi);
|
||||
|
||||
self::assertSame(
|
||||
@ -378,8 +373,6 @@ final class ExportHtmlwordTest extends AbstractTestCase
|
||||
->method('fetchAssoc')
|
||||
->willReturn(['comment' => 'testComment']);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportHtmlword = $this->getExportHtmlword($dbi);
|
||||
|
||||
$relationParameters = RelationParameters::fromArray([
|
||||
@ -452,8 +445,6 @@ final class ExportHtmlwordTest extends AbstractTestCase
|
||||
->method('fetchAssoc')
|
||||
->willReturn(['comment' => 'testComment']);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportHtmlword = $this->getExportHtmlword($dbi);
|
||||
$exportHtmlword->setExportOptions($request, new SettingsExport());
|
||||
|
||||
@ -494,8 +485,6 @@ final class ExportHtmlwordTest extends AbstractTestCase
|
||||
$dbi->expects(self::never())
|
||||
->method('tryQuery');
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$relationParameters = RelationParameters::fromArray([
|
||||
RelationParameters::DATABASE => 'database',
|
||||
RelationParameters::RELATION => 'rel',
|
||||
@ -506,6 +495,7 @@ final class ExportHtmlwordTest extends AbstractTestCase
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['htmlword_relation' => 'On', 'htmlword_mime' => 'On']);
|
||||
|
||||
$exportHtmlword = $this->getExportHtmlword($dbi);
|
||||
$exportHtmlword->setExportOptions($request, new SettingsExport());
|
||||
|
||||
$result = $exportHtmlword->getTableDef('database', '');
|
||||
@ -553,10 +543,7 @@ final class ExportHtmlwordTest extends AbstractTestCase
|
||||
public function testExportStructure(): void
|
||||
{
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportHtmlword = $this->getExportHtmlword($dbi);
|
||||
$exportHtmlword = $this->getExportHtmlword($this->createDatabaseInterface($dbiDummy));
|
||||
|
||||
ob_start();
|
||||
$dbiDummy->addSelectDb('test_db');
|
||||
@ -666,9 +653,8 @@ final class ExportHtmlwordTest extends AbstractTestCase
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportHtmlword = $this->getExportHtmlword();
|
||||
$exportHtmlword = $this->getExportHtmlword($dbi);
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['htmlword_structure_or_data' => 'structure']);
|
||||
@ -694,6 +680,6 @@ final class ExportHtmlwordTest extends AbstractTestCase
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportHtmlword($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportHtmlword($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Plugins\Export\ExportJson;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
@ -137,10 +136,7 @@ final class ExportJsonTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportJson = $this->getExportJson($dbi);
|
||||
$exportJson = $this->getExportJson();
|
||||
$this->expectOutputString(
|
||||
'{"type":"table","name":"test_table","database":"test_db","data":' . "\n"
|
||||
. '[' . "\n"
|
||||
@ -156,10 +152,7 @@ final class ExportJsonTest extends AbstractTestCase
|
||||
|
||||
public function testExportComplexData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportJson = $this->getExportJson($dbi);
|
||||
$exportJson = $this->getExportJson();
|
||||
// normalString binaryField textField blobField
|
||||
$this->expectOutputString(
|
||||
'{"type":"table","name":"test_table_complex","database":"test_db","data":'
|
||||
@ -177,10 +170,7 @@ final class ExportJsonTest extends AbstractTestCase
|
||||
|
||||
public function testExportRawComplexData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportJson = $this->getExportJson($dbi);
|
||||
$exportJson = $this->getExportJson();
|
||||
$this->expectOutputString(
|
||||
'{"type":"raw","data":'
|
||||
. "\n[\n"
|
||||
@ -195,11 +185,11 @@ final class ExportJsonTest extends AbstractTestCase
|
||||
$exportJson->exportRawQuery('', 'SELECT * FROM `test_db`.`test_table_complex`;');
|
||||
}
|
||||
|
||||
private function getExportJson(DatabaseInterface|null $dbi = null): ExportJson
|
||||
private function getExportJson(): ExportJson
|
||||
{
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportJson($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportJson($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,10 +470,7 @@ final class ExportLatexTest extends AbstractTestCase
|
||||
'latex_null' => 'null',
|
||||
]);
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportLatex = $this->getExportLatex($dbi);
|
||||
$exportLatex = $this->getExportLatex();
|
||||
$exportLatex->setExportOptions($request, new SettingsExport());
|
||||
|
||||
ob_start();
|
||||
@ -576,8 +573,6 @@ final class ExportLatexTest extends AbstractTestCase
|
||||
->method('fetchAssoc')
|
||||
->willReturn(['comment' => 'testComment']);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportLatex = $this->getExportLatex($dbi);
|
||||
|
||||
$relationParameters = RelationParameters::fromArray([
|
||||
@ -660,8 +655,6 @@ final class ExportLatexTest extends AbstractTestCase
|
||||
->method('fetchAssoc')
|
||||
->willReturn(['comment' => 'testComment']);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportLatex = $this->getExportLatex($dbi);
|
||||
$exportLatex->setExportOptions($request, new SettingsExport());
|
||||
|
||||
@ -706,8 +699,6 @@ final class ExportLatexTest extends AbstractTestCase
|
||||
$dbi->expects(self::never())
|
||||
->method('tryQuery');
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$config = Config::getInstance();
|
||||
$config->selectedServer['host'] = 'localhost';
|
||||
$config->selectedServer['verbose'] = 'verb';
|
||||
@ -779,11 +770,11 @@ final class ExportLatexTest extends AbstractTestCase
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['latex_structure_or_data' => 'structure']);
|
||||
|
||||
$exportLatex = $this->getExportLatex();
|
||||
$exportLatex = $this->getExportLatex($dbi);
|
||||
$exportLatex->setExportOptions($request, new SettingsExport());
|
||||
ob_start();
|
||||
$export = new Export($dbi, new OutputHandler());
|
||||
@ -808,6 +799,6 @@ final class ExportLatexTest extends AbstractTestCase
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportLatex($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportLatex($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,12 +216,10 @@ final class ExportMediawikiTest extends AbstractTestCase
|
||||
->with('db', 'table')
|
||||
->willReturn($columns);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['mediawiki_headers' => 'On', 'mediawiki_caption' => 'On']);
|
||||
|
||||
$exportMediawiki = $this->getExportMediawiki();
|
||||
$exportMediawiki = $this->getExportMediawiki($dbi);
|
||||
$exportMediawiki->setExportOptions($request, new SettingsExport());
|
||||
|
||||
ob_start();
|
||||
@ -262,13 +260,10 @@ final class ExportMediawikiTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['mediawiki_headers' => 'On', 'mediawiki_caption' => 'On']);
|
||||
|
||||
$exportMediawiki = $this->getExportMediawiki($dbi);
|
||||
$exportMediawiki = $this->getExportMediawiki();
|
||||
$exportMediawiki->setExportOptions($request, new SettingsExport());
|
||||
|
||||
ob_start();
|
||||
@ -309,11 +304,11 @@ final class ExportMediawikiTest extends AbstractTestCase
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['mediawiki_structure_or_data' => 'structure']);
|
||||
|
||||
$exportMediawiki = $this->getExportMediawiki();
|
||||
$exportMediawiki = $this->getExportMediawiki($dbi);
|
||||
$exportMediawiki->setExportOptions($request, new SettingsExport());
|
||||
ob_start();
|
||||
$export = new Export($dbi, new OutputHandler());
|
||||
@ -338,6 +333,6 @@ final class ExportMediawikiTest extends AbstractTestCase
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportMediawiki($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportMediawiki($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,8 +235,6 @@ final class ExportOdsTest extends AbstractTestCase
|
||||
[],
|
||||
);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['ods_null' => '&']);
|
||||
|
||||
@ -305,8 +303,6 @@ final class ExportOdsTest extends AbstractTestCase
|
||||
->method('fetchRow')
|
||||
->willReturn([]);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['ods_columns' => 'On']);
|
||||
|
||||
@ -351,8 +347,6 @@ final class ExportOdsTest extends AbstractTestCase
|
||||
->method('fetchRow')
|
||||
->willReturn([]);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportOds = $this->getExportOds($dbi);
|
||||
$exportOds->setExportOptions($request, new Export());
|
||||
$exportOds->buffer = '';
|
||||
@ -370,6 +364,6 @@ final class ExportOdsTest extends AbstractTestCase
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportOds($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportOds($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,8 +359,6 @@ final class ExportOdtTest extends AbstractTestCase
|
||||
->method('fetchRow')
|
||||
->willReturn([null, 'a<b', 'a>b', 'a&b'], []);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['odt_null' => '&']);
|
||||
|
||||
@ -424,12 +422,10 @@ final class ExportOdtTest extends AbstractTestCase
|
||||
->method('fetchRow')
|
||||
->willReturn([]);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['odt_columns' => 'On']);
|
||||
|
||||
$exportOdt = $this->getExportOdt();
|
||||
$exportOdt = $this->getExportOdt($dbi);
|
||||
$exportOdt->setExportOptions($request, new SettingsExport());
|
||||
|
||||
$exportOdt->exportData('db', 'table', 'SELECT');
|
||||
@ -472,8 +468,6 @@ final class ExportOdtTest extends AbstractTestCase
|
||||
->method('fetchRow')
|
||||
->willReturn([]);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportOdt = $this->getExportOdt($dbi);
|
||||
$exportOdt->setExportOptions($request, new SettingsExport());
|
||||
$exportOdt->buffer = '';
|
||||
@ -493,10 +487,7 @@ final class ExportOdtTest extends AbstractTestCase
|
||||
public function testGetTableDefStandIn(): void
|
||||
{
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportOdt = $this->getExportOdt($dbi);
|
||||
$exportOdt = $this->getExportOdt($this->createDatabaseInterface($dbiDummy));
|
||||
|
||||
$dbiDummy->addSelectDb('test_db');
|
||||
self::assertSame(
|
||||
@ -565,8 +556,6 @@ final class ExportOdtTest extends AbstractTestCase
|
||||
->method('fetchAssoc')
|
||||
->willReturn(['comment' => 'testComment']);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportOdt = $this->getExportOdt($dbi);
|
||||
|
||||
$relationParameters = RelationParameters::fromArray([
|
||||
@ -639,8 +628,6 @@ final class ExportOdtTest extends AbstractTestCase
|
||||
->method('fetchAssoc')
|
||||
->willReturn(['comment' => 'testComment']);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportOdt = $this->getExportOdt($dbi);
|
||||
$exportOdt->setExportOptions($request, new SettingsExport());
|
||||
|
||||
@ -714,10 +701,7 @@ final class ExportOdtTest extends AbstractTestCase
|
||||
public function testExportStructure(): void
|
||||
{
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportOdt = $this->getExportOdt($dbi);
|
||||
$exportOdt = $this->getExportOdt($this->createDatabaseInterface($dbiDummy));
|
||||
|
||||
// case 1
|
||||
$dbiDummy->addSelectDb('test_db');
|
||||
@ -879,11 +863,11 @@ final class ExportOdtTest extends AbstractTestCase
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['odt_structure_or_data' => 'structure']);
|
||||
|
||||
$exportOdt = $this->getExportOdt();
|
||||
$exportOdt = $this->getExportOdt($dbi);
|
||||
$exportOdt->setExportOptions($request, new SettingsExport());
|
||||
$export = new Export($dbi, new OutputHandler());
|
||||
$export->exportTable(
|
||||
@ -904,6 +888,6 @@ final class ExportOdtTest extends AbstractTestCase
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportOdt($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportOdt($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,6 +209,6 @@ final class ExportPdfTest extends AbstractTestCase
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportPdf($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportPdf($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Plugins\Export\ExportPhparray;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
@ -145,10 +144,7 @@ final class ExportPhparrayTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportPhparray = $this->getExportPhparray($dbi);
|
||||
$exportPhparray = $this->getExportPhparray();
|
||||
|
||||
ob_start();
|
||||
$exportPhparray->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
|
||||
@ -181,11 +177,11 @@ final class ExportPhparrayTest extends AbstractTestCase
|
||||
);
|
||||
}
|
||||
|
||||
private function getExportPhparray(DatabaseInterface|null $dbi = null): ExportPhparray
|
||||
private function getExportPhparray(): ExportPhparray
|
||||
{
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportPhparray($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportPhparray($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
->method('getCompatibilities')
|
||||
->willReturn(['v1', 'v2']);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
ExportPlugin::$exportType = ExportType::Server;
|
||||
ExportPlugin::$singleTable = false;
|
||||
|
||||
@ -277,16 +276,13 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
public function testExportRoutines(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody([
|
||||
'sql_drop_table' => 'On',
|
||||
'sql_procedure_function' => 'On',
|
||||
]);
|
||||
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
$this->expectOutputString(
|
||||
@ -382,12 +378,10 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
->method('query')
|
||||
->with('SET time_zone = "GMT"');
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['sql_use_transaction' => 'On', 'sql_disable_fk' => 'On', 'sql_utc_time' => 'On']);
|
||||
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
$this->expectOutputString('SET FOREIGN_KEY_CHECKS=1;' . "\n" . 'COMMIT;' . "\n");
|
||||
@ -421,8 +415,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
->method('query')
|
||||
->with('SET time_zone = "+00:00"');
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody([
|
||||
'sql_include_comments' => 'On',
|
||||
@ -432,7 +424,7 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
'sql_utc_time' => 'On',
|
||||
]);
|
||||
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
ob_start();
|
||||
@ -469,8 +461,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
->with('db')
|
||||
->willReturn('utf8_general_ci');
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody([
|
||||
'sql_structure_or_data' => 'structure_and_data',
|
||||
@ -478,7 +468,7 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
'sql_drop_database' => 'On',
|
||||
]);
|
||||
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
ob_start();
|
||||
@ -508,8 +498,8 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
->with('db')
|
||||
->willReturn('testcollation');
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
$exportSql->useSqlBackquotes(false);
|
||||
|
||||
ob_start();
|
||||
@ -580,12 +570,10 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
$dbi->expects(self::any())->method('quoteString')
|
||||
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['sql_procedure_function' => 'On']);
|
||||
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
ob_start();
|
||||
@ -608,12 +596,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql->sqlConstraints = 'SqlConstraints';
|
||||
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
ob_start();
|
||||
$exportSql->exportDBFooter('db');
|
||||
$result = ob_get_clean();
|
||||
@ -632,12 +614,10 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
->with('db', 'view')
|
||||
->willReturn([new Column('cname', 'int', null, false, '', null, '', '', '')]);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['sql_drop_table' => 'On', 'sql_if_not_exists' => 'On']);
|
||||
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
$result = $exportSql->getTableDefStandIn('db', 'view');
|
||||
@ -675,12 +655,10 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
),
|
||||
]);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['sql_compatibility' => 'MSSQL', 'sql_if_not_exists' => 'On']);
|
||||
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
$method = new ReflectionMethod(ExportSql::class, 'getTableDefForView');
|
||||
@ -716,11 +694,11 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
'cmt',
|
||||
),
|
||||
]);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['sql_if_not_exists' => 'On']);
|
||||
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
$result = $method->invoke($exportSql, 'db', 'view');
|
||||
@ -780,7 +758,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
['Table', 'Create Table'],
|
||||
);
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface($dbiDummy);
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
@ -793,6 +770,7 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
'sql_drop_table' => 'On',
|
||||
]);
|
||||
|
||||
$exportSql = $this->getExportSql($this->createDatabaseInterface($dbiDummy));
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
$result = $exportSql->getTableDef('db', 'table', true, false);
|
||||
@ -814,9 +792,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
public function testGetTableDefWithError(): void
|
||||
{
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql->sqlConstraints = null;
|
||||
|
||||
ExportSql::$noConstraintsComments = false;
|
||||
|
||||
$isViewQuery = 'SELECT 1 FROM information_schema.VIEWS WHERE TABLE_SCHEMA = \'db\' AND TABLE_NAME = \'table\'';
|
||||
@ -829,12 +804,14 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
$dbiDummy->addResult('SHOW CREATE TABLE `db`.`table`', []);
|
||||
$dbiDummy->addErrorCode('error occurred');
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface($dbiDummy);
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['sql_include_comments' => 'On', 'sql_drop_table' => 'On']);
|
||||
|
||||
$exportSql = $this->getExportSql($this->createDatabaseInterface($dbiDummy));
|
||||
$exportSql->sqlConstraints = null;
|
||||
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
$this->expectException(ExportException::class);
|
||||
@ -869,8 +846,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
['foo' => ['foreign_table' => 'ftable', 'foreign_field' => 'ffield']],
|
||||
);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->useSqlBackquotes(false);
|
||||
|
||||
@ -899,9 +874,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
public function testExportStructure(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody([
|
||||
'sql_backquotes' => 'true',
|
||||
@ -912,7 +884,7 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
'sql_create_trigger' => 'On',
|
||||
]);
|
||||
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
// case 1
|
||||
@ -1055,7 +1027,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
->method('getTable')
|
||||
->willReturn($tableObj);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
@ -1068,7 +1039,7 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
'sql_hex_for_binary' => 'On',
|
||||
]);
|
||||
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
ob_start();
|
||||
@ -1154,7 +1125,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
->method('getTable')
|
||||
->willReturn($tableObj);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
@ -1165,7 +1135,7 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
'sql_ignore' => 'On',
|
||||
]);
|
||||
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
ob_start();
|
||||
@ -1201,13 +1171,12 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
->method('getTable')
|
||||
->willReturn($tableObj);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['sql_backquotes' => 'true', 'sql_include_comments' => 'On']);
|
||||
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
ob_start();
|
||||
@ -1245,13 +1214,12 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
->method('getTable')
|
||||
->willReturn($tableObj);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['sql_include_comments' => 'On']);
|
||||
|
||||
$exportSql = $this->getExportSql();
|
||||
$exportSql = $this->getExportSql($dbi);
|
||||
$exportSql->setExportOptions($request, new Export());
|
||||
|
||||
$this->expectException(ExportException::class);
|
||||
@ -1503,6 +1471,6 @@ final class ExportSqlTest extends AbstractTestCase
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportSql($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportSql($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,10 +182,7 @@ final class ExportTexytextTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportTexytext = $this->getExportTexytext($dbi);
|
||||
$exportTexytext = $this->getExportTexytext();
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['texytext_columns' => 'On']);
|
||||
@ -212,10 +209,7 @@ final class ExportTexytextTest extends AbstractTestCase
|
||||
public function testGetTableDefStandIn(): void
|
||||
{
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportTexytext = $this->getExportTexytext($dbi);
|
||||
$exportTexytext = $this->getExportTexytext($this->createDatabaseInterface($dbiDummy));
|
||||
|
||||
$dbiDummy->addSelectDb('test_db');
|
||||
$result = $exportTexytext->getTableDefStandIn('test_db', 'test_table');
|
||||
@ -265,8 +259,6 @@ final class ExportTexytextTest extends AbstractTestCase
|
||||
['db', 'table', ConnectionType::User, [$columnFull]],
|
||||
]);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportTexytext = $this->getExportTexytext($dbi);
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
@ -320,10 +312,7 @@ final class ExportTexytextTest extends AbstractTestCase
|
||||
public function testExportStructure(): void
|
||||
{
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportTexytext = $this->getExportTexytext($dbi);
|
||||
$exportTexytext = $this->getExportTexytext($this->createDatabaseInterface($dbiDummy));
|
||||
|
||||
// case 1
|
||||
ob_start();
|
||||
@ -423,6 +412,6 @@ final class ExportTexytextTest extends AbstractTestCase
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportTexytext($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportTexytext($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,8 +215,6 @@ final class ExportXmlTest extends AbstractTestCase
|
||||
$dbiDummy->addResult('SHOW CREATE FUNCTION `d<"b`.`fn`', [['fn', 'fndef']], ['name', 'Create Function']);
|
||||
$dbiDummy->addResult('SHOW CREATE PROCEDURE `d<"b`.`pr`', [['pr', 'prdef']], ['name', 'Create Procedure']);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody([
|
||||
'xml_export_contents' => 'On',
|
||||
@ -226,7 +224,7 @@ final class ExportXmlTest extends AbstractTestCase
|
||||
'xml_export_triggers' => 'On',
|
||||
]);
|
||||
|
||||
$exportXml = $this->getExportXml();
|
||||
$exportXml = $this->getExportXml($dbi);
|
||||
$exportXml->setExportOptions($request, new Export());
|
||||
|
||||
$exportXml->setTables([]);
|
||||
@ -285,11 +283,10 @@ final class ExportXmlTest extends AbstractTestCase
|
||||
[],
|
||||
);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['xml_export_triggers' => 'On']);
|
||||
|
||||
$exportXml = $this->getExportXml($dbi);
|
||||
$exportXml->setExportOptions($request, new Export());
|
||||
|
||||
$exportXml->setTables(['t1', 't2']);
|
||||
@ -375,15 +372,12 @@ final class ExportXmlTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
OutputHandler::$asFile = true;
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['xml_export_contents' => 'On']);
|
||||
|
||||
$exportXml = $this->getExportXml($dbi);
|
||||
$exportXml = $this->getExportXml();
|
||||
$exportXml->setExportOptions($request, new Export());
|
||||
|
||||
ob_start();
|
||||
@ -417,6 +411,6 @@ final class ExportXmlTest extends AbstractTestCase
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportXml($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportXml($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ namespace PhpMyAdmin\Tests\Plugins\Export;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Plugins\Export\ExportYaml;
|
||||
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
|
||||
@ -135,10 +134,7 @@ final class ExportYamlTest extends AbstractTestCase
|
||||
|
||||
public function testExportData(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$exportYaml = $this->getExportYaml($dbi);
|
||||
$exportYaml = $this->getExportYaml();
|
||||
|
||||
ob_start();
|
||||
$exportYaml->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table_yaml`;');
|
||||
@ -175,11 +171,11 @@ final class ExportYamlTest extends AbstractTestCase
|
||||
);
|
||||
}
|
||||
|
||||
private function getExportYaml(DatabaseInterface|null $dbi = null): ExportYaml
|
||||
private function getExportYaml(): ExportYaml
|
||||
{
|
||||
$dbi ??= $this->createDatabaseInterface();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$relation = new Relation($dbi, new Config());
|
||||
|
||||
return new ExportYaml($relation, new OutputHandler(), new Transformations($dbi, $relation));
|
||||
return new ExportYaml($relation, new OutputHandler(), new Transformations($dbi, $relation), $dbi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,10 +107,10 @@ class PluginsTest extends AbstractTestCase
|
||||
$transformations = new Transformations($dbi, $relation);
|
||||
$outputHandler = new OutputHandler();
|
||||
$exportList = [
|
||||
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),
|
||||
new Plugins\Export\ExportJson($relation, $outputHandler, $transformations, $dbi),
|
||||
new Plugins\Export\ExportOds($relation, $outputHandler, $transformations, $dbi),
|
||||
new Plugins\Export\ExportSql($relation, $outputHandler, $transformations, $dbi),
|
||||
new Plugins\Export\ExportXml($relation, $outputHandler, $transformations, $dbi),
|
||||
];
|
||||
$actual = Plugins::getChoice($exportList, 'xml');
|
||||
$expected = [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user