Create ExportType enum

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2024-12-14 00:34:12 +00:00
parent bcaccee218
commit 24fba67ccd
47 changed files with 380 additions and 337 deletions

View File

@ -8407,13 +8407,13 @@ parameters:
path: src/Export/Template.php
-
message: '#^Parameter \#2 \$username of class PhpMyAdmin\\Export\\Template constructor expects string, mixed given\.$#'
message: '#^Parameter \#1 \$value of static method PhpMyAdmin\\Plugins\\ExportType\:\:from\(\) expects int\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Export/Template.php
-
message: '#^Parameter \#3 \$exportType of class PhpMyAdmin\\Export\\Template constructor expects string, mixed given\.$#'
message: '#^Parameter \#2 \$username of class PhpMyAdmin\\Export\\Template constructor expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Export/Template.php

View File

@ -15,6 +15,7 @@ use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Url;
use PhpMyAdmin\UrlParams;
@ -123,9 +124,9 @@ final class ExportController implements InvocableController
$isReturnBackFromRawExport = $request->getParsedBodyParam('export_type') === 'raw';
if ($request->hasBodyParam('raw_query') || $isReturnBackFromRawExport) {
$exportType = 'raw';
$exportType = ExportType::Raw;
} else {
$exportType = 'database';
$exportType = ExportType::Database;
}
$GLOBALS['single_table'] = $request->getParam('single_table') ?? $GLOBALS['single_table'] ?? null;

View File

@ -22,6 +22,7 @@ use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\Export\ExportSql;
use PhpMyAdmin\Plugins\Export\ExportXml;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Sanitize;
use PhpMyAdmin\SqlParser\Parser;
@ -94,10 +95,7 @@ final class ExportController implements InvocableController
return $this->response->missingParameterError('what');
}
$exportType = $request->getParsedBodyParamAsString('export_type');
if ($exportType === '') {
return $this->response->missingParameterError('export_type');
}
$exportType = ExportType::from($request->getParsedBodyParamAsString('export_type'));
// export class instance, not array of properties, as before
$exportPlugin = Plugins::getPlugin('export', $GLOBALS['what'], $exportType, isset($GLOBALS['single_table']));
@ -162,7 +160,7 @@ final class ExportController implements InvocableController
$tableNames = [];
// Generate error url and check for needed variables
if ($exportType === 'database') {
if ($exportType === ExportType::Database) {
if (Current::$database === '') {
return $this->response->missingParameterError('db');
}
@ -171,7 +169,7 @@ final class ExportController implements InvocableController
$tableNames = $GLOBALS['table_select'] ?? [];
Assert::isArray($tableNames);
Assert::allString($tableNames);
} elseif ($exportType === 'table') {
} elseif ($exportType === ExportType::Table) {
if (Current::$database === '') {
return $this->response->missingParameterError('db');
}
@ -179,11 +177,6 @@ final class ExportController implements InvocableController
if (Current::$table === '') {
return $this->response->missingParameterError('table');
}
} elseif ($exportType !== 'raw' && $exportType !== 'server') {
$this->response->setRequestStatus(false);
$this->response->addHTML(Message::error(__('Bad parameters!'))->getDisplay());
return $this->response->response();
}
// Merge SQL Query aliases with Export aliases from
@ -252,7 +245,7 @@ final class ExportController implements InvocableController
}
// For raw query export, filename will be export.extension
if ($exportType === 'raw') {
if ($exportType === ExportType::Raw) {
$filename = $this->export->getFinalFilename($exportPlugin, $GLOBALS['compression'], 'export');
}
@ -283,7 +276,7 @@ final class ExportController implements InvocableController
Core::downloadHeader($filename, $mimeType);
} else {
// HTML
if ($exportType === 'database') {
if ($exportType === ExportType::Database) {
$GLOBALS['num_tables'] = count($tableNames);
if ($GLOBALS['num_tables'] === 0) {
$GLOBALS['message'] = Message::error(
@ -337,14 +330,14 @@ final class ExportController implements InvocableController
$GLOBALS[$GLOBALS['what'] . '_structure_or_data'] = $whatStrucOrData;
}
if ($exportType === 'raw') {
if ($exportType === ExportType::Raw) {
$whatStrucOrData = 'raw';
}
/**
* Builds the dump
*/
if ($exportType === 'server') {
if ($exportType === ExportType::Server) {
if ($dbSelect === null) {
$dbSelect = '';
}
@ -361,7 +354,7 @@ final class ExportController implements InvocableController
$aliases,
$separateFiles,
);
} elseif ($exportType === 'database') {
} elseif ($exportType === ExportType::Database) {
if (! is_array($tableStructure)) {
$tableStructure = [];
}
@ -413,7 +406,7 @@ final class ExportController implements InvocableController
$separateFiles,
);
}
} elseif ($exportType === 'raw') {
} elseif ($exportType === ExportType::Raw) {
Export::exportRaw($whatStrucOrData, $exportPlugin, Current::$database, Current::$sqlQuery);
} else {
// We export just one table

View File

@ -21,6 +21,7 @@ use PhpMyAdmin\Message;
use PhpMyAdmin\MessageType;
use PhpMyAdmin\Operations;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Query\Utilities;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Url;
@ -100,7 +101,7 @@ final class DatabaseController implements InvocableController
$tableNames = $this->dbi->getTables(Current::$database);
// remove all foreign key constraints, otherwise we can get errors
$exportSqlPlugin = Plugins::getPlugin('export', 'sql', 'database', isset($GLOBALS['single_table']));
$exportSqlPlugin = Plugins::getPlugin('export', 'sql', ExportType::Database, isset($GLOBALS['single_table']));
// create stand-in tables for views
$views = $this->operations->getViewsAndCreateSqlViewStandIn(

View File

@ -13,6 +13,7 @@ use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\ResponseRenderer;
use function __;
@ -57,7 +58,7 @@ final class ExportController implements InvocableController
$GLOBALS['single_table'] = $request->getParam('single_table') ?? $GLOBALS['single_table'] ?? null;
$exportList = Plugins::getExport('server', isset($GLOBALS['single_table']));
$exportList = Plugins::getExport(ExportType::Server, isset($GLOBALS['single_table']));
if ($exportList === []) {
$this->response->addHTML(Message::error(
@ -68,7 +69,7 @@ final class ExportController implements InvocableController
}
$options = $this->export->getOptions(
'server',
ExportType::Server,
Current::$database,
Current::$table,
Current::$sqlQuery,

View File

@ -12,6 +12,7 @@ use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Statements\SelectStatement;
@ -88,7 +89,7 @@ class ExportController implements InvocableController
$GLOBALS['single_table'] = $request->getParam('single_table') ?? $GLOBALS['single_table'] ?? null;
$exportList = Plugins::getExport('table', isset($GLOBALS['single_table']));
$exportList = Plugins::getExport(ExportType::Table, isset($GLOBALS['single_table']));
if ($exportList === []) {
$this->response->addHTML(Message::error(
@ -98,10 +99,10 @@ class ExportController implements InvocableController
return $this->response->response();
}
$exportType = 'table';
$exportType = ExportType::Table;
$isReturnBackFromRawExport = $request->getParsedBodyParam('export_type') === 'raw';
if ($request->hasBodyParam('raw_query') || $isReturnBackFromRawExport) {
$exportType = 'raw';
$exportType = ExportType::Raw;
}
$options = $this->export->getOptions(
@ -115,7 +116,7 @@ class ExportController implements InvocableController
);
$this->response->render('table/export/index', array_merge($options, [
'export_type' => $exportType,
'export_type' => $exportType->value,
'page_settings_error_html' => $pageSettingsErrorHtml,
'page_settings_html' => $pageSettingsHtml,
]));

View File

@ -18,6 +18,7 @@ use PhpMyAdmin\Message;
use PhpMyAdmin\MessageType;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Plugins\SchemaPlugin;
use PhpMyAdmin\Table\Table;
use PhpMyAdmin\Url;
@ -223,14 +224,14 @@ class Export
/**
* Returns HTML containing the footer for a displayed export
*
* @param string $exportType the export type
* @param string $db the database name
* @param string $table the table name
* @param ExportType $exportType the export type
* @param string $db the database name
* @param string $table the table name
*
* @return string the HTML output
*/
public function getHtmlForDisplayedExportFooter(
string $exportType,
ExportType $exportType,
string $db,
string $table,
): string {
@ -314,14 +315,14 @@ class Export
public function rememberFilename(
Config $config,
string $exportType,
ExportType $exportType,
string $filenameTemplate,
): void {
if ($exportType === 'server') {
if ($exportType === ExportType::Server) {
$config->setUserValue('pma_server_filename_template', 'Export/file_template_server', $filenameTemplate);
} elseif ($exportType === 'database') {
} elseif ($exportType === ExportType::Database) {
$config->setUserValue('pma_db_filename_template', 'Export/file_template_database', $filenameTemplate);
} elseif ($exportType === 'raw') {
} elseif ($exportType === ExportType::Raw) {
$config->setUserValue('pma_raw_filename_template', 'Export/file_template_raw', $filenameTemplate);
} else {
$config->setUserValue('pma_table_filename_template', 'Export/file_template_table', $filenameTemplate);
@ -463,14 +464,14 @@ class Export
/**
* Returns HTML containing the header for a displayed export
*
* @param string $exportType the export type
* @param string $db the database name
* @param string $table the table name
* @param ExportType $exportType the export type
* @param string $db the database name
* @param string $table the table name
*
* @return string the generated HTML and back button
*/
public function getHtmlForDisplayedExportHeader(
string $exportType,
ExportType $exportType,
string $db,
string $table,
): string {
@ -495,7 +496,7 @@ class Export
* @param string|mixed[] $dbSelect the selected databases to export
* @param string $whatStrucOrData structure or data or both
* @param ExportPlugin $exportPlugin the selected export plugin
* @param string $exportType the export type
* @param ExportType $exportType the export type
* @param bool $doRelation whether to export relation info
* @param bool $doComments whether to add comments
* @param bool $doMime whether to add MIME info
@ -507,7 +508,7 @@ class Export
string|array $dbSelect,
string $whatStrucOrData,
ExportPlugin $exportPlugin,
string $exportType,
ExportType $exportType,
bool $doRelation,
bool $doComments,
bool $doMime,
@ -559,7 +560,7 @@ class Export
* @param string[] $tableStructure whether to export structure for each table
* @param string[] $tableData whether to export data for each table
* @param ExportPlugin $exportPlugin the selected export plugin
* @param string $exportType the export type
* @param ExportType $exportType the export type
* @param bool $doRelation whether to export relation info
* @param bool $doComments whether to add comments
* @param bool $doMime whether to add MIME info
@ -574,7 +575,7 @@ class Export
array $tableStructure,
array $tableData,
ExportPlugin $exportPlugin,
string $exportType,
ExportType $exportType,
bool $doRelation,
bool $doComments,
bool $doMime,
@ -850,7 +851,7 @@ class Export
* @param string $table the table to export
* @param string $whatStrucOrData structure or data or both
* @param ExportPlugin $exportPlugin the selected export plugin
* @param string $exportType the export type
* @param ExportType $exportType the export type
* @param bool $doRelation whether to export relation info
* @param bool $doComments whether to add comments
* @param bool $doMime whether to add MIME info
@ -866,7 +867,7 @@ class Export
string $table,
string $whatStrucOrData,
ExportPlugin $exportPlugin,
string $exportType,
ExportType $exportType,
bool $doRelation,
bool $doComments,
bool $doMime,
@ -1001,15 +1002,15 @@ class Export
*
* @psalm-return non-empty-string
*/
public function getPageLocationAndSaveMessage(string $exportType, Message $message): string
public function getPageLocationAndSaveMessage(ExportType $exportType, Message $message): string
{
(new FlashMessenger())->addMessage($message->isError() ? 'danger' : 'success', $message->getMessage());
if ($exportType === 'server') {
if ($exportType === ExportType::Server) {
return 'index.php?route=/server/export' . Url::getCommonRaw([], '&');
}
if ($exportType === 'database') {
if ($exportType === ExportType::Database) {
$params = ['db' => Current::$database];
return 'index.php?route=/database/export' . Url::getCommonRaw($params, '&');
@ -1148,24 +1149,22 @@ class Export
* get all the export options and verify
* call and include the appropriate Schema Class depending on $export_type
*
* @param non-empty-string $exportType
*
* @return array{fileName: non-empty-string, mediaType: non-empty-string, fileData: string}
*
* @throws ExportException
*/
public function getExportSchemaInfo(DatabaseName $db, string $exportType): array
public function getExportSchemaInfo(DatabaseName $db, string $format): array
{
/**
* default is PDF, otherwise validate it's only letters a-z
*/
if (preg_match('/^[a-zA-Z]+$/', $exportType) !== 1) {
$exportType = 'pdf';
if (preg_match('/^[a-zA-Z]+$/', $format) !== 1) {
$format = 'pdf';
}
// get the specific plugin
/** @var SchemaPlugin|null $exportPlugin */
$exportPlugin = Plugins::getPlugin('schema', $exportType);
$exportPlugin = Plugins::getPlugin('schema', $format);
// Check schema export type
if ($exportPlugin === null) {
@ -1183,7 +1182,7 @@ class Export
return $this->dbi->getTables($database);
}
private function getHTMLForRefreshButton(string $exportType): string
private function getHTMLForRefreshButton(ExportType $exportType): string
{
$postParams = $this->getPostParams($exportType);
@ -1211,12 +1210,12 @@ class Export
. __('Copy to clipboard') . '</a> ]</p>';
}
private function getHTMLForBackButton(string $exportType, string $db, string $table): string
private function getHTMLForBackButton(ExportType $exportType, string $db, string $table): string
{
$backButton = '<p>[ <a href="';
$backButton .= match ($exportType) {
'server' => Url::getFromRoute('/server/export') . '" data-post="' . Url::getCommon([], '', false),
'database' => Url::getFromRoute('/database/export') . '" data-post="' . Url::getCommon(
ExportType::Server => Url::getFromRoute('/server/export') . '" data-post="' . Url::getCommon([], '', false),
ExportType::Database => Url::getFromRoute('/database/export') . '" data-post="' . Url::getCommon(
['db' => $db],
'',
false,
@ -1237,12 +1236,12 @@ class Export
}
/** @return mixed[] */
private function getPostParams(string $exportType): array
private function getPostParams(ExportType $exportType): array
{
$postParams = $_POST;
// Convert the multiple select elements from an array to a string
if ($exportType === 'database') {
if ($exportType === ExportType::Database) {
$structOrDataForced = empty($postParams['structure_or_data_forced']);
if ($structOrDataForced && ! isset($postParams['table_structure'])) {
$postParams['table_structure'] = [];

View File

@ -11,6 +11,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Encoding;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Query\Utilities;
use PhpMyAdmin\Table\Table;
use PhpMyAdmin\Util;
@ -87,7 +88,7 @@ final class Options
}
/**
* @param string $exportType export type: server|database|table
* @param ExportType $exportType export type: server|database|table
* @param string $db selected DB
* @param string $table selected table
* @param string $sqlQuery SQL query
@ -98,7 +99,7 @@ final class Options
* @return array<string, mixed>
*/
public function getOptions(
string $exportType,
ExportType $exportType,
string $db,
string $table,
string $sqlQuery,
@ -127,7 +128,7 @@ final class Options
$tableObject = new Table($table, $db, DatabaseInterface::getInstance());
$rows = [];
if ($table !== '' && $numTables === 0 && ! $tableObject->isMerge() && $exportType !== 'raw') {
if ($table !== '' && $numTables === 0 && ! $tableObject->isMerge() && $exportType !== ExportType::Raw) {
$rows = [
'allrows' => $_POST['allrows'] ?? null,
'limit_to' => $_POST['limit_to'] ?? null,
@ -153,7 +154,7 @@ final class Options
$hiddenInputs = [
'db' => $db,
'table' => $table,
'export_type' => $exportType,
'export_type' => $exportType->value,
'export_method' => $_POST['export_method'] ?? $config->settings['Export']['method'] ?? 'quick',
'template_id' => $_POST['template_id'] ?? '',
];
@ -167,7 +168,7 @@ final class Options
}
return [
'export_type' => $exportType,
'export_type' => $exportType->value,
'db' => $db,
'table' => $table,
'templates' => [
@ -208,21 +209,21 @@ final class Options
];
}
private function getFileNameTemplate(string $exportType, string|null $filename = null): string
private function getFileNameTemplate(ExportType $exportType, string|null $filename = null): string
{
if ($filename !== null) {
return $filename;
}
$config = Config::getInstance();
if ($exportType === 'database') {
if ($exportType === ExportType::Database) {
return (string) $config->getUserValue(
'pma_db_filename_template',
$config->settings['Export']['file_template_database'],
);
}
if ($exportType === 'table') {
if ($exportType === ExportType::Table) {
return (string) $config->getUserValue(
'pma_table_filename_template',
$config->settings['Export']['file_template_table'],

View File

@ -4,13 +4,15 @@ declare(strict_types=1);
namespace PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportType;
/** @psalm-immutable */
final class Template
{
private function __construct(
private int $id,
private string $username,
private string $exportType,
private ExportType $exportType,
private string $name,
private string $data,
) {
@ -22,7 +24,7 @@ final class Template
return new self(
$state['id'] ?? 0,
$state['username'],
$state['exportType'] ?? '',
ExportType::from($state['exportType'] ?? ''),
$state['name'] ?? '',
$state['data'],
);
@ -38,7 +40,7 @@ final class Template
return $this->username;
}
public function getExportType(): string
public function getExportType(): ExportType
{
return $this->exportType;
}

View File

@ -8,6 +8,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Util;
use function sprintf;
@ -26,7 +27,7 @@ final class TemplateModel
Util::backquote($db),
Util::backquote($table),
$this->dbi->quoteString($template->getUsername(), ConnectionType::ControlUser),
$this->dbi->quoteString($template->getExportType(), ConnectionType::ControlUser),
$this->dbi->quoteString($template->getExportType()->value, ConnectionType::ControlUser),
$this->dbi->quoteString($template->getName(), ConnectionType::ControlUser),
$this->dbi->quoteString($template->getData(), ConnectionType::ControlUser),
);
@ -102,14 +103,14 @@ final class TemplateModel
}
/** @return Template[]|string */
public function getAll(DatabaseName $db, TableName $table, string $user, string $exportType): array|string
public function getAll(DatabaseName $db, TableName $table, string $user, ExportType $exportType): array|string
{
$query = sprintf(
'SELECT * FROM %s.%s WHERE `username` = %s AND `export_type` = %s ORDER BY `template_name`;',
Util::backquote($db),
Util::backquote($table),
$this->dbi->quoteString($user, ConnectionType::ControlUser),
$this->dbi->quoteString($exportType, ConnectionType::ControlUser),
$this->dbi->quoteString($exportType->value, ConnectionType::ControlUser),
);
$result = $this->dbi->tryQueryAsControlUser($query);
if ($result === false) {

View File

@ -9,6 +9,7 @@ use PhpMyAdmin\Container\ContainerBuilder;
use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Import\ImportSettings;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Plugins\ImportPlugin;
use PhpMyAdmin\Plugins\Plugin;
use PhpMyAdmin\Plugins\SchemaPlugin;
@ -57,7 +58,7 @@ class Plugins
public static function getPlugin(
string $type,
string $format,
string $exportType = '',
ExportType $exportType = ExportType::Raw,
bool $singleTable = false,
): object|null {
ExportPlugin::$exportType = $exportType;
@ -84,13 +85,10 @@ class Plugins
}
/**
* @param string $type server|database|table|raw
* @psalm-param 'server'|'database'|'table'|'raw' $type
*
* @return ExportPlugin[]
* @psalm-return list<ExportPlugin>
*/
public static function getExport(string $type, bool $singleTable): array
public static function getExport(ExportType $type, bool $singleTable): array
{
ExportPlugin::$exportType = $type;
ExportPlugin::$singleTable = $singleTable;

View File

@ -10,6 +10,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Plugins\Export\Helpers\TableProperty;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@ -116,11 +117,11 @@ class ExportCodegen extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}

View File

@ -10,6 +10,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -174,11 +175,11 @@ class ExportCsv extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}

View File

@ -11,6 +11,7 @@ use PhpMyAdmin\Column;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -152,11 +153,11 @@ class ExportHtmlword extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}
@ -479,26 +480,26 @@ class ExportHtmlword extends ExportPlugin
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because /export calls
* PMA_exportStructure() also for other
* export types which use this parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param ExportType $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because /export calls
* PMA_exportStructure() also for other
* export types which use this parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(
string $db,
string $table,
string $exportMode,
string $exportType,
ExportType $exportType,
bool $doRelation = false,
bool $doComments = false,
bool $doMime = false,

View File

@ -11,6 +11,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\FieldMetadata;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -156,11 +157,11 @@ class ExportJson extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}

View File

@ -12,6 +12,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -56,7 +57,7 @@ class ExportLatex extends ExportPlugin
protected function setProperties(): ExportPluginProperties
{
$hideStructure = false;
if (ExportPlugin::$exportType === 'table' && ! ExportPlugin::$singleTable) {
if (ExportPlugin::$exportType === ExportType::Table && ! ExportPlugin::$singleTable) {
$hideStructure = true;
}
@ -256,11 +257,11 @@ class ExportLatex extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}
@ -411,26 +412,26 @@ class ExportLatex extends ExportPlugin
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because /export calls
* exportStructure() also for other
* export types which use this parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param ExportType $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because /export calls
* exportStructure() also for other
* export types which use this parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(
string $db,
string $table,
string $exportMode,
string $exportType,
ExportType $exportType,
bool $doRelation = false,
bool $doComments = false,
bool $doMime = false,

View File

@ -10,6 +10,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertySubgroup;
@ -127,11 +128,11 @@ class ExportMediawiki extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}
@ -139,20 +140,20 @@ class ExportMediawiki extends ExportPlugin
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure; this is
* deprecated but the parameter is left here
* because /export calls exportStructure()
* also for other export types which use this
* parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param ExportType $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure; this is
* deprecated but the parameter is left here
* because /export calls exportStructure()
* also for other export types which use this
* parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
*
* @infection-ignore-all
*/
@ -160,7 +161,7 @@ class ExportMediawiki extends ExportPlugin
string $db,
string $table,
string $exportMode,
string $exportType,
ExportType $exportType,
bool $doRelation = false,
bool $doComments = false,
bool $doMime = false,

View File

@ -12,6 +12,7 @@ use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\FieldMetadata;
use PhpMyAdmin\OpenDocument;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -172,11 +173,11 @@ class ExportOds extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}

View File

@ -12,6 +12,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\OpenDocument;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -46,7 +47,7 @@ class ExportOdt extends ExportPlugin
protected function setProperties(): ExportPluginProperties
{
$hideStructure = false;
if (ExportPlugin::$exportType === 'table' && ! ExportPlugin::$singleTable) {
if (ExportPlugin::$exportType === ExportType::Table && ! ExportPlugin::$singleTable) {
$hideStructure = true;
}
@ -196,11 +197,11 @@ class ExportOdt extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}
@ -605,25 +606,25 @@ class ExportOdt extends ExportPlugin
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because /export calls
* PMA_exportStructure() also for other
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param ExportType $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because /export calls
* PMA_exportStructure() also for other
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(
string $db,
string $table,
string $exportMode,
string $exportType,
ExportType $exportType,
bool $doRelation = false,
bool $doComments = false,
bool $doMime = false,

View File

@ -7,6 +7,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Plugins\Export\Helpers\Pdf;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\RadioPropertyItem;
@ -144,11 +145,11 @@ class ExportPdf extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}
@ -208,26 +209,26 @@ class ExportPdf extends ExportPlugin
/**
* Outputs table structure
*
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because /export calls
* PMA_exportStructure() also for other
* export types which use this parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases aliases for db/table/columns
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param ExportType $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because /export calls
* PMA_exportStructure() also for other
* export types which use this parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases aliases for db/table/columns
*/
public function exportStructure(
string $db,
string $table,
string $exportMode,
string $exportType,
ExportType $exportType,
bool $doRelation = false,
bool $doComments = false,
bool $doMime = false,

View File

@ -10,6 +10,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@ -129,11 +130,11 @@ class ExportPhparray extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}

View File

@ -16,6 +16,7 @@ use PhpMyAdmin\Database\Routines;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertySubgroup;
@ -96,7 +97,7 @@ class ExportSql extends ExportPlugin
{
$hideSql = false;
$hideStructure = false;
if (ExportPlugin::$exportType === 'table' && ! ExportPlugin::$singleTable) {
if (ExportPlugin::$exportType === ExportType::Table && ! ExportPlugin::$singleTable) {
$hideStructure = true;
$hideSql = true;
}
@ -241,7 +242,7 @@ class ExportSql extends ExportPlugin
$subgroup->setSubgroupHeader($leaf);
// server export options
if (ExportPlugin::$exportType === 'server') {
if (ExportPlugin::$exportType === ExportType::Server) {
$leaf = new BoolPropertyItem(
'drop_database',
sprintf(__('Add %s statement'), '<code>DROP DATABASE IF EXISTS</code>'),
@ -249,7 +250,7 @@ class ExportSql extends ExportPlugin
$subgroup->addProperty($leaf);
}
if (ExportPlugin::$exportType === 'database') {
if (ExportPlugin::$exportType === ExportType::Database) {
$createClause = '<code>CREATE DATABASE / USE</code>';
$leaf = new BoolPropertyItem(
'create_database',
@ -258,7 +259,7 @@ class ExportSql extends ExportPlugin
$subgroup->addProperty($leaf);
}
if (ExportPlugin::$exportType === 'table') {
if (ExportPlugin::$exportType === ExportType::Table) {
$dropClause = $dbi->getTable(Current::$database, Current::$table)->isView()
? '<code>DROP VIEW</code>'
: '<code>DROP TABLE</code>';
@ -796,11 +797,11 @@ class ExportSql extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
if ($dbAlias === '') {
$dbAlias = $db;
@ -826,7 +827,7 @@ class ExportSql extends ExportPlugin
}
}
if ($exportType === 'database' && ! isset($GLOBALS['sql_create_database'])) {
if ($exportType === ExportType::Database && ! isset($GLOBALS['sql_create_database'])) {
return true;
}
@ -1869,26 +1870,26 @@ class ExportSql extends ExportPlugin
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure; this is
* deprecated but the parameter is left here
* because /export calls exportStructure()
* also for other export types which use this
* parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param ExportType $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure; this is
* deprecated but the parameter is left here
* because /export calls exportStructure()
* also for other export types which use this
* parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(
string $db,
string $table,
string $exportMode,
string $exportType,
ExportType $exportType,
bool $doRelation = false,
bool $doComments = false,
bool $doMime = false,
@ -1972,7 +1973,7 @@ class ExportSql extends ExportPlugin
)
. $this->exportComment();
// delete the stand-in table previously created (if any)
if ($exportType !== 'table') {
if ($exportType !== ExportType::Table) {
$dump .= 'DROP TABLE IF EXISTS '
. Util::backquote($tableAlias) . ';' . "\n";
}
@ -1987,7 +1988,7 @@ class ExportSql extends ExportPlugin
)
. $this->exportComment();
// delete the stand-in table previously created (if any)
if ($exportType !== 'table') {
if ($exportType !== ExportType::Table) {
$dump .= 'DROP TABLE IF EXISTS '
. Util::backquote($tableAlias) . ';' . "\n";
}

View File

@ -11,6 +11,7 @@ use PhpMyAdmin\Column;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -136,11 +137,11 @@ class ExportTexytext extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}
@ -450,26 +451,26 @@ class ExportTexytext extends ExportPlugin
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because /export calls
* $this->exportStructure() also for other
* export types which use this parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param ExportType $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because /export calls
* $this->exportStructure() also for other
* export types which use this parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(
string $db,
string $table,
string $exportMode,
string $exportType,
ExportType $exportType,
bool $doRelation = false,
bool $doComments = false,
bool $doMime = false,

View File

@ -12,6 +12,7 @@ use PhpMyAdmin\Database\Routines;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -383,11 +384,11 @@ class ExportXml extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}

View File

@ -11,6 +11,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\FieldMetadata;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@ -104,11 +105,11 @@ class ExportYaml extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}

View File

@ -28,7 +28,7 @@ abstract class ExportPlugin implements Plugin
*/
protected ExportPluginProperties $properties;
public static string $exportType = '';
public static ExportType $exportType = ExportType::Raw;
public static bool $singleTable = false;
final public function __construct(
@ -68,11 +68,11 @@ abstract class ExportPlugin implements Plugin
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
* @param string $db Database name
* @param ExportType $exportType 'server', 'database', 'table'
* @param string $dbAlias Aliases of db
*/
abstract public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool;
abstract public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool;
/**
* Outputs the content of a table
@ -129,25 +129,25 @@ abstract class ExportPlugin implements Plugin
/**
* Outputs table's structure
*
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because /export
* calls exportStructure() also for other export
* types which use this parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
* @param string $db database name
* @param string $table table name
* @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param ExportType $exportType 'server', 'database', 'table'
* @param bool $doRelation whether to include relation comments
* @param bool $doComments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because /export
* calls exportStructure() also for other export
* types which use this parameter
* @param bool $doMime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(
string $db,
string $table,
string $exportMode,
string $exportType,
ExportType $exportType,
bool $doRelation = false,
bool $doComments = false,
bool $doMime = false,

View File

@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Plugins;
enum ExportType: string
{
case Server = 'server';
case Database = 'database';
case Table = 'table';
case Raw = 'raw';
}

View File

@ -11,6 +11,7 @@ use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\Export\ExportSql;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\SqlParser\Components\Expression;
use PhpMyAdmin\SqlParser\Components\OptionsArray;
use PhpMyAdmin\SqlParser\Context;
@ -462,7 +463,7 @@ class TableMover
*
* @var ExportSql $exportSqlPlugin
*/
$exportSqlPlugin = Plugins::getPlugin('export', 'sql', 'table');
$exportSqlPlugin = Plugins::getPlugin('export', 'sql', ExportType::Table);
// It is better that all identifiers are quoted
$exportSqlPlugin->useSqlBackquotes(true);

View File

@ -50,7 +50,7 @@ class CreateControllerTest extends AbstractTestCase
$template = new Template();
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody([
'exportType' => 'type',
'exportType' => 'raw',
'templateName' => 'name',
'templateData' => 'data',
'template_id' => null,
@ -67,14 +67,14 @@ class CreateControllerTest extends AbstractTestCase
ExportTemplate::fromArray([
'id' => 1,
'username' => 'user1',
'exportType' => 'type1',
'exportType' => 'raw',
'name' => 'name1',
'data' => 'data1',
]),
ExportTemplate::fromArray([
'id' => 2,
'username' => 'user2',
'exportType' => 'type2',
'exportType' => 'raw',
'name' => 'name2',
'data' => 'data2',
]),

View File

@ -15,6 +15,7 @@ use PhpMyAdmin\Export\Options;
use PhpMyAdmin\Export\TemplateModel;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
@ -58,7 +59,7 @@ class ExportControllerTest extends AbstractTestCase
);
$pageSettings->init('Export');
$template = new Template();
$exportList = Plugins::getExport('table', true);
$exportList = Plugins::getExport(ExportType::Table, true);
$expected = $template->render('table/export/index', [
'export_type' => 'table',

View File

@ -14,6 +14,7 @@ use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\Export\ExportPhparray;
use PhpMyAdmin\Plugins\Export\ExportSql;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Transformations;
use PHPUnit\Framework\Attributes\CoversClass;
@ -139,7 +140,7 @@ class ExportTest extends AbstractTestCase
['test_table'],
['test_table'],
new ExportSql(new Relation($dbi), $export, new Transformations()),
'database',
ExportType::Database,
false,
true,
false,
@ -218,7 +219,7 @@ SQL;
['test_db'],
'structure_and_data',
new ExportSql(new Relation($dbi), $export, new Transformations()),
'server',
ExportType::Server,
false,
true,
false,
@ -248,7 +249,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
$location = $export->getPageLocationAndSaveMessage('server', Message::error('Error message!'));
$location = $export->getPageLocationAndSaveMessage(ExportType::Server, Message::error('Error message!'));
self::assertSame('index.php?route=/server/export&server=2&lang=en', $location);
self::assertSame(
[['context' => 'danger', 'message' => 'Error message!', 'statement' => '']],
@ -263,7 +264,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
$location = $export->getPageLocationAndSaveMessage('server', Message::success('Success message!'));
$location = $export->getPageLocationAndSaveMessage(ExportType::Server, Message::success('Success message!'));
self::assertSame('index.php?route=/server/export&server=2&lang=en', $location);
self::assertSame(
[['context' => 'success', 'message' => 'Success message!', 'statement' => '']],
@ -279,7 +280,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
$location = $export->getPageLocationAndSaveMessage('database', Message::error('Error message!'));
$location = $export->getPageLocationAndSaveMessage(ExportType::Database, Message::error('Error message!'));
self::assertSame('index.php?route=/database/export&db=test_db&server=2&lang=en', $location);
self::assertSame(
[['context' => 'danger', 'message' => 'Error message!', 'statement' => '']],
@ -295,7 +296,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
$location = $export->getPageLocationAndSaveMessage('database', Message::success('Success message!'));
$location = $export->getPageLocationAndSaveMessage(ExportType::Database, Message::success('Success message!'));
self::assertSame('index.php?route=/database/export&db=test_db&server=2&lang=en', $location);
self::assertSame(
[['context' => 'success', 'message' => 'Success message!', 'statement' => '']],
@ -312,7 +313,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
$location = $export->getPageLocationAndSaveMessage('table', Message::error('Error message!'));
$location = $export->getPageLocationAndSaveMessage(ExportType::Table, Message::error('Error message!'));
self::assertSame(
'index.php?route=/table/export&db=test_db&table=test_table&single_table=true&server=2&lang=en',
$location,
@ -332,7 +333,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
$location = $export->getPageLocationAndSaveMessage('table', Message::success('Success message!'));
$location = $export->getPageLocationAndSaveMessage(ExportType::Table, Message::success('Success message!'));
self::assertSame(
'index.php?route=/table/export&db=test_db&table=test_table&single_table=true&server=2&lang=en',
$location,

View File

@ -12,6 +12,7 @@ use PhpMyAdmin\Encoding;
use PhpMyAdmin\Export\Options;
use PhpMyAdmin\Export\TemplateModel;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Util;
use PHPUnit\Framework\Attributes\CoversClass;
@ -56,7 +57,7 @@ class OptionsTest extends AbstractTestCase
$config->settings['ZipDump'] = false;
$config->settings['GZipDump'] = false;
$exportType = 'server';
$exportType = ExportType::Server;
$db = 'PMA';
$table = 'PMA_test';
$numTablesStr = '10';
@ -87,7 +88,7 @@ class OptionsTest extends AbstractTestCase
$actual = $this->export->getOptions($exportType, $db, $table, '', $numTablesStr, $unlimNumRowsStr, $exportList);
$expected = [
'export_type' => $exportType,
'export_type' => $exportType->value,
'db' => $db,
'table' => $table,
'templates' => ['is_enabled' => '', 'templates' => [], 'selected' => null],
@ -95,7 +96,7 @@ class OptionsTest extends AbstractTestCase
'hidden_inputs' => [
'db' => $db,
'table' => $table,
'export_type' => $exportType,
'export_type' => $exportType->value,
'export_method' => $config->settings['Export']['method'],
'template_id' => '',
],

View File

@ -9,6 +9,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportCsv;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -362,7 +363,7 @@ class ExportCsvTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}

View File

@ -14,6 +14,7 @@ use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Identifiers\TriggerName;
use PhpMyAdmin\Plugins\Export\ExportHtmlword;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -284,7 +285,7 @@ class ExportHtmlwordTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}
@ -583,7 +584,7 @@ class ExportHtmlwordTest extends AbstractTestCase
'test_db',
'test_table',
'create_table',
'test',
ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@ -609,7 +610,7 @@ class ExportHtmlwordTest extends AbstractTestCase
'test_db',
'test_table',
'triggers',
'test',
ExportType::Raw,
),
);
$result = ob_get_clean();
@ -631,7 +632,7 @@ class ExportHtmlwordTest extends AbstractTestCase
'test_db',
'test_table',
'create_view',
'test',
ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@ -657,7 +658,7 @@ class ExportHtmlwordTest extends AbstractTestCase
'test_db',
'test_table',
'stand_in',
'test',
ExportType::Raw,
),
);
$result = ob_get_clean();

View File

@ -8,6 +8,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportJson;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@ -160,7 +161,7 @@ class ExportJsonTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}

View File

@ -13,6 +13,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportLatex;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -51,7 +52,7 @@ class ExportLatexTest extends AbstractTestCase
$GLOBALS['buffer_needed'] = false;
$GLOBALS['asfile'] = true;
$GLOBALS['save_on_server'] = false;
ExportPlugin::$exportType = 'table';
ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
Current::$database = 'db';
Current::$table = 'table';
@ -75,7 +76,7 @@ class ExportLatexTest extends AbstractTestCase
public function testSetProperties(): void
{
ExportPlugin::$exportType = '';
ExportPlugin::$exportType = ExportType::Raw;
ExportPlugin::$singleTable = false;
$relationParameters = RelationParameters::fromArray([
@ -419,7 +420,7 @@ class ExportLatexTest extends AbstractTestCase
);
// case 2
ExportPlugin::$exportType = 'table';
ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
$method->invoke($this->object, null);
@ -472,7 +473,7 @@ class ExportLatexTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}
@ -609,7 +610,7 @@ class ExportLatexTest extends AbstractTestCase
'database',
'',
'test',
'test',
ExportType::Raw,
true,
true,
true,
@ -697,7 +698,7 @@ class ExportLatexTest extends AbstractTestCase
'database',
'',
'test',
'test',
ExportType::Raw,
true,
true,
true,
@ -755,7 +756,7 @@ class ExportLatexTest extends AbstractTestCase
'database',
'',
'test',
'test',
ExportType::Raw,
),
);
$result = ob_get_clean();
@ -772,7 +773,7 @@ class ExportLatexTest extends AbstractTestCase
'database',
'',
'triggers',
'test',
ExportType::Raw,
),
);
}

View File

@ -10,6 +10,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportMediawiki;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertySubgroup;
@ -214,7 +215,7 @@ class ExportMediawikiTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}
@ -247,7 +248,7 @@ class ExportMediawikiTest extends AbstractTestCase
'db',
'table',
'create_table',
'test',
ExportType::Raw,
),
);
$result = ob_get_clean();

View File

@ -9,6 +9,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportOds;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -207,7 +208,7 @@ class ExportOdsTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}

View File

@ -15,6 +15,7 @@ use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Identifiers\TriggerName;
use PhpMyAdmin\Plugins\Export\ExportOdt;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -70,7 +71,7 @@ class ExportOdtTest extends AbstractTestCase
$GLOBALS['buffer_needed'] = false;
$GLOBALS['asfile'] = true;
$GLOBALS['save_on_server'] = false;
ExportPlugin::$exportType = 'table';
ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
Config::getInstance()->selectedServer['DisableIS'] = true;
$this->object = new ExportOdt(
@ -93,7 +94,7 @@ class ExportOdtTest extends AbstractTestCase
public function testSetProperties(): void
{
ExportPlugin::$exportType = '';
ExportPlugin::$exportType = ExportType::Raw;
ExportPlugin::$singleTable = false;
$relationParameters = RelationParameters::fromArray([
@ -294,7 +295,7 @@ class ExportOdtTest extends AbstractTestCase
);
// case 2
ExportPlugin::$exportType = 'table';
ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
$method->invoke($this->object, null);
@ -350,7 +351,7 @@ class ExportOdtTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}
@ -758,7 +759,7 @@ class ExportOdtTest extends AbstractTestCase
'test_db',
'test_table',
'create_table',
'test',
ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@ -798,7 +799,7 @@ class ExportOdtTest extends AbstractTestCase
'test_db',
'test_table',
'triggers',
'test',
ExportType::Raw,
),
);
@ -828,7 +829,7 @@ class ExportOdtTest extends AbstractTestCase
'test_db',
'test_table',
'create_view',
'test',
ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@ -868,7 +869,7 @@ class ExportOdtTest extends AbstractTestCase
'test_db',
'test_table',
'stand_in',
'test',
ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();

View File

@ -9,6 +9,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportPdf;
use PhpMyAdmin\Plugins\Export\Helpers\Pdf;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\RadioPropertyItem;
@ -212,7 +213,7 @@ class ExportPdfTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}

View File

@ -9,6 +9,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportPhparray;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@ -162,7 +163,7 @@ class ExportPhparrayTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}

View File

@ -14,6 +14,7 @@ use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportSql;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertySubgroup;
@ -68,7 +69,7 @@ class ExportSqlTest extends AbstractTestCase
$GLOBALS['buffer_needed'] = false;
$GLOBALS['asfile'] = false;
$GLOBALS['save_on_server'] = false;
ExportPlugin::$exportType = 'table';
ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
$this->object = new ExportSql(
@ -93,7 +94,7 @@ class ExportSqlTest extends AbstractTestCase
public function testSetPropertiesWithHideSql(): void
{
// test with hide structure and hide sql as true
ExportPlugin::$exportType = 'table';
ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
$method = new ReflectionMethod(ExportSql::class, 'setProperties');
@ -116,7 +117,7 @@ class ExportSqlTest extends AbstractTestCase
->willReturn(['v1', 'v2']);
DatabaseInterface::$instance = $dbi;
ExportPlugin::$exportType = 'server';
ExportPlugin::$exportType = ExportType::Server;
ExportPlugin::$singleTable = false;
$relationParameters = RelationParameters::fromArray([
@ -485,7 +486,7 @@ class ExportSqlTest extends AbstractTestCase
ob_start();
self::assertTrue(
$this->object->exportDBCreate('db', 'database'),
$this->object->exportDBCreate('db', ExportType::Database),
);
$result = ob_get_clean();
@ -519,7 +520,7 @@ class ExportSqlTest extends AbstractTestCase
ob_start();
self::assertTrue(
$this->object->exportDBCreate('db', 'database'),
$this->object->exportDBCreate('db', ExportType::Database),
);
$result = ob_get_clean();
@ -907,7 +908,7 @@ SQL;
'test_db',
'test_table',
'create_table',
'test',
ExportType::Raw,
),
);
$result = ob_get_clean();
@ -930,7 +931,7 @@ SQL;
'test_db',
'test_table',
'triggers',
'test',
ExportType::Raw,
),
);
$result = ob_get_clean();
@ -956,7 +957,7 @@ SQL;
'test_db',
'test_table',
'create_view',
'test',
ExportType::Raw,
),
);
$result = ob_get_clean();
@ -979,7 +980,7 @@ SQL;
'test_db',
'test_table',
'create_view',
'test',
ExportType::Raw,
),
);
$result = ob_get_clean();
@ -996,7 +997,7 @@ SQL;
'test_db',
'test_table',
'stand_in',
'test',
ExportType::Raw,
),
);
$result = ob_get_clean();

View File

@ -17,6 +17,7 @@ use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Identifiers\TriggerName;
use PhpMyAdmin\Plugins\Export\ExportTexytext;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -61,7 +62,7 @@ class ExportTexytextTest extends AbstractTestCase
$GLOBALS['buffer_needed'] = false;
$GLOBALS['asfile'] = false;
$GLOBALS['save_on_server'] = false;
ExportPlugin::$exportType = 'table';
ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
Current::$database = '';
Current::$table = '';
@ -205,7 +206,7 @@ class ExportTexytextTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}
@ -349,7 +350,7 @@ class ExportTexytextTest extends AbstractTestCase
'test_db',
'test_table',
'create_table',
'test',
ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@ -374,7 +375,7 @@ class ExportTexytextTest extends AbstractTestCase
'test_db',
'test_table',
'triggers',
'test',
ExportType::Raw,
),
);
$result = ob_get_clean();
@ -396,7 +397,7 @@ class ExportTexytextTest extends AbstractTestCase
'test_db',
'test_table',
'create_view',
'test',
ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@ -421,7 +422,7 @@ class ExportTexytextTest extends AbstractTestCase
'test_db',
'test_table',
'stand_in',
'test',
ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();

View File

@ -11,6 +11,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportXml;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -46,7 +47,7 @@ class ExportXmlTest extends AbstractTestCase
$GLOBALS['buffer_needed'] = false;
$GLOBALS['asfile'] = false;
$GLOBALS['save_on_server'] = false;
ExportPlugin::$exportType = 'table';
ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
Current::$database = 'db';
Config::getInstance()->selectedServer['DisableIS'] = true;
@ -365,7 +366,7 @@ class ExportXmlTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}

View File

@ -9,6 +9,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportYaml;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@ -152,7 +153,7 @@ class ExportYamlTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
$this->object->exportDBCreate('testDB', 'database'),
$this->object->exportDBCreate('testDB', ExportType::Database),
);
}

View File

@ -11,6 +11,7 @@ use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Import\ImportSettings;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Transformations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
@ -27,8 +28,8 @@ class PluginsTest extends AbstractTestCase
public function testGetExport(): void
{
$plugins = Plugins::getExport('database', false);
self::assertSame('database', ExportPlugin::$exportType);
$plugins = Plugins::getExport(ExportType::Database, false);
self::assertSame(ExportType::Database, ExportPlugin::$exportType);
self::assertFalse(ExportPlugin::$singleTable);
self::assertCount(14, $plugins);
self::assertContainsOnlyInstancesOf(Plugins\ExportPlugin::class, $plugins);

View File

@ -1424,20 +1424,20 @@ class DbiDummy implements DbiExtension
],
[
'query' => 'INSERT INTO `db`.`table` (`username`, `export_type`, `template_name`, `template_data`)'
. ' VALUES (\'user\', \'type\', \'name\', \'data\');',
. ' VALUES (\'user\', \'raw\', \'name\', \'data\');',
'result' => true,
],
[
'query' => 'SELECT * FROM `db`.`table` WHERE `username` = \'user\''
. ' AND `export_type` = \'type\' ORDER BY `template_name`;',
. ' AND `export_type` = \'raw\' ORDER BY `template_name`;',
'columns' => ['id', 'username', 'export_type', 'template_name', 'template_data'],
'result' => [['1', 'user1', 'type1', 'name1', 'data1'], ['2', 'user2', 'type2', 'name2', 'data2']],
'result' => [['1', 'user1', 'raw', 'name1', 'data1'], ['2', 'user2', 'raw', 'name2', 'data2']],
],
['query' => 'DELETE FROM `db`.`table` WHERE `id` = 1 AND `username` = \'user\';', 'result' => true],
[
'query' => 'SELECT * FROM `db`.`table` WHERE `id` = 1 AND `username` = \'user\';',
'columns' => ['id', 'username', 'export_type', 'template_name', 'template_data'],
'result' => [['1', 'user1', 'type1', 'name1', 'data1']],
'result' => [['1', 'user1', 'raw', 'name1', 'data1']],
],
[
'query' => 'UPDATE `db`.`table` SET `template_data` = \'data\''