Merge pull request #17723 from MauricioFauth/crlf-global
Remove `crlf` global variable
This commit is contained in:
commit
344981d57d
@ -35,8 +35,6 @@ use function register_shutdown_function;
|
||||
use function strlen;
|
||||
use function time;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
final class ExportController extends AbstractController
|
||||
{
|
||||
/** @var Export */
|
||||
@ -56,7 +54,6 @@ final class ExportController extends AbstractController
|
||||
$GLOBALS['errorUrl'] = $GLOBALS['errorUrl'] ?? null;
|
||||
$GLOBALS['message'] = $GLOBALS['message'] ?? null;
|
||||
$GLOBALS['compression'] = $GLOBALS['compression'] ?? null;
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
$GLOBALS['asfile'] = $GLOBALS['asfile'] ?? null;
|
||||
$GLOBALS['buffer_needed'] = $GLOBALS['buffer_needed'] ?? null;
|
||||
$GLOBALS['save_on_server'] = $GLOBALS['save_on_server'] ?? null;
|
||||
@ -261,14 +258,6 @@ final class ExportController extends AbstractController
|
||||
// We send fake headers to avoid browser timeout when buffering
|
||||
$GLOBALS['time_start'] = time();
|
||||
|
||||
// Defines the default <CR><LF> format.
|
||||
// For SQL always use \n as MySQL wants this on all platforms.
|
||||
if ($GLOBALS['what'] === 'sql') {
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
} else {
|
||||
$GLOBALS['crlf'] = PHP_EOL;
|
||||
}
|
||||
|
||||
$GLOBALS['output_kanji_conversion'] = Encoding::canConvertKanji();
|
||||
|
||||
// Do we need to convert charset?
|
||||
@ -397,7 +386,6 @@ final class ExportController extends AbstractController
|
||||
$GLOBALS['db_select'],
|
||||
$GLOBALS['whatStrucOrData'],
|
||||
$GLOBALS['export_plugin'],
|
||||
$GLOBALS['crlf'],
|
||||
$GLOBALS['errorUrl'],
|
||||
$GLOBALS['export_type'],
|
||||
$GLOBALS['do_relation'],
|
||||
@ -431,7 +419,6 @@ final class ExportController extends AbstractController
|
||||
$GLOBALS['table_structure'],
|
||||
$GLOBALS['table_data'],
|
||||
$GLOBALS['export_plugin'],
|
||||
$GLOBALS['crlf'],
|
||||
$GLOBALS['errorUrl'],
|
||||
$GLOBALS['export_type'],
|
||||
$GLOBALS['do_relation'],
|
||||
@ -452,7 +439,6 @@ final class ExportController extends AbstractController
|
||||
$GLOBALS['table_structure'],
|
||||
$GLOBALS['table_data'],
|
||||
$GLOBALS['export_plugin'],
|
||||
$GLOBALS['crlf'],
|
||||
$GLOBALS['errorUrl'],
|
||||
$GLOBALS['export_type'],
|
||||
$GLOBALS['do_relation'],
|
||||
@ -467,7 +453,6 @@ final class ExportController extends AbstractController
|
||||
Export::exportRaw(
|
||||
$GLOBALS['whatStrucOrData'],
|
||||
$GLOBALS['export_plugin'],
|
||||
$GLOBALS['crlf'],
|
||||
$GLOBALS['errorUrl'],
|
||||
$GLOBALS['sql_query'],
|
||||
$GLOBALS['export_type']
|
||||
@ -495,7 +480,6 @@ final class ExportController extends AbstractController
|
||||
$GLOBALS['table'],
|
||||
$GLOBALS['whatStrucOrData'],
|
||||
$GLOBALS['export_plugin'],
|
||||
$GLOBALS['crlf'],
|
||||
$GLOBALS['errorUrl'],
|
||||
$GLOBALS['export_type'],
|
||||
$GLOBALS['do_relation'],
|
||||
@ -517,7 +501,6 @@ final class ExportController extends AbstractController
|
||||
$GLOBALS['table'],
|
||||
$GLOBALS['whatStrucOrData'],
|
||||
$GLOBALS['export_plugin'],
|
||||
$GLOBALS['crlf'],
|
||||
$GLOBALS['errorUrl'],
|
||||
$GLOBALS['export_type'],
|
||||
$GLOBALS['do_relation'],
|
||||
|
||||
@ -562,7 +562,6 @@ class Export
|
||||
* @param string|array $dbSelect the selected databases to export
|
||||
* @param string $whatStrucOrData structure or data or both
|
||||
* @param ExportPlugin $exportPlugin the selected export plugin
|
||||
* @param string $crlf end of line character(s)
|
||||
* @param string $errorUrl the URL in case of error
|
||||
* @param string $exportType the export type
|
||||
* @param bool $doRelation whether to export relation info
|
||||
@ -576,7 +575,6 @@ class Export
|
||||
$dbSelect,
|
||||
string $whatStrucOrData,
|
||||
ExportPlugin $exportPlugin,
|
||||
string $crlf,
|
||||
string $errorUrl,
|
||||
string $exportType,
|
||||
bool $doRelation,
|
||||
@ -605,7 +603,6 @@ class Export
|
||||
$tables,
|
||||
$tables,
|
||||
$exportPlugin,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$exportType,
|
||||
$doRelation,
|
||||
@ -632,7 +629,6 @@ class Export
|
||||
* @param array $tableStructure whether to export structure for each table
|
||||
* @param array $tableData whether to export data for each table
|
||||
* @param ExportPlugin $exportPlugin the selected export plugin
|
||||
* @param string $crlf end of line character(s)
|
||||
* @param string $errorUrl the URL in case of error
|
||||
* @param string $exportType the export type
|
||||
* @param bool $doRelation whether to export relation info
|
||||
@ -649,7 +645,6 @@ class Export
|
||||
array $tableStructure,
|
||||
array $tableData,
|
||||
ExportPlugin $exportPlugin,
|
||||
string $crlf,
|
||||
string $errorUrl,
|
||||
string $exportType,
|
||||
bool $doRelation,
|
||||
@ -711,7 +706,6 @@ class Export
|
||||
&& ! $exportPlugin->exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
'stand_in',
|
||||
$exportType,
|
||||
@ -747,7 +741,6 @@ class Export
|
||||
! $exportPlugin->exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
'create_table',
|
||||
$exportType,
|
||||
@ -776,7 +769,7 @@ class Export
|
||||
. ' FROM ' . Util::backquote($db)
|
||||
. '.' . Util::backquote($table);
|
||||
|
||||
if (! $exportPlugin->exportData($db, $table, $crlf, $errorUrl, $localQuery, $aliases)) {
|
||||
if (! $exportPlugin->exportData($db, $table, $errorUrl, $localQuery, $aliases)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -800,7 +793,6 @@ class Export
|
||||
! $exportPlugin->exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
'triggers',
|
||||
$exportType,
|
||||
@ -832,7 +824,6 @@ class Export
|
||||
! $exportPlugin->exportStructure(
|
||||
$db,
|
||||
$view,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
'create_view',
|
||||
$exportType,
|
||||
@ -896,7 +887,6 @@ class Export
|
||||
*
|
||||
* @param string $whatStrucOrData whether to export structure for each table or raw
|
||||
* @param ExportPlugin $exportPlugin the selected export plugin
|
||||
* @param string $crlf end of line character(s)
|
||||
* @param string $errorUrl the URL in case of error
|
||||
* @param string $sqlQuery the query to be executed
|
||||
* @param string $exportType the export type
|
||||
@ -904,7 +894,6 @@ class Export
|
||||
public static function exportRaw(
|
||||
string $whatStrucOrData,
|
||||
ExportPlugin $exportPlugin,
|
||||
string $crlf,
|
||||
string $errorUrl,
|
||||
string $sqlQuery,
|
||||
string $exportType
|
||||
@ -914,7 +903,7 @@ class Export
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $exportPlugin->exportRawQuery($errorUrl, $sqlQuery, $crlf)) {
|
||||
if (! $exportPlugin->exportRawQuery($errorUrl, $sqlQuery)) {
|
||||
$GLOBALS['message'] = Message::error(
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
/* l10n: A query written by the user is a "raw query" that could be using no tables or databases in particular */
|
||||
@ -932,7 +921,6 @@ 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 $crlf end of line character(s)
|
||||
* @param string $errorUrl the URL in case of error
|
||||
* @param string $exportType the export type
|
||||
* @param bool $doRelation whether to export relation info
|
||||
@ -950,7 +938,6 @@ class Export
|
||||
string $table,
|
||||
string $whatStrucOrData,
|
||||
ExportPlugin $exportPlugin,
|
||||
string $crlf,
|
||||
string $errorUrl,
|
||||
string $exportType,
|
||||
bool $doRelation,
|
||||
@ -986,7 +973,6 @@ class Export
|
||||
! $exportPlugin->exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
'create_view',
|
||||
$exportType,
|
||||
@ -1005,7 +991,6 @@ class Export
|
||||
! $exportPlugin->exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
'create_table',
|
||||
$exportType,
|
||||
@ -1044,7 +1029,7 @@ class Export
|
||||
. '.' . Util::backquote($table) . $addQuery;
|
||||
}
|
||||
|
||||
if (! $exportPlugin->exportData($db, $table, $crlf, $errorUrl, $localQuery, $aliases)) {
|
||||
if (! $exportPlugin->exportData($db, $table, $errorUrl, $localQuery, $aliases)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1059,7 +1044,6 @@ class Export
|
||||
! $exportPlugin->exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
'triggers',
|
||||
$exportType,
|
||||
|
||||
@ -160,7 +160,7 @@ class Operations
|
||||
|
||||
$views[] = $each_table;
|
||||
// Create stand-in definition to resolve view dependencies
|
||||
$sql_view_standin = $export_sql_plugin->getTableDefStandIn($db, $each_table, "\n");
|
||||
$sql_view_standin = $export_sql_plugin->getTableDefStandIn($db, $each_table);
|
||||
$this->dbi->selectDb($newDatabaseName);
|
||||
$this->dbi->query($sql_view_standin);
|
||||
$GLOBALS['sql_query'] .= "\n" . $sql_view_standin;
|
||||
|
||||
@ -23,6 +23,8 @@ use function preg_replace;
|
||||
use function sprintf;
|
||||
use function ucfirst;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
/**
|
||||
* Handles the export for the CodeGen class
|
||||
*/
|
||||
@ -144,7 +146,6 @@ class ExportCodegen extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -152,7 +153,6 @@ class ExportCodegen extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -160,11 +160,11 @@ class ExportCodegen extends ExportPlugin
|
||||
$format = (int) $GLOBALS['codegen_format'];
|
||||
|
||||
if ($format === self::HANDLER_NHIBERNATE_CS) {
|
||||
return $this->export->outputHandler($this->handleNHibernateCSBody($db, $table, $crlf, $aliases));
|
||||
return $this->export->outputHandler($this->handleNHibernateCSBody($db, $table, $aliases));
|
||||
}
|
||||
|
||||
if ($format === self::HANDLER_NHIBERNATE_XML) {
|
||||
return $this->export->outputHandler($this->handleNHibernateXMLBody($db, $table, $crlf, $aliases));
|
||||
return $this->export->outputHandler($this->handleNHibernateXMLBody($db, $table, $aliases));
|
||||
}
|
||||
|
||||
return $this->export->outputHandler(sprintf('%s is not supported.', $format));
|
||||
@ -199,12 +199,11 @@ class ExportCodegen extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf line separator
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
*
|
||||
* @return string containing C# code lines, separated by "\n"
|
||||
*/
|
||||
private function handleNHibernateCSBody($db, $table, $crlf, array $aliases = [])
|
||||
private function handleNHibernateCSBody($db, $table, array $aliases = [])
|
||||
{
|
||||
$db_alias = $db;
|
||||
$table_alias = $table;
|
||||
@ -294,7 +293,7 @@ class ExportCodegen extends ExportPlugin
|
||||
$lines[] = ' #endregion';
|
||||
$lines[] = '}';
|
||||
|
||||
return implode($crlf, $lines);
|
||||
return implode(PHP_EOL, $lines);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,7 +301,6 @@ class ExportCodegen extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf line separator
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
*
|
||||
* @return string containing XML code lines, separated by "\n"
|
||||
@ -310,7 +308,6 @@ class ExportCodegen extends ExportPlugin
|
||||
private function handleNHibernateXMLBody(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
array $aliases = []
|
||||
) {
|
||||
$db_alias = $db;
|
||||
@ -363,7 +360,7 @@ class ExportCodegen extends ExportPlugin
|
||||
$lines[] = ' </class>';
|
||||
$lines[] = '</hibernate-mapping>';
|
||||
|
||||
return implode($crlf, $lines);
|
||||
return implode(PHP_EOL, $lines);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -23,6 +23,8 @@ use function preg_replace;
|
||||
use function str_replace;
|
||||
use function trim;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
/**
|
||||
* Handles the export for the CSV format
|
||||
*/
|
||||
@ -137,7 +139,7 @@ class ExportCsv extends ExportPlugin
|
||||
}
|
||||
} else {
|
||||
if (empty($GLOBALS['csv_terminated']) || mb_strtolower($GLOBALS['csv_terminated']) === 'auto') {
|
||||
$GLOBALS['csv_terminated'] = $GLOBALS['crlf'];
|
||||
$GLOBALS['csv_terminated'] = PHP_EOL;
|
||||
} else {
|
||||
$GLOBALS['csv_terminated'] = str_replace(
|
||||
[
|
||||
@ -206,7 +208,6 @@ class ExportCsv extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -214,7 +215,6 @@ class ExportCsv extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -343,10 +343,9 @@ class ExportCsv extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the end of line sequence
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
return $this->exportData('', '', $crlf, $errorUrl, $sqlQuery);
|
||||
return $this->exportData('', '', $errorUrl, $sqlQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,7 +169,6 @@ class ExportHtmlword extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -177,7 +176,6 @@ class ExportHtmlword extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -260,12 +258,11 @@ class ExportHtmlword extends ExportPlugin
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $view the view name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
*
|
||||
* @return string resulting definition
|
||||
*/
|
||||
public function getTableDefStandIn($db, $view, $crlf, $aliases = [])
|
||||
public function getTableDefStandIn($db, $view, $aliases = [])
|
||||
{
|
||||
$schema_insert = '<table width="100%" cellspacing="1">'
|
||||
. '<tr class="print-category">'
|
||||
@ -502,7 +499,6 @@ class ExportHtmlword extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $exportMode 'create_table', 'triggers', 'create_view',
|
||||
* 'stand_in'
|
||||
@ -521,7 +517,6 @@ class ExportHtmlword extends ExportPlugin
|
||||
public function exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$exportMode,
|
||||
$exportType,
|
||||
@ -568,7 +563,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
. htmlspecialchars($table_alias)
|
||||
. '</h2>';
|
||||
// export a stand-in definition to resolve view dependencies
|
||||
$dump .= $this->getTableDefStandIn($db, $table, $crlf, $aliases);
|
||||
$dump .= $this->getTableDefStandIn($db, $table, $aliases);
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($dump);
|
||||
|
||||
@ -24,6 +24,7 @@ use function json_encode;
|
||||
|
||||
use const JSON_PRETTY_PRINT;
|
||||
use const JSON_UNESCAPED_UNICODE;
|
||||
use const PHP_EOL;
|
||||
|
||||
/**
|
||||
* Handles the export for the JSON format
|
||||
@ -107,8 +108,6 @@ class ExportJson extends ExportPlugin
|
||||
*/
|
||||
public function exportHeader(): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
$data = $this->encode([
|
||||
'type' => 'header',
|
||||
'version' => Version::VERSION,
|
||||
@ -118,7 +117,7 @@ class ExportJson extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->export->outputHandler('[' . $GLOBALS['crlf'] . $data . ',' . $GLOBALS['crlf']);
|
||||
return $this->export->outputHandler('[' . PHP_EOL . $data . ',' . PHP_EOL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,9 +125,7 @@ class ExportJson extends ExportPlugin
|
||||
*/
|
||||
public function exportFooter(): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
return $this->export->outputHandler(']' . $GLOBALS['crlf']);
|
||||
return $this->export->outputHandler(']' . PHP_EOL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,8 +136,6 @@ class ExportJson extends ExportPlugin
|
||||
*/
|
||||
public function exportDBHeader($db, $dbAlias = ''): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
if (empty($dbAlias)) {
|
||||
$dbAlias = $db;
|
||||
}
|
||||
@ -150,7 +145,7 @@ class ExportJson extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($data . ',' . $GLOBALS['crlf']);
|
||||
return $this->export->outputHandler($data . ',' . PHP_EOL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,7 +175,6 @@ class ExportJson extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -188,7 +182,6 @@ class ExportJson extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -215,7 +208,7 @@ class ExportJson extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->doExportForQuery($GLOBALS['dbi'], $sqlQuery, $buffer, $crlf, $aliases, $db, $table);
|
||||
return $this->doExportForQuery($GLOBALS['dbi'], $sqlQuery, $buffer, $aliases, $db, $table);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,14 +228,13 @@ class ExportJson extends ExportPlugin
|
||||
DatabaseInterface $dbi,
|
||||
string $sqlQuery,
|
||||
string $buffer,
|
||||
string $crlf,
|
||||
?array $aliases,
|
||||
?string $db,
|
||||
?string $table
|
||||
): bool {
|
||||
[$header, $footer] = explode('"@@DATA@@"', $buffer);
|
||||
|
||||
if (! $this->export->outputHandler($header . $crlf . '[' . $crlf)) {
|
||||
if (! $this->export->outputHandler($header . PHP_EOL . '[' . PHP_EOL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -269,7 +261,7 @@ class ExportJson extends ExportPlugin
|
||||
|
||||
// Output table name as comment if this is the first record of the table
|
||||
if ($record_cnt > 1) {
|
||||
if (! $this->export->outputHandler(',' . $crlf)) {
|
||||
if (! $this->export->outputHandler(',' . PHP_EOL)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -311,7 +303,7 @@ class ExportJson extends ExportPlugin
|
||||
}
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($crlf . ']' . $crlf . $footer . $crlf);
|
||||
return $this->export->outputHandler(PHP_EOL . ']' . PHP_EOL . $footer . PHP_EOL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -319,9 +311,8 @@ class ExportJson extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the end of line sequence
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
$buffer = $this->encode([
|
||||
'type' => 'raw',
|
||||
@ -331,6 +322,6 @@ class ExportJson extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->doExportForQuery($GLOBALS['dbi'], $sqlQuery, $buffer, $crlf, null, null, null);
|
||||
return $this->doExportForQuery($GLOBALS['dbi'], $sqlQuery, $buffer, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ use function mb_strpos;
|
||||
use function mb_substr;
|
||||
use function str_replace;
|
||||
|
||||
use const PHP_EOL;
|
||||
use const PHP_VERSION;
|
||||
|
||||
/**
|
||||
@ -201,22 +202,20 @@ class ExportLatex extends ExportPlugin
|
||||
*/
|
||||
public function exportHeader(): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
$head = '% phpMyAdmin LaTeX Dump' . $GLOBALS['crlf']
|
||||
. '% version ' . Version::VERSION . $GLOBALS['crlf']
|
||||
. '% https://www.phpmyadmin.net/' . $GLOBALS['crlf']
|
||||
. '%' . $GLOBALS['crlf']
|
||||
$head = '% phpMyAdmin LaTeX Dump' . PHP_EOL
|
||||
. '% version ' . Version::VERSION . PHP_EOL
|
||||
. '% https://www.phpmyadmin.net/' . PHP_EOL
|
||||
. '%' . PHP_EOL
|
||||
. '% ' . __('Host:') . ' ' . $GLOBALS['cfg']['Server']['host'];
|
||||
if (! empty($GLOBALS['cfg']['Server']['port'])) {
|
||||
$head .= ':' . $GLOBALS['cfg']['Server']['port'];
|
||||
}
|
||||
|
||||
$head .= $GLOBALS['crlf']
|
||||
$head .= PHP_EOL
|
||||
. '% ' . __('Generation Time:') . ' '
|
||||
. Util::localisedDate() . $GLOBALS['crlf']
|
||||
. '% ' . __('Server version:') . ' ' . $GLOBALS['dbi']->getVersionString() . $GLOBALS['crlf']
|
||||
. '% ' . __('PHP Version:') . ' ' . PHP_VERSION . $GLOBALS['crlf'];
|
||||
. Util::localisedDate() . PHP_EOL
|
||||
. '% ' . __('Server version:') . ' ' . $GLOBALS['dbi']->getVersionString() . PHP_EOL
|
||||
. '% ' . __('PHP Version:') . ' ' . PHP_VERSION . PHP_EOL;
|
||||
|
||||
return $this->export->outputHandler($head);
|
||||
}
|
||||
@ -241,11 +240,9 @@ class ExportLatex extends ExportPlugin
|
||||
$dbAlias = $db;
|
||||
}
|
||||
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
$head = '% ' . $GLOBALS['crlf']
|
||||
. '% ' . __('Database:') . ' \'' . $dbAlias . '\'' . $GLOBALS['crlf']
|
||||
. '% ' . $GLOBALS['crlf'];
|
||||
$head = '% ' . PHP_EOL
|
||||
. '% ' . __('Database:') . ' \'' . $dbAlias . '\'' . PHP_EOL
|
||||
. '% ' . PHP_EOL;
|
||||
|
||||
return $this->export->outputHandler($head);
|
||||
}
|
||||
@ -277,7 +274,6 @@ class ExportLatex extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -285,7 +281,6 @@ class ExportLatex extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -312,16 +307,16 @@ class ExportLatex extends ExportPlugin
|
||||
$columns_alias[$i] = $col_as;
|
||||
}
|
||||
|
||||
$buffer = $crlf . '%' . $crlf . '% ' . __('Data:') . ' ' . $table_alias
|
||||
. $crlf . '%' . $crlf . ' \\begin{longtable}{|';
|
||||
$buffer = PHP_EOL . '%' . PHP_EOL . '% ' . __('Data:') . ' ' . $table_alias
|
||||
. PHP_EOL . '%' . PHP_EOL . ' \\begin{longtable}{|';
|
||||
|
||||
for ($index = 0; $index < $columns_cnt; $index++) {
|
||||
$buffer .= 'l|';
|
||||
}
|
||||
|
||||
$buffer .= '} ' . $crlf;
|
||||
$buffer .= '} ' . PHP_EOL;
|
||||
|
||||
$buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . $crlf;
|
||||
$buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . PHP_EOL;
|
||||
if (isset($GLOBALS['latex_caption'])) {
|
||||
$buffer .= ' \\caption{'
|
||||
. Util::expandUserString(
|
||||
@ -354,7 +349,7 @@ class ExportLatex extends ExportPlugin
|
||||
}
|
||||
|
||||
$buffer = mb_substr($buffer, 0, -2) . '\\\\ \\hline \hline ';
|
||||
if (! $this->export->outputHandler($buffer . ' \\endfirsthead ' . $crlf)) {
|
||||
if (! $this->export->outputHandler($buffer . ' \\endfirsthead ' . PHP_EOL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -374,7 +369,7 @@ class ExportLatex extends ExportPlugin
|
||||
}
|
||||
}
|
||||
|
||||
if (! $this->export->outputHandler($buffer . '\\endhead \\endfoot' . $crlf)) {
|
||||
if (! $this->export->outputHandler($buffer . '\\endhead \\endfoot' . PHP_EOL)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -402,13 +397,13 @@ class ExportLatex extends ExportPlugin
|
||||
}
|
||||
}
|
||||
|
||||
$buffer .= ' \\\\ \\hline ' . $crlf;
|
||||
$buffer .= ' \\\\ \\hline ' . PHP_EOL;
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$buffer = ' \\end{longtable}' . $crlf;
|
||||
$buffer = ' \\end{longtable}' . PHP_EOL;
|
||||
|
||||
return $this->export->outputHandler($buffer);
|
||||
}
|
||||
@ -418,11 +413,10 @@ class ExportLatex extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the seperator for a file
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
return $this->exportData('', '', $crlf, $errorUrl, $sqlQuery);
|
||||
return $this->exportData('', '', $errorUrl, $sqlQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -430,7 +424,6 @@ class ExportLatex extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $exportMode 'create_table', 'triggers', 'create_view',
|
||||
* 'stand_in'
|
||||
@ -449,7 +442,6 @@ class ExportLatex extends ExportPlugin
|
||||
public function exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$exportMode,
|
||||
$exportType,
|
||||
@ -497,8 +489,8 @@ class ExportLatex extends ExportPlugin
|
||||
/**
|
||||
* Displays the table structure
|
||||
*/
|
||||
$buffer = $crlf . '%' . $crlf . '% ' . __('Structure:') . ' '
|
||||
. $table_alias . $crlf . '%' . $crlf . ' \\begin{longtable}{';
|
||||
$buffer = PHP_EOL . '%' . PHP_EOL . '% ' . __('Structure:') . ' '
|
||||
. $table_alias . PHP_EOL . '%' . PHP_EOL . ' \\begin{longtable}{';
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
return false;
|
||||
}
|
||||
@ -516,7 +508,7 @@ class ExportLatex extends ExportPlugin
|
||||
$alignment .= 'l|';
|
||||
}
|
||||
|
||||
$buffer = $alignment . '} ' . $crlf;
|
||||
$buffer = $alignment . '} ' . PHP_EOL;
|
||||
|
||||
$header = ' \\hline ';
|
||||
$header .= '\\multicolumn{1}{|c|}{\\textbf{' . __('Column')
|
||||
@ -554,11 +546,11 @@ class ExportLatex extends ExportPlugin
|
||||
'database' => $db_alias,
|
||||
]
|
||||
)
|
||||
. '} \\\\' . $crlf;
|
||||
. '} \\\\' . PHP_EOL;
|
||||
}
|
||||
|
||||
$buffer .= $header . ' \\\\ \\hline \\hline' . $crlf
|
||||
. '\\endfirsthead' . $crlf;
|
||||
$buffer .= $header . ' \\\\ \\hline \\hline' . PHP_EOL
|
||||
. '\\endfirsthead' . PHP_EOL;
|
||||
// Table caption on next pages
|
||||
if (isset($GLOBALS['latex_caption'])) {
|
||||
$buffer .= ' \\caption{'
|
||||
@ -567,10 +559,10 @@ class ExportLatex extends ExportPlugin
|
||||
[static::class, 'texEscape'],
|
||||
['table' => $table_alias, 'database' => $db_alias]
|
||||
)
|
||||
. '} \\\\ ' . $crlf;
|
||||
. '} \\\\ ' . PHP_EOL;
|
||||
}
|
||||
|
||||
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . $crlf;
|
||||
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . PHP_EOL;
|
||||
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
return false;
|
||||
@ -639,14 +631,14 @@ class ExportLatex extends ExportPlugin
|
||||
}
|
||||
|
||||
$buffer = str_replace("\000", ' & ', $local_buffer);
|
||||
$buffer .= ' \\\\ \\hline ' . $crlf;
|
||||
$buffer .= ' \\\\ \\hline ' . PHP_EOL;
|
||||
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$buffer = ' \\end{longtable}' . $crlf;
|
||||
$buffer = ' \\end{longtable}' . PHP_EOL;
|
||||
|
||||
return $this->export->outputHandler($buffer);
|
||||
}
|
||||
|
||||
@ -147,7 +147,6 @@ class ExportMediawiki extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $exportMode 'create_table','triggers','create_view',
|
||||
* 'stand_in'
|
||||
@ -166,7 +165,6 @@ class ExportMediawiki extends ExportPlugin
|
||||
public function exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$exportMode,
|
||||
$exportType,
|
||||
@ -254,7 +252,6 @@ class ExportMediawiki extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -262,7 +259,6 @@ class ExportMediawiki extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -338,11 +334,10 @@ class ExportMediawiki extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the end of line sequence
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
return $this->exportData('', '', $crlf, $errorUrl, $sqlQuery);
|
||||
return $this->exportData('', '', $errorUrl, $sqlQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -187,7 +187,6 @@ class ExportOds extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -195,7 +194,6 @@ class ExportOds extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -317,10 +315,9 @@ class ExportOds extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the end of line sequence
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
return $this->exportData('', '', $crlf, $errorUrl, $sqlQuery);
|
||||
return $this->exportData('', '', $errorUrl, $sqlQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,7 +216,6 @@ class ExportOdt extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -224,7 +223,6 @@ class ExportOdt extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -327,11 +325,10 @@ class ExportOdt extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the end of line sequence
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
return $this->exportData('', '', $crlf, $errorUrl, $sqlQuery);
|
||||
return $this->exportData('', '', $errorUrl, $sqlQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -339,12 +336,11 @@ class ExportOdt extends ExportPlugin
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $view the view name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
*
|
||||
* @return string resulting definition
|
||||
*/
|
||||
public function getTableDefStandIn($db, $view, $crlf, $aliases = [])
|
||||
public function getTableDefStandIn($db, $view, $aliases = [])
|
||||
{
|
||||
$db_alias = $db;
|
||||
$view_alias = $view;
|
||||
@ -399,7 +395,6 @@ class ExportOdt extends ExportPlugin
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $table the table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $error_url the url to go back in case of error
|
||||
* @param bool $do_relation whether to include relation comments
|
||||
* @param bool $do_comments whether to include the pmadb-style column
|
||||
@ -417,7 +412,6 @@ class ExportOdt extends ExportPlugin
|
||||
public function getTableDef(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$error_url,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
@ -638,7 +632,6 @@ class ExportOdt extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $exportMode 'create_table', 'triggers', 'create_view',
|
||||
* 'stand_in'
|
||||
@ -656,7 +649,6 @@ class ExportOdt extends ExportPlugin
|
||||
public function exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$exportMode,
|
||||
$exportType,
|
||||
@ -679,7 +671,6 @@ class ExportOdt extends ExportPlugin
|
||||
$this->getTableDef(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
@ -711,7 +702,6 @@ class ExportOdt extends ExportPlugin
|
||||
$this->getTableDef(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
@ -729,7 +719,7 @@ class ExportOdt extends ExportPlugin
|
||||
. htmlspecialchars($table_alias)
|
||||
. '</text:h>';
|
||||
// export a stand-in definition to resolve view dependencies
|
||||
$this->getTableDefStandIn($db, $table, $crlf, $aliases);
|
||||
$this->getTableDefStandIn($db, $table, $aliases);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -167,7 +167,6 @@ class ExportPdf extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -175,7 +174,6 @@ class ExportPdf extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -200,9 +198,8 @@ class ExportPdf extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the end of line sequence
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
$pdf = $this->getPdf();
|
||||
$pdf->setDbAlias('----');
|
||||
@ -218,7 +215,6 @@ class ExportPdf extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $exportMode 'create_table', 'triggers', 'create_view',
|
||||
* 'stand_in'
|
||||
@ -237,7 +233,6 @@ class ExportPdf extends ExportPlugin
|
||||
public function exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$exportMode,
|
||||
$exportType,
|
||||
@ -292,7 +287,7 @@ class ExportPdf extends ExportPlugin
|
||||
case 'stand_in':
|
||||
/* export a stand-in definition to resolve view dependencies
|
||||
* Yet to develop this function
|
||||
* $pdf->getTableDefStandIn($db, $table, $crlf);
|
||||
* $pdf->getTableDefStandIn($db, $table);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,8 @@ use function preg_replace;
|
||||
use function strtr;
|
||||
use function var_export;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
/**
|
||||
* Handles the export for the PHP Array class
|
||||
*/
|
||||
@ -80,11 +82,11 @@ class ExportPhparray extends ExportPlugin
|
||||
public function exportHeader(): bool
|
||||
{
|
||||
$this->export->outputHandler(
|
||||
'<?php' . $GLOBALS['crlf']
|
||||
. '/**' . $GLOBALS['crlf']
|
||||
. ' * Export to PHP Array plugin for PHPMyAdmin' . $GLOBALS['crlf']
|
||||
. ' * @version ' . Version::VERSION . $GLOBALS['crlf']
|
||||
. ' */' . $GLOBALS['crlf'] . $GLOBALS['crlf']
|
||||
'<?php' . PHP_EOL
|
||||
. '/**' . PHP_EOL
|
||||
. ' * Export to PHP Array plugin for PHPMyAdmin' . PHP_EOL
|
||||
. ' * @version ' . Version::VERSION . PHP_EOL
|
||||
. ' */' . PHP_EOL . PHP_EOL
|
||||
);
|
||||
|
||||
return true;
|
||||
@ -111,9 +113,9 @@ class ExportPhparray extends ExportPlugin
|
||||
}
|
||||
|
||||
$this->export->outputHandler(
|
||||
'/**' . $GLOBALS['crlf']
|
||||
'/**' . PHP_EOL
|
||||
. ' * Database ' . $this->commentString(Util::backquote($dbAlias))
|
||||
. $GLOBALS['crlf'] . ' */' . $GLOBALS['crlf']
|
||||
. PHP_EOL . ' */' . PHP_EOL
|
||||
);
|
||||
|
||||
return true;
|
||||
@ -146,7 +148,6 @@ class ExportPhparray extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -154,7 +155,6 @@ class ExportPhparray extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -197,9 +197,9 @@ class ExportPhparray extends ExportPlugin
|
||||
$buffer = '';
|
||||
$record_cnt = 0;
|
||||
// Output table name as comment
|
||||
$buffer .= $crlf . '/* '
|
||||
$buffer .= PHP_EOL . '/* '
|
||||
. $this->commentString(Util::backquote($db_alias)) . '.'
|
||||
. $this->commentString(Util::backquote($table_alias)) . ' */' . $crlf;
|
||||
. $this->commentString(Util::backquote($table_alias)) . ' */' . PHP_EOL;
|
||||
$buffer .= '$' . $tablefixed . ' = array(';
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
return false;
|
||||
@ -211,9 +211,9 @@ class ExportPhparray extends ExportPlugin
|
||||
$record_cnt++;
|
||||
|
||||
if ($record_cnt == 1) {
|
||||
$buffer .= $crlf . ' array(';
|
||||
$buffer .= PHP_EOL . ' array(';
|
||||
} else {
|
||||
$buffer .= ',' . $crlf . ' array(';
|
||||
$buffer .= ',' . PHP_EOL . ' array(';
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
@ -231,7 +231,7 @@ class ExportPhparray extends ExportPlugin
|
||||
$buffer = '';
|
||||
}
|
||||
|
||||
$buffer .= $crlf . ');' . $crlf;
|
||||
$buffer .= PHP_EOL . ');' . PHP_EOL;
|
||||
|
||||
return $this->export->outputHandler($buffer);
|
||||
}
|
||||
@ -241,10 +241,9 @@ class ExportPhparray extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the end of line sequence
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
return $this->exportData('', '', $crlf, $errorUrl, $sqlQuery);
|
||||
return $this->exportData('', '', $errorUrl, $sqlQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@ -541,8 +541,6 @@ class ExportSql extends ExportPlugin
|
||||
array $routines,
|
||||
$delimiter
|
||||
) {
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
$text = $this->exportComment()
|
||||
. $this->exportComment($name)
|
||||
. $this->exportComment();
|
||||
@ -554,7 +552,7 @@ class ExportSql extends ExportPlugin
|
||||
if (! empty($GLOBALS['sql_drop_table'])) {
|
||||
$procQuery .= 'DROP ' . $type . ' IF EXISTS '
|
||||
. Util::backquote($routine)
|
||||
. $delimiter . $GLOBALS['crlf'];
|
||||
. $delimiter . "\n";
|
||||
}
|
||||
|
||||
if ($type === 'FUNCTION') {
|
||||
@ -577,7 +575,7 @@ class ExportSql extends ExportPlugin
|
||||
$usedAlias = true;
|
||||
}
|
||||
|
||||
$procQuery .= $createQuery . $delimiter . $GLOBALS['crlf'] . $GLOBALS['crlf'];
|
||||
$procQuery .= $createQuery . $delimiter . "\n\n";
|
||||
}
|
||||
|
||||
if ($usedAlias) {
|
||||
@ -603,8 +601,6 @@ class ExportSql extends ExportPlugin
|
||||
*/
|
||||
public function exportRoutines($db, array $aliases = []): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
$dbAlias = $db;
|
||||
$this->initAlias($aliases, $dbAlias);
|
||||
|
||||
@ -615,8 +611,8 @@ class ExportSql extends ExportPlugin
|
||||
$functionNames = Routines::getFunctionNames($GLOBALS['dbi'], $db);
|
||||
|
||||
if ($procedureNames || $functionNames) {
|
||||
$text .= $GLOBALS['crlf']
|
||||
. 'DELIMITER ' . $delimiter . $GLOBALS['crlf'];
|
||||
$text .= "\n"
|
||||
. 'DELIMITER ' . $delimiter . "\n";
|
||||
|
||||
if ($procedureNames) {
|
||||
$text .= $this->exportRoutineSQL(
|
||||
@ -640,7 +636,7 @@ class ExportSql extends ExportPlugin
|
||||
);
|
||||
}
|
||||
|
||||
$text .= 'DELIMITER ;' . $GLOBALS['crlf'];
|
||||
$text .= 'DELIMITER ;' . "\n";
|
||||
}
|
||||
|
||||
if (! empty($text)) {
|
||||
@ -662,17 +658,17 @@ class ExportSql extends ExportPlugin
|
||||
if (isset($GLOBALS['sql_include_comments']) && $GLOBALS['sql_include_comments']) {
|
||||
// see https://dev.mysql.com/doc/refman/5.0/en/ansi-diff-comments.html
|
||||
if ($text === '') {
|
||||
return '--' . $GLOBALS['crlf'];
|
||||
return '--' . "\n";
|
||||
}
|
||||
|
||||
$lines = preg_split("/\\r\\n|\\r|\\n/", $text);
|
||||
if ($lines === false) {
|
||||
return '--' . $GLOBALS['crlf'];
|
||||
return '--' . "\n";
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($lines as $line) {
|
||||
$result[] = '-- ' . $line . $GLOBALS['crlf'];
|
||||
$result[] = '-- ' . $line . "\n";
|
||||
}
|
||||
|
||||
return implode('', $result);
|
||||
@ -689,7 +685,7 @@ class ExportSql extends ExportPlugin
|
||||
private function possibleCRLF()
|
||||
{
|
||||
if (isset($GLOBALS['sql_include_comments']) && $GLOBALS['sql_include_comments']) {
|
||||
return $GLOBALS['crlf'];
|
||||
return "\n";
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -700,27 +696,25 @@ class ExportSql extends ExportPlugin
|
||||
*/
|
||||
public function exportFooter(): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
$foot = '';
|
||||
|
||||
if (isset($GLOBALS['sql_disable_fk'])) {
|
||||
$foot .= 'SET FOREIGN_KEY_CHECKS=1;' . $GLOBALS['crlf'];
|
||||
$foot .= 'SET FOREIGN_KEY_CHECKS=1;' . "\n";
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['sql_use_transaction'])) {
|
||||
$foot .= 'COMMIT;' . $GLOBALS['crlf'];
|
||||
$foot .= 'COMMIT;' . "\n";
|
||||
}
|
||||
|
||||
// restore connection settings
|
||||
if ($this->sentCharset) {
|
||||
$foot .= $GLOBALS['crlf']
|
||||
$foot .= "\n"
|
||||
. '/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;'
|
||||
. $GLOBALS['crlf']
|
||||
. "\n"
|
||||
. '/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;'
|
||||
. $GLOBALS['crlf']
|
||||
. "\n"
|
||||
. '/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;'
|
||||
. $GLOBALS['crlf'];
|
||||
. "\n";
|
||||
$this->sentCharset = false;
|
||||
}
|
||||
|
||||
@ -738,8 +732,6 @@ class ExportSql extends ExportPlugin
|
||||
*/
|
||||
public function exportHeader(): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
if (isset($GLOBALS['sql_compatibility'])) {
|
||||
$tmpCompat = $GLOBALS['sql_compatibility'];
|
||||
if ($tmpCompat === 'NONE') {
|
||||
@ -783,22 +775,22 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['sql_disable_fk'])) {
|
||||
$head .= 'SET FOREIGN_KEY_CHECKS=0;' . $GLOBALS['crlf'];
|
||||
$head .= 'SET FOREIGN_KEY_CHECKS=0;' . "\n";
|
||||
}
|
||||
|
||||
// We want exported AUTO_INCREMENT columns to have still same value,
|
||||
// do this only for recent MySQL exports
|
||||
if (! isset($GLOBALS['sql_compatibility']) || $GLOBALS['sql_compatibility'] === 'NONE') {
|
||||
$head .= 'SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";' . $GLOBALS['crlf'];
|
||||
$head .= 'SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";' . "\n";
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['sql_use_transaction'])) {
|
||||
$head .= 'START TRANSACTION;' . $GLOBALS['crlf'];
|
||||
$head .= 'START TRANSACTION;' . "\n";
|
||||
}
|
||||
|
||||
/* Change timezone if we should export timestamps in UTC */
|
||||
if (isset($GLOBALS['sql_utc_time']) && $GLOBALS['sql_utc_time']) {
|
||||
$head .= 'SET time_zone = "+00:00";' . $GLOBALS['crlf'];
|
||||
$head .= 'SET time_zone = "+00:00";' . "\n";
|
||||
$GLOBALS['old_tz'] = $GLOBALS['dbi']
|
||||
->fetchValue('SELECT @@session.time_zone');
|
||||
$GLOBALS['dbi']->query('SET time_zone = "+00:00"');
|
||||
@ -822,14 +814,14 @@ class ExportSql extends ExportPlugin
|
||||
$setNames = 'utf8mb4';
|
||||
}
|
||||
|
||||
$head .= $GLOBALS['crlf']
|
||||
$head .= "\n"
|
||||
. '/*!40101 SET @OLD_CHARACTER_SET_CLIENT='
|
||||
. '@@CHARACTER_SET_CLIENT */;' . $GLOBALS['crlf']
|
||||
. '@@CHARACTER_SET_CLIENT */;' . "\n"
|
||||
. '/*!40101 SET @OLD_CHARACTER_SET_RESULTS='
|
||||
. '@@CHARACTER_SET_RESULTS */;' . $GLOBALS['crlf']
|
||||
. '@@CHARACTER_SET_RESULTS */;' . "\n"
|
||||
. '/*!40101 SET @OLD_COLLATION_CONNECTION='
|
||||
. '@@COLLATION_CONNECTION */;' . $GLOBALS['crlf']
|
||||
. '/*!40101 SET NAMES ' . $setNames . ' */;' . $GLOBALS['crlf'] . $GLOBALS['crlf'];
|
||||
. '@@COLLATION_CONNECTION */;' . "\n"
|
||||
. '/*!40101 SET NAMES ' . $setNames . ' */;' . "\n\n";
|
||||
$this->sentCharset = true;
|
||||
}
|
||||
|
||||
@ -845,8 +837,6 @@ class ExportSql extends ExportPlugin
|
||||
*/
|
||||
public function exportDBCreate($db, $exportType, $dbAlias = ''): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
if (empty($dbAlias)) {
|
||||
$dbAlias = $db;
|
||||
}
|
||||
@ -862,7 +852,7 @@ class ExportSql extends ExportPlugin
|
||||
$compat,
|
||||
isset($GLOBALS['sql_backquotes'])
|
||||
)
|
||||
. ';' . $GLOBALS['crlf']
|
||||
. ';' . "\n"
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
@ -888,7 +878,7 @@ class ExportSql extends ExportPlugin
|
||||
$createQuery .= ' DEFAULT CHARACTER SET ' . $collation;
|
||||
}
|
||||
|
||||
$createQuery .= ';' . $GLOBALS['crlf'];
|
||||
$createQuery .= ';' . "\n";
|
||||
if (! $this->export->outputHandler($createQuery)) {
|
||||
return false;
|
||||
}
|
||||
@ -904,8 +894,6 @@ class ExportSql extends ExportPlugin
|
||||
*/
|
||||
private function exportUseStatement($db, $compat): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
if (isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] === 'NONE') {
|
||||
$result = $this->export->outputHandler(
|
||||
'USE '
|
||||
@ -914,10 +902,10 @@ class ExportSql extends ExportPlugin
|
||||
$compat,
|
||||
isset($GLOBALS['sql_backquotes'])
|
||||
)
|
||||
. ';' . $GLOBALS['crlf']
|
||||
. ';' . "\n"
|
||||
);
|
||||
} else {
|
||||
$result = $this->export->outputHandler('USE ' . $db . ';' . $GLOBALS['crlf']);
|
||||
$result = $this->export->outputHandler('USE ' . $db . ';' . "\n");
|
||||
}
|
||||
|
||||
return $result;
|
||||
@ -988,8 +976,6 @@ class ExportSql extends ExportPlugin
|
||||
*/
|
||||
public function exportEvents($db): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
$text = '';
|
||||
$delimiter = '$$';
|
||||
|
||||
@ -1000,8 +986,8 @@ class ExportSql extends ExportPlugin
|
||||
);
|
||||
|
||||
if ($eventNames) {
|
||||
$text .= $GLOBALS['crlf']
|
||||
. 'DELIMITER ' . $delimiter . $GLOBALS['crlf'];
|
||||
$text .= "\n"
|
||||
. 'DELIMITER ' . $delimiter . "\n";
|
||||
|
||||
$text .= $this->exportComment()
|
||||
. $this->exportComment(__('Events'))
|
||||
@ -1011,7 +997,7 @@ class ExportSql extends ExportPlugin
|
||||
if (! empty($GLOBALS['sql_drop_table'])) {
|
||||
$text .= 'DROP EVENT IF EXISTS '
|
||||
. Util::backquote($eventName)
|
||||
. $delimiter . $GLOBALS['crlf'];
|
||||
. $delimiter . "\n";
|
||||
}
|
||||
|
||||
$eventDef = Events::getDefinition($GLOBALS['dbi'], $db, $eventName);
|
||||
@ -1023,10 +1009,10 @@ class ExportSql extends ExportPlugin
|
||||
$eventDef = $statement->build();
|
||||
}
|
||||
|
||||
$text .= $eventDef . $delimiter . $GLOBALS['crlf'] . $GLOBALS['crlf'];
|
||||
$text .= $eventDef . $delimiter . "\n\n";
|
||||
}
|
||||
|
||||
$text .= 'DELIMITER ;' . $GLOBALS['crlf'];
|
||||
$text .= 'DELIMITER ;' . "\n";
|
||||
}
|
||||
|
||||
if (! empty($text)) {
|
||||
@ -1171,7 +1157,6 @@ class ExportSql extends ExportPlugin
|
||||
! $this->exportData(
|
||||
$relationParameters->pdfFeature->database->getName(),
|
||||
$relationParameters->pdfFeature->pdfPages->getName(),
|
||||
$GLOBALS['crlf'],
|
||||
'',
|
||||
$sqlQueryRow,
|
||||
$aliases
|
||||
@ -1180,9 +1165,9 @@ class ExportSql extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
$lastPage = $GLOBALS['crlf']
|
||||
$lastPage = "\n"
|
||||
. 'SET @LAST_PAGE = LAST_INSERT_ID();'
|
||||
. $GLOBALS['crlf'];
|
||||
. "\n";
|
||||
if (! $this->export->outputHandler($lastPage)) {
|
||||
return false;
|
||||
}
|
||||
@ -1198,7 +1183,6 @@ class ExportSql extends ExportPlugin
|
||||
! $this->exportData(
|
||||
$relationParameters->pdfFeature->database->getName(),
|
||||
$relationParameters->pdfFeature->tableCoords->getName(),
|
||||
$GLOBALS['crlf'],
|
||||
'',
|
||||
$sqlQueryCoords,
|
||||
$aliases
|
||||
@ -1242,7 +1226,6 @@ class ExportSql extends ExportPlugin
|
||||
! $this->exportData(
|
||||
(string) $relationParameters->db,
|
||||
(string) $relationParams[$type],
|
||||
$GLOBALS['crlf'],
|
||||
'',
|
||||
$sqlQuery,
|
||||
$aliases
|
||||
@ -1260,12 +1243,11 @@ class ExportSql extends ExportPlugin
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $view the view name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
*
|
||||
* @return string resulting definition
|
||||
*/
|
||||
public function getTableDefStandIn($db, $view, $crlf, $aliases = [])
|
||||
public function getTableDefStandIn($db, $view, $aliases = [])
|
||||
{
|
||||
$dbAlias = $db;
|
||||
$viewAlias = $view;
|
||||
@ -1274,7 +1256,7 @@ class ExportSql extends ExportPlugin
|
||||
if (! empty($GLOBALS['sql_drop_table'])) {
|
||||
$createQuery .= 'DROP VIEW IF EXISTS '
|
||||
. Util::backquote($viewAlias)
|
||||
. ';' . $crlf;
|
||||
. ';' . "\n";
|
||||
}
|
||||
|
||||
$createQuery .= 'CREATE TABLE ';
|
||||
@ -1283,7 +1265,7 @@ class ExportSql extends ExportPlugin
|
||||
$createQuery .= 'IF NOT EXISTS ';
|
||||
}
|
||||
|
||||
$createQuery .= Util::backquote($viewAlias) . ' (' . $crlf;
|
||||
$createQuery .= Util::backquote($viewAlias) . ' (' . "\n";
|
||||
$tmp = [];
|
||||
$columns = $GLOBALS['dbi']->getColumnsFull($db, $view);
|
||||
foreach ($columns as $columnName => $definition) {
|
||||
@ -1293,10 +1275,10 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
|
||||
$tmp[] = Util::backquote($colAlias) . ' ' .
|
||||
$definition['Type'] . $crlf;
|
||||
$definition['Type'] . "\n";
|
||||
}
|
||||
|
||||
return $createQuery . implode(',', $tmp) . ');' . $crlf;
|
||||
return $createQuery . implode(',', $tmp) . ');' . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1304,7 +1286,6 @@ class ExportSql extends ExportPlugin
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $view the view name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
*
|
||||
* @return string resulting schema
|
||||
@ -1312,7 +1293,6 @@ class ExportSql extends ExportPlugin
|
||||
private function getTableDefForView(
|
||||
$db,
|
||||
$view,
|
||||
$crlf,
|
||||
array $aliases = []
|
||||
) {
|
||||
$dbAlias = $db;
|
||||
@ -1323,7 +1303,7 @@ class ExportSql extends ExportPlugin
|
||||
$createQuery .= ' IF NOT EXISTS ';
|
||||
}
|
||||
|
||||
$createQuery .= Util::backquote($viewAlias) . '(' . $crlf;
|
||||
$createQuery .= Util::backquote($viewAlias) . '(' . "\n";
|
||||
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $view, true);
|
||||
|
||||
@ -1337,7 +1317,7 @@ class ExportSql extends ExportPlugin
|
||||
$extractedColumnspec = Util::extractColumnSpec($column['Type']);
|
||||
|
||||
if (! $firstCol) {
|
||||
$createQuery .= ',' . $crlf;
|
||||
$createQuery .= ',' . "\n";
|
||||
}
|
||||
|
||||
$createQuery .= ' ' . Util::backquote($colAlias);
|
||||
@ -1367,7 +1347,7 @@ class ExportSql extends ExportPlugin
|
||||
$firstCol = false;
|
||||
}
|
||||
|
||||
$createQuery .= $crlf . ');' . $crlf;
|
||||
$createQuery .= "\n" . ');' . "\n";
|
||||
|
||||
$compat = $GLOBALS['sql_compatibility'] ?? 'NONE';
|
||||
|
||||
@ -1383,7 +1363,6 @@ class ExportSql extends ExportPlugin
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $table the table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case
|
||||
* of error
|
||||
* @param bool $showDates whether to include creation/
|
||||
@ -1400,7 +1379,6 @@ class ExportSql extends ExportPlugin
|
||||
public function getTableDef(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$showDates = false,
|
||||
$addSemicolon = true,
|
||||
@ -1422,7 +1400,7 @@ class ExportSql extends ExportPlugin
|
||||
$this->initAlias($aliases, $dbAlias, $tableAlias);
|
||||
|
||||
$schemaCreate = '';
|
||||
$newCrlf = $crlf;
|
||||
$newCrlf = "\n";
|
||||
|
||||
$compat = $GLOBALS['sql_compatibility'] ?? 'NONE';
|
||||
|
||||
@ -1441,7 +1419,7 @@ class ExportSql extends ExportPlugin
|
||||
strtotime($tmpres['Create_time'])
|
||||
)
|
||||
);
|
||||
$newCrlf = $this->exportComment() . $crlf;
|
||||
$newCrlf = $this->exportComment() . "\n";
|
||||
}
|
||||
|
||||
if ($showDates && isset($tmpres['Update_time']) && ! empty($tmpres['Update_time'])) {
|
||||
@ -1451,7 +1429,7 @@ class ExportSql extends ExportPlugin
|
||||
strtotime($tmpres['Update_time'])
|
||||
)
|
||||
);
|
||||
$newCrlf = $this->exportComment() . $crlf;
|
||||
$newCrlf = $this->exportComment() . "\n";
|
||||
}
|
||||
|
||||
if ($showDates && isset($tmpres['Check_time']) && ! empty($tmpres['Check_time'])) {
|
||||
@ -1461,7 +1439,7 @@ class ExportSql extends ExportPlugin
|
||||
strtotime($tmpres['Check_time'])
|
||||
)
|
||||
);
|
||||
$newCrlf = $this->exportComment() . $crlf;
|
||||
$newCrlf = $this->exportComment() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1471,14 +1449,14 @@ class ExportSql extends ExportPlugin
|
||||
if (! empty($GLOBALS['sql_drop_table']) && $GLOBALS['dbi']->getTable($db, $table)->isView()) {
|
||||
$schemaCreate .= 'DROP VIEW IF EXISTS '
|
||||
. Util::backquoteCompat($tableAlias, 'NONE', $GLOBALS['sql_backquotes']) . ';'
|
||||
. $crlf;
|
||||
. "\n";
|
||||
}
|
||||
|
||||
// no need to generate a DROP VIEW here, it was done earlier
|
||||
if (! empty($GLOBALS['sql_drop_table']) && ! $GLOBALS['dbi']->getTable($db, $table)->isView()) {
|
||||
$schemaCreate .= 'DROP TABLE IF EXISTS '
|
||||
. Util::backquoteCompat($tableAlias, 'NONE', $GLOBALS['sql_backquotes']) . ';'
|
||||
. $crlf;
|
||||
. "\n";
|
||||
}
|
||||
|
||||
// Complete table dump,
|
||||
@ -1533,11 +1511,11 @@ class ExportSql extends ExportPlugin
|
||||
// Convert end of line chars to one that we want (note that MySQL
|
||||
// doesn't return query it will accept in all cases)
|
||||
if (mb_strpos($createQuery, "(\r\n ")) {
|
||||
$createQuery = str_replace("\r\n", $crlf, $createQuery);
|
||||
$createQuery = str_replace("\r\n", "\n", $createQuery);
|
||||
} elseif (mb_strpos($createQuery, "(\n ")) {
|
||||
$createQuery = str_replace("\n", $crlf, $createQuery);
|
||||
$createQuery = str_replace("\n", "\n", $createQuery);
|
||||
} elseif (mb_strpos($createQuery, "(\r ")) {
|
||||
$createQuery = str_replace("\r", $crlf, $createQuery);
|
||||
$createQuery = str_replace("\r", "\n", $createQuery);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1748,16 +1726,15 @@ class ExportSql extends ExportPlugin
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
$alterFooter = ';' . $crlf;
|
||||
$alterFooter = ';' . "\n";
|
||||
|
||||
// Generating constraints-related query.
|
||||
if (! empty($constraints)) {
|
||||
$GLOBALS['sql_constraints_query'] = $alterHeader . $crlf . ' ADD '
|
||||
. implode(',' . $crlf . ' ADD ', $constraints)
|
||||
$GLOBALS['sql_constraints_query'] = $alterHeader . "\n" . ' ADD '
|
||||
. implode(',' . "\n" . ' ADD ', $constraints)
|
||||
. $alterFooter;
|
||||
|
||||
$GLOBALS['sql_constraints'] = $this->generateComment(
|
||||
$crlf,
|
||||
$GLOBALS['sql_constraints'],
|
||||
__('Constraints for dumped tables'),
|
||||
__('Constraints for table'),
|
||||
@ -1770,8 +1747,8 @@ class ExportSql extends ExportPlugin
|
||||
$GLOBALS['sql_indexes_query'] = '';
|
||||
|
||||
if (! empty($indexes)) {
|
||||
$GLOBALS['sql_indexes_query'] .= $alterHeader . $crlf . ' ADD '
|
||||
. implode(',' . $crlf . ' ADD ', $indexes)
|
||||
$GLOBALS['sql_indexes_query'] .= $alterHeader . "\n" . ' ADD '
|
||||
. implode(',' . "\n" . ' ADD ', $indexes)
|
||||
. $alterFooter;
|
||||
}
|
||||
|
||||
@ -1785,7 +1762,6 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
if (! empty($indexes) || ! empty($indexesFulltext)) {
|
||||
$GLOBALS['sql_indexes'] = $this->generateComment(
|
||||
$crlf,
|
||||
$GLOBALS['sql_indexes'],
|
||||
__('Indexes for dumped tables'),
|
||||
__('Indexes for table'),
|
||||
@ -1796,15 +1772,15 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
// Generating drop foreign keys-related query.
|
||||
if (! empty($dropped)) {
|
||||
$GLOBALS['sql_drop_foreign_keys'] = $alterHeader . $crlf . ' DROP '
|
||||
. implode(',' . $crlf . ' DROP ', $dropped)
|
||||
$GLOBALS['sql_drop_foreign_keys'] = $alterHeader . "\n" . ' DROP '
|
||||
. implode(',' . "\n" . ' DROP ', $dropped)
|
||||
. $alterFooter;
|
||||
}
|
||||
|
||||
// Generating auto-increment-related query.
|
||||
if ($autoIncrement !== [] && $updateIndexesIncrements) {
|
||||
$sqlAutoIncrementsQuery = $alterHeader . $crlf . ' MODIFY '
|
||||
. implode(',' . $crlf . ' MODIFY ', $autoIncrement);
|
||||
$sqlAutoIncrementsQuery = $alterHeader . "\n" . ' MODIFY '
|
||||
. implode(',' . "\n" . ' MODIFY ', $autoIncrement);
|
||||
if (
|
||||
isset($GLOBALS['sql_auto_increment'])
|
||||
&& ($statement->entityOptions->has('AUTO_INCREMENT') !== false)
|
||||
@ -1819,10 +1795,9 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
}
|
||||
|
||||
$sqlAutoIncrementsQuery .= ';' . $crlf;
|
||||
$sqlAutoIncrementsQuery .= ';' . "\n";
|
||||
|
||||
$GLOBALS['sql_auto_increments'] = $this->generateComment(
|
||||
$crlf,
|
||||
$GLOBALS['sql_auto_increments'],
|
||||
__('AUTO_INCREMENT for dumped tables'),
|
||||
__('AUTO_INCREMENT for table'),
|
||||
@ -1851,7 +1826,7 @@ class ExportSql extends ExportPlugin
|
||||
// Restoring old mode.
|
||||
Context::$MODE = $oldMode;
|
||||
|
||||
return $warning . $schemaCreate . ($addSemicolon ? ';' . $crlf : '');
|
||||
return $warning . $schemaCreate . ($addSemicolon ? ';' . "\n" : '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2003,9 +1978,8 @@ class ExportSql extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the seperator for a file
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
return $this->export->outputHandler($sqlQuery);
|
||||
}
|
||||
@ -2015,7 +1989,6 @@ class ExportSql extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $exportMode 'create_table','triggers','create_view',
|
||||
* 'stand_in'
|
||||
@ -2034,7 +2007,6 @@ class ExportSql extends ExportPlugin
|
||||
public function exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$exportMode,
|
||||
$exportType,
|
||||
@ -2061,7 +2033,7 @@ class ExportSql extends ExportPlugin
|
||||
__('Table structure for table') . ' ' . $formattedTableName
|
||||
);
|
||||
$dump .= $this->exportComment();
|
||||
$dump .= $this->getTableDef($db, $table, $crlf, $errorUrl, $dates, true, false, true, $aliases);
|
||||
$dump .= $this->getTableDef($db, $table, $errorUrl, $dates, true, false, true, $aliases);
|
||||
$dump .= $this->getTableComments($db, $table, $relation, $mime, $aliases);
|
||||
break;
|
||||
case 'triggers':
|
||||
@ -2079,16 +2051,16 @@ class ExportSql extends ExportPlugin
|
||||
$triggerQuery = '';
|
||||
foreach ($triggers as $trigger) {
|
||||
if (! empty($GLOBALS['sql_drop_table'])) {
|
||||
$triggerQuery .= $trigger['drop'] . ';' . $crlf;
|
||||
$triggerQuery .= $trigger['drop'] . ';' . "\n";
|
||||
}
|
||||
|
||||
$triggerQuery .= 'DELIMITER ' . $delimiter . $crlf;
|
||||
$triggerQuery .= 'DELIMITER ' . $delimiter . "\n";
|
||||
$triggerQuery .= $this->replaceWithAliases($trigger['create'], $aliases, $db, $table, $flag);
|
||||
if ($flag) {
|
||||
$usedAlias = true;
|
||||
}
|
||||
|
||||
$triggerQuery .= 'DELIMITER ;' . $crlf;
|
||||
$triggerQuery .= 'DELIMITER ;' . "\n";
|
||||
}
|
||||
|
||||
// One warning per table.
|
||||
@ -2117,10 +2089,10 @@ class ExportSql extends ExportPlugin
|
||||
// delete the stand-in table previously created (if any)
|
||||
if ($exportType !== 'table') {
|
||||
$dump .= 'DROP TABLE IF EXISTS '
|
||||
. Util::backquote($tableAlias) . ';' . $crlf;
|
||||
. Util::backquote($tableAlias) . ';' . "\n";
|
||||
}
|
||||
|
||||
$dump .= $this->getTableDef($db, $table, $crlf, $errorUrl, $dates, true, true, true, $aliases);
|
||||
$dump .= $this->getTableDef($db, $table, $errorUrl, $dates, true, true, true, $aliases);
|
||||
} else {
|
||||
$dump .= $this->exportComment(
|
||||
sprintf(
|
||||
@ -2132,10 +2104,10 @@ class ExportSql extends ExportPlugin
|
||||
// delete the stand-in table previously created (if any)
|
||||
if ($exportType !== 'table') {
|
||||
$dump .= 'DROP TABLE IF EXISTS '
|
||||
. Util::backquote($tableAlias) . ';' . $crlf;
|
||||
. Util::backquote($tableAlias) . ';' . "\n";
|
||||
}
|
||||
|
||||
$dump .= $this->getTableDefForView($db, $table, $crlf, $aliases);
|
||||
$dump .= $this->getTableDefForView($db, $table, $aliases);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -2148,7 +2120,7 @@ class ExportSql extends ExportPlugin
|
||||
)
|
||||
. $this->exportComment();
|
||||
// export a stand-in definition to resolve view dependencies
|
||||
$dump .= $this->getTableDefStandIn($db, $table, $crlf, $aliases);
|
||||
$dump .= $this->getTableDefStandIn($db, $table, $aliases);
|
||||
}
|
||||
|
||||
// this one is built by getTableDef() to use in table copy/move
|
||||
@ -2163,7 +2135,6 @@ class ExportSql extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -2171,7 +2142,6 @@ class ExportSql extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -2283,7 +2253,7 @@ class ExportSql extends ExportPlugin
|
||||
. $formattedTableName
|
||||
)
|
||||
. $this->exportComment()
|
||||
. $crlf;
|
||||
. "\n";
|
||||
$this->export->outputHandler($truncatehead);
|
||||
$this->export->outputHandler($truncate);
|
||||
}
|
||||
@ -2312,7 +2282,7 @@ class ExportSql extends ExportPlugin
|
||||
|| $GLOBALS['sql_type'] !== 'UPDATE')
|
||||
) {
|
||||
$separator = ',';
|
||||
$schemaInsert .= $crlf;
|
||||
$schemaInsert .= "\n";
|
||||
} else {
|
||||
$separator = ';';
|
||||
}
|
||||
@ -2326,7 +2296,7 @@ class ExportSql extends ExportPlugin
|
||||
. $formattedTableName
|
||||
)
|
||||
. $this->exportComment()
|
||||
. $crlf;
|
||||
. "\n";
|
||||
if (! $this->export->outputHandler($head)) {
|
||||
return false;
|
||||
}
|
||||
@ -2346,7 +2316,7 @@ class ExportSql extends ExportPlugin
|
||||
$compat,
|
||||
$GLOBALS['sql_backquotes']
|
||||
)
|
||||
. ' ON ;' . $crlf
|
||||
. ' ON ;' . "\n"
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
@ -2438,7 +2408,7 @@ class ExportSql extends ExportPlugin
|
||||
$insertLineSize = mb_strlen($insertLine);
|
||||
$sqlMaxSize = $GLOBALS['sql_max_query_size'];
|
||||
if ($sqlMaxSize > 0 && $querySize + $insertLineSize > $sqlMaxSize) {
|
||||
if (! $this->export->outputHandler(';' . $crlf)) {
|
||||
if (! $this->export->outputHandler(';' . "\n")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2454,13 +2424,13 @@ class ExportSql extends ExportPlugin
|
||||
$insertLine = $schemaInsert . '(' . implode(', ', $values) . ')';
|
||||
}
|
||||
|
||||
if (! $this->export->outputHandler(($current_row === 1 ? '' : $separator . $crlf) . $insertLine)) {
|
||||
if (! $this->export->outputHandler(($current_row === 1 ? '' : $separator . "\n") . $insertLine)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($current_row > 0) {
|
||||
if (! $this->export->outputHandler(';' . $crlf)) {
|
||||
if (! $this->export->outputHandler(';' . "\n")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2472,13 +2442,13 @@ class ExportSql extends ExportPlugin
|
||||
&& $current_row > 0
|
||||
) {
|
||||
$outputSucceeded = $this->export->outputHandler(
|
||||
$crlf . 'SET IDENTITY_INSERT '
|
||||
"\n" . 'SET IDENTITY_INSERT '
|
||||
. Util::backquoteCompat(
|
||||
$tableAlias,
|
||||
$compat,
|
||||
$GLOBALS['sql_backquotes']
|
||||
)
|
||||
. ' OFF;' . $crlf
|
||||
. ' OFF;' . "\n"
|
||||
);
|
||||
if (! $outputSucceeded) {
|
||||
return false;
|
||||
@ -2778,7 +2748,6 @@ class ExportSql extends ExportPlugin
|
||||
/**
|
||||
* Generate comment
|
||||
*
|
||||
* @param string $crlf Carriage return character
|
||||
* @param string|null $sqlStatement SQL statement
|
||||
* @param string $comment1 Comment for dumped table
|
||||
* @param string $comment2 Comment for current table
|
||||
@ -2788,7 +2757,6 @@ class ExportSql extends ExportPlugin
|
||||
* @return string
|
||||
*/
|
||||
protected function generateComment(
|
||||
$crlf,
|
||||
?string $sqlStatement,
|
||||
$comment1,
|
||||
$comment2,
|
||||
@ -2799,7 +2767,7 @@ class ExportSql extends ExportPlugin
|
||||
if (isset($GLOBALS['no_constraints_comments'])) {
|
||||
$sqlStatement = '';
|
||||
} else {
|
||||
$sqlStatement = $crlf
|
||||
$sqlStatement = "\n"
|
||||
. $this->exportComment()
|
||||
. $this->exportComment($comment1)
|
||||
. $this->exportComment();
|
||||
@ -2808,7 +2776,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
// comments for current table
|
||||
if (! isset($GLOBALS['no_constraints_comments'])) {
|
||||
$sqlStatement .= $crlf
|
||||
$sqlStatement .= "\n"
|
||||
. $this->exportComment()
|
||||
. $this->exportComment(
|
||||
$comment2 . ' ' . Util::backquoteCompat(
|
||||
|
||||
@ -153,7 +153,6 @@ class ExportTexytext extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -161,7 +160,6 @@ class ExportTexytext extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -241,11 +239,10 @@ class ExportTexytext extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the end of line sequence
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
return $this->exportData('', '', $crlf, $errorUrl, $sqlQuery);
|
||||
return $this->exportData('', '', $errorUrl, $sqlQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,12 +250,11 @@ class ExportTexytext extends ExportPlugin
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $view the view name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
*
|
||||
* @return string resulting definition
|
||||
*/
|
||||
public function getTableDefStandIn($db, $view, $crlf, $aliases = [])
|
||||
public function getTableDefStandIn($db, $view, $aliases = [])
|
||||
{
|
||||
$text_output = '';
|
||||
|
||||
@ -310,7 +306,6 @@ class ExportTexytext extends ExportPlugin
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $table the table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $error_url the url to go back in case of error
|
||||
* @param bool $do_relation whether to include relation comments
|
||||
* @param bool $do_comments whether to include the pmadb-style column
|
||||
@ -331,7 +326,6 @@ class ExportTexytext extends ExportPlugin
|
||||
public function getTableDef(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$error_url,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
@ -477,7 +471,6 @@ class ExportTexytext extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $exportMode 'create_table', 'triggers', 'create_view',
|
||||
* 'stand_in'
|
||||
@ -496,7 +489,6 @@ class ExportTexytext extends ExportPlugin
|
||||
public function exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$exportMode,
|
||||
$exportType,
|
||||
@ -518,7 +510,6 @@ class ExportTexytext extends ExportPlugin
|
||||
$dump .= $this->getTableDef(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
@ -543,7 +534,6 @@ class ExportTexytext extends ExportPlugin
|
||||
$dump .= $this->getTableDef(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$do_relation,
|
||||
$do_comments,
|
||||
@ -558,7 +548,7 @@ class ExportTexytext extends ExportPlugin
|
||||
$dump .= '== ' . __('Stand-in structure for view')
|
||||
. ' ' . $table . "\n\n";
|
||||
// export a stand-in definition to resolve view dependencies
|
||||
$dump .= $this->getTableDefStandIn($db, $table, $crlf, $aliases);
|
||||
$dump .= $this->getTableDefStandIn($db, $table, $aliases);
|
||||
}
|
||||
|
||||
return $this->export->outputHandler($dump);
|
||||
|
||||
@ -26,6 +26,7 @@ use function rtrim;
|
||||
use function str_replace;
|
||||
use function strlen;
|
||||
|
||||
use const PHP_EOL;
|
||||
use const PHP_VERSION;
|
||||
|
||||
/**
|
||||
@ -161,12 +162,10 @@ class ExportXml extends ExportPlugin
|
||||
*/
|
||||
private function exportDefinitions(string $db, string $type, array $names): string
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
$head = '';
|
||||
|
||||
foreach ($names as $name) {
|
||||
$head .= ' <pma:' . $type . ' name="' . htmlspecialchars($name) . '">' . $GLOBALS['crlf'];
|
||||
$head .= ' <pma:' . $type . ' name="' . htmlspecialchars($name) . '">' . PHP_EOL;
|
||||
|
||||
if ($type === 'function') {
|
||||
$definition = Routines::getFunctionDefinition($GLOBALS['dbi'], $db, $name);
|
||||
@ -180,8 +179,8 @@ class ExportXml extends ExportPlugin
|
||||
$sql = htmlspecialchars(rtrim((string) $definition));
|
||||
$sql = str_replace("\n", "\n ", $sql);
|
||||
|
||||
$head .= ' ' . $sql . $GLOBALS['crlf'];
|
||||
$head .= ' </pma:' . $type . '>' . $GLOBALS['crlf'];
|
||||
$head .= ' ' . $sql . PHP_EOL;
|
||||
$head .= ' </pma:' . $type . '>' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $head;
|
||||
@ -195,7 +194,6 @@ class ExportXml extends ExportPlugin
|
||||
{
|
||||
$this->initSpecificVariables();
|
||||
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
$table = $this->getTable();
|
||||
$tables = $this->getTables();
|
||||
|
||||
@ -212,29 +210,29 @@ class ExportXml extends ExportPlugin
|
||||
$charset = 'utf-8';
|
||||
}
|
||||
|
||||
$head = '<?xml version="1.0" encoding="' . $charset . '"?>' . $GLOBALS['crlf']
|
||||
. '<!--' . $GLOBALS['crlf']
|
||||
. '- phpMyAdmin XML Dump' . $GLOBALS['crlf']
|
||||
. '- version ' . Version::VERSION . $GLOBALS['crlf']
|
||||
. '- https://www.phpmyadmin.net' . $GLOBALS['crlf']
|
||||
. '-' . $GLOBALS['crlf']
|
||||
$head = '<?xml version="1.0" encoding="' . $charset . '"?>' . PHP_EOL
|
||||
. '<!--' . PHP_EOL
|
||||
. '- phpMyAdmin XML Dump' . PHP_EOL
|
||||
. '- version ' . Version::VERSION . PHP_EOL
|
||||
. '- https://www.phpmyadmin.net' . PHP_EOL
|
||||
. '-' . PHP_EOL
|
||||
. '- ' . __('Host:') . ' ' . htmlspecialchars($GLOBALS['cfg']['Server']['host']);
|
||||
if (! empty($GLOBALS['cfg']['Server']['port'])) {
|
||||
$head .= ':' . $GLOBALS['cfg']['Server']['port'];
|
||||
}
|
||||
|
||||
$head .= $GLOBALS['crlf']
|
||||
$head .= PHP_EOL
|
||||
. '- ' . __('Generation Time:') . ' '
|
||||
. Util::localisedDate() . $GLOBALS['crlf']
|
||||
. '- ' . __('Server version:') . ' ' . $GLOBALS['dbi']->getVersionString() . $GLOBALS['crlf']
|
||||
. '- ' . __('PHP Version:') . ' ' . PHP_VERSION . $GLOBALS['crlf']
|
||||
. '-->' . $GLOBALS['crlf'] . $GLOBALS['crlf'];
|
||||
. Util::localisedDate() . PHP_EOL
|
||||
. '- ' . __('Server version:') . ' ' . $GLOBALS['dbi']->getVersionString() . PHP_EOL
|
||||
. '- ' . __('PHP Version:') . ' ' . PHP_VERSION . PHP_EOL
|
||||
. '-->' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$head .= '<pma_xml_export version="1.0"'
|
||||
. ($export_struct
|
||||
? ' xmlns:pma="https://www.phpmyadmin.net/some_doc_url/"'
|
||||
: '')
|
||||
. '>' . $GLOBALS['crlf'];
|
||||
. '>' . PHP_EOL;
|
||||
|
||||
if ($export_struct) {
|
||||
$result = $GLOBALS['dbi']->fetchResult(
|
||||
@ -245,13 +243,13 @@ class ExportXml extends ExportPlugin
|
||||
$db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
|
||||
$db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];
|
||||
|
||||
$head .= ' <!--' . $GLOBALS['crlf'];
|
||||
$head .= ' - Structure schemas' . $GLOBALS['crlf'];
|
||||
$head .= ' -->' . $GLOBALS['crlf'];
|
||||
$head .= ' <pma:structure_schemas>' . $GLOBALS['crlf'];
|
||||
$head .= ' <!--' . PHP_EOL;
|
||||
$head .= ' - Structure schemas' . PHP_EOL;
|
||||
$head .= ' -->' . PHP_EOL;
|
||||
$head .= ' <pma:structure_schemas>' . PHP_EOL;
|
||||
$head .= ' <pma:database name="' . htmlspecialchars($GLOBALS['db'])
|
||||
. '" collation="' . htmlspecialchars($db_collation) . '" charset="' . htmlspecialchars($db_charset)
|
||||
. '">' . $GLOBALS['crlf'];
|
||||
. '">' . PHP_EOL;
|
||||
|
||||
if (count($tables) === 0) {
|
||||
$tables[] = $table;
|
||||
@ -284,13 +282,13 @@ class ExportXml extends ExportPlugin
|
||||
}
|
||||
|
||||
$head .= ' <pma:' . $type . ' name="' . htmlspecialchars($table) . '">'
|
||||
. $GLOBALS['crlf'];
|
||||
. PHP_EOL;
|
||||
|
||||
$tbl = ' ' . htmlspecialchars($tbl);
|
||||
$tbl = str_replace("\n", "\n ", $tbl);
|
||||
|
||||
$head .= $tbl . ';' . $GLOBALS['crlf'];
|
||||
$head .= ' </pma:' . $type . '>' . $GLOBALS['crlf'];
|
||||
$head .= $tbl . ';' . PHP_EOL;
|
||||
$head .= ' </pma:' . $type . '>' . PHP_EOL;
|
||||
|
||||
if (! isset($GLOBALS['xml_export_triggers']) || ! $GLOBALS['xml_export_triggers']) {
|
||||
continue;
|
||||
@ -305,15 +303,15 @@ class ExportXml extends ExportPlugin
|
||||
foreach ($triggers as $trigger) {
|
||||
$code = $trigger['create'];
|
||||
$head .= ' <pma:trigger name="'
|
||||
. htmlspecialchars($trigger['name']) . '">' . $GLOBALS['crlf'];
|
||||
. htmlspecialchars($trigger['name']) . '">' . PHP_EOL;
|
||||
|
||||
// Do some formatting
|
||||
$code = mb_substr(rtrim($code), 0, -3);
|
||||
$code = ' ' . htmlspecialchars($code);
|
||||
$code = str_replace("\n", "\n ", $code);
|
||||
|
||||
$head .= $code . $GLOBALS['crlf'];
|
||||
$head .= ' </pma:trigger>' . $GLOBALS['crlf'];
|
||||
$head .= $code . PHP_EOL;
|
||||
$head .= ' </pma:trigger>' . PHP_EOL;
|
||||
}
|
||||
|
||||
unset($trigger, $triggers);
|
||||
@ -347,11 +345,11 @@ class ExportXml extends ExportPlugin
|
||||
|
||||
unset($result);
|
||||
|
||||
$head .= ' </pma:database>' . $GLOBALS['crlf'];
|
||||
$head .= ' </pma:structure_schemas>' . $GLOBALS['crlf'];
|
||||
$head .= ' </pma:database>' . PHP_EOL;
|
||||
$head .= ' </pma:structure_schemas>' . PHP_EOL;
|
||||
|
||||
if ($export_data) {
|
||||
$head .= $GLOBALS['crlf'];
|
||||
$head .= PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,18 +374,16 @@ class ExportXml extends ExportPlugin
|
||||
*/
|
||||
public function exportDBHeader($db, $dbAlias = ''): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
if (empty($dbAlias)) {
|
||||
$dbAlias = $db;
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
|
||||
$head = ' <!--' . $GLOBALS['crlf']
|
||||
$head = ' <!--' . PHP_EOL
|
||||
. ' - ' . __('Database:') . ' \''
|
||||
. htmlspecialchars($dbAlias) . '\'' . $GLOBALS['crlf']
|
||||
. ' -->' . $GLOBALS['crlf'] . ' <database name="'
|
||||
. htmlspecialchars($dbAlias) . '">' . $GLOBALS['crlf'];
|
||||
. htmlspecialchars($dbAlias) . '\'' . PHP_EOL
|
||||
. ' -->' . PHP_EOL . ' <database name="'
|
||||
. htmlspecialchars($dbAlias) . '">' . PHP_EOL;
|
||||
|
||||
return $this->export->outputHandler($head);
|
||||
}
|
||||
@ -402,10 +398,8 @@ class ExportXml extends ExportPlugin
|
||||
*/
|
||||
public function exportDBFooter($db): bool
|
||||
{
|
||||
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
|
||||
|
||||
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
|
||||
return $this->export->outputHandler(' </database>' . $GLOBALS['crlf']);
|
||||
return $this->export->outputHandler(' </database>' . PHP_EOL);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -428,7 +422,6 @@ class ExportXml extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -436,7 +429,6 @@ class ExportXml extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -460,14 +452,14 @@ class ExportXml extends ExportPlugin
|
||||
$columns = $result->getFieldNames();
|
||||
|
||||
$buffer = ' <!-- ' . __('Table') . ' '
|
||||
. htmlspecialchars($table_alias) . ' -->' . $crlf;
|
||||
. htmlspecialchars($table_alias) . ' -->' . PHP_EOL;
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($record = $result->fetchRow()) {
|
||||
$buffer = ' <table name="'
|
||||
. htmlspecialchars($table_alias) . '">' . $crlf;
|
||||
. htmlspecialchars($table_alias) . '">' . PHP_EOL;
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
$col_as = $columns[$i];
|
||||
if (! empty($aliases[$db]['tables'][$table]['columns'][$col_as])) {
|
||||
@ -483,10 +475,10 @@ class ExportXml extends ExportPlugin
|
||||
$buffer .= ' <column name="'
|
||||
. htmlspecialchars($col_as) . '">'
|
||||
. htmlspecialchars((string) $record[$i])
|
||||
. '</column>' . $crlf;
|
||||
. '</column>' . PHP_EOL;
|
||||
}
|
||||
|
||||
$buffer .= ' </table>' . $crlf;
|
||||
$buffer .= ' </table>' . PHP_EOL;
|
||||
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
return false;
|
||||
|
||||
@ -20,6 +20,8 @@ use function array_key_exists;
|
||||
use function is_numeric;
|
||||
use function str_replace;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
/**
|
||||
* Handles the export for the YAML format
|
||||
*/
|
||||
@ -66,7 +68,7 @@ class ExportYaml extends ExportPlugin
|
||||
*/
|
||||
public function exportHeader(): bool
|
||||
{
|
||||
$this->export->outputHandler('%YAML 1.1' . $GLOBALS['crlf'] . '---' . $GLOBALS['crlf']);
|
||||
$this->export->outputHandler('%YAML 1.1' . PHP_EOL . '---' . PHP_EOL);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -76,7 +78,7 @@ class ExportYaml extends ExportPlugin
|
||||
*/
|
||||
public function exportFooter(): bool
|
||||
{
|
||||
$this->export->outputHandler('...' . $GLOBALS['crlf']);
|
||||
$this->export->outputHandler('...' . PHP_EOL);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -119,7 +121,6 @@ class ExportYaml extends ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -127,7 +128,6 @@ class ExportYaml extends ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -160,10 +160,10 @@ class ExportYaml extends ExportPlugin
|
||||
|
||||
// Output table name as comment if this is the first record of the table
|
||||
if ($record_cnt == 1) {
|
||||
$buffer = '# ' . $db_alias . '.' . $table_alias . $crlf;
|
||||
$buffer .= '-' . $crlf;
|
||||
$buffer = '# ' . $db_alias . '.' . $table_alias . PHP_EOL;
|
||||
$buffer .= '-' . PHP_EOL;
|
||||
} else {
|
||||
$buffer = '-' . $crlf;
|
||||
$buffer = '-' . PHP_EOL;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
@ -172,13 +172,13 @@ class ExportYaml extends ExportPlugin
|
||||
}
|
||||
|
||||
if ($record[$i] === null) {
|
||||
$buffer .= ' ' . $columns[$i] . ': null' . $crlf;
|
||||
$buffer .= ' ' . $columns[$i] . ': null' . PHP_EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
$isNotString = isset($fieldsMeta[$i]) && $fieldsMeta[$i]->isNotType(FieldMetadata::TYPE_STRING);
|
||||
if (is_numeric($record[$i]) && $isNotString) {
|
||||
$buffer .= ' ' . $columns[$i] . ': ' . $record[$i] . $crlf;
|
||||
$buffer .= ' ' . $columns[$i] . ': ' . $record[$i] . PHP_EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ class ExportYaml extends ExportPlugin
|
||||
],
|
||||
$record[$i]
|
||||
);
|
||||
$buffer .= ' ' . $columns[$i] . ': "' . $record[$i] . '"' . $crlf;
|
||||
$buffer .= ' ' . $columns[$i] . ': "' . $record[$i] . '"' . PHP_EOL;
|
||||
}
|
||||
|
||||
if (! $this->export->outputHandler($buffer)) {
|
||||
@ -213,10 +213,9 @@ class ExportYaml extends ExportPlugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the end of line sequence
|
||||
*/
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf): bool
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
return $this->exportData('', '', $crlf, $errorUrl, $sqlQuery);
|
||||
return $this->exportData('', '', $errorUrl, $sqlQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +178,6 @@ class Export[Name] extends PhpMyAdmin\Plugins\ExportPlugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -188,7 +187,6 @@ class Export[Name] extends PhpMyAdmin\Plugins\ExportPlugin
|
||||
public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
|
||||
@ -90,7 +90,6 @@ abstract class ExportPlugin implements Plugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery SQL query for obtaining data
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
@ -98,7 +97,6 @@ abstract class ExportPlugin implements Plugin
|
||||
abstract public function exportData(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$sqlQuery,
|
||||
array $aliases = []
|
||||
@ -135,13 +133,9 @@ abstract class ExportPlugin implements Plugin
|
||||
*
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $sqlQuery the rawquery to output
|
||||
* @param string $crlf the seperator for a file
|
||||
*/
|
||||
public function exportRawQuery(
|
||||
string $errorUrl,
|
||||
string $sqlQuery,
|
||||
string $crlf
|
||||
): bool {
|
||||
public function exportRawQuery(string $errorUrl, string $sqlQuery): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -150,7 +144,6 @@ abstract class ExportPlugin implements Plugin
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param string $errorUrl the url to go back in case of error
|
||||
* @param string $exportMode 'create_table','triggers','create_view',
|
||||
* 'stand_in'
|
||||
@ -168,7 +161,6 @@ abstract class ExportPlugin implements Plugin
|
||||
public function exportStructure(
|
||||
$db,
|
||||
$table,
|
||||
$crlf,
|
||||
$errorUrl,
|
||||
$exportMode,
|
||||
$exportType,
|
||||
@ -201,12 +193,11 @@ abstract class ExportPlugin implements Plugin
|
||||
*
|
||||
* @param string $db the database name
|
||||
* @param string $view the view name
|
||||
* @param string $crlf the end of line sequence
|
||||
* @param array $aliases Aliases of db/table/columns
|
||||
*
|
||||
* @return string resulting definition
|
||||
*/
|
||||
public function getTableDefStandIn($db, $view, $crlf, $aliases = [])
|
||||
public function getTableDefStandIn($db, $view, $aliases = [])
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -36,24 +36,22 @@ class ConfigGenerator
|
||||
*/
|
||||
public static function getConfigFile(ConfigFile $cf)
|
||||
{
|
||||
$crlf = isset($_SESSION['eol']) && $_SESSION['eol'] === 'win'
|
||||
? "\r\n"
|
||||
: "\n";
|
||||
$eol = isset($_SESSION['eol']) && $_SESSION['eol'] === 'win' ? "\r\n" : "\n";
|
||||
$conf = $cf->getConfig();
|
||||
|
||||
// header
|
||||
$ret = '<?php' . $crlf
|
||||
. '/**' . $crlf
|
||||
. ' * Generated configuration file' . $crlf
|
||||
$ret = '<?php' . $eol
|
||||
. '/**' . $eol
|
||||
. ' * Generated configuration file' . $eol
|
||||
. ' * Generated by: phpMyAdmin '
|
||||
. Version::VERSION
|
||||
. ' setup script' . $crlf
|
||||
. ' * Date: ' . gmdate(DATE_RFC1123) . $crlf
|
||||
. ' */' . $crlf . $crlf;
|
||||
. ' setup script' . $eol
|
||||
. ' * Date: ' . gmdate(DATE_RFC1123) . $eol
|
||||
. ' */' . $eol . $eol;
|
||||
|
||||
//servers
|
||||
if (! empty($conf['Servers'])) {
|
||||
$ret .= self::getServerPart($cf, $crlf, $conf['Servers']);
|
||||
$ret .= self::getServerPart($cf, $eol, $conf['Servers']);
|
||||
unset($conf['Servers']);
|
||||
}
|
||||
|
||||
@ -62,7 +60,7 @@ class ConfigGenerator
|
||||
|
||||
foreach ($conf as $k => $v) {
|
||||
$k = preg_replace('/[^A-Za-z0-9_]/', '_', (string) $k);
|
||||
$ret .= self::getVarExport($k, $v, $crlf);
|
||||
$ret .= self::getVarExport($k, $v, $eol);
|
||||
if (! isset($persistKeys[$k])) {
|
||||
continue;
|
||||
}
|
||||
@ -77,10 +75,10 @@ class ConfigGenerator
|
||||
}
|
||||
|
||||
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
|
||||
$ret .= self::getVarExport($k, $cf->getDefault($k), $crlf);
|
||||
$ret .= self::getVarExport($k, $cf->getDefault($k), $eol);
|
||||
}
|
||||
|
||||
return $ret . $crlf;
|
||||
return $ret . $eol;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,21 +86,21 @@ class ConfigGenerator
|
||||
*
|
||||
* @param string $var_name configuration name
|
||||
* @param mixed $var_value configuration value(s)
|
||||
* @param string $crlf line ending
|
||||
* @param string $eol line ending
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getVarExport($var_name, $var_value, $crlf)
|
||||
private static function getVarExport($var_name, $var_value, string $eol)
|
||||
{
|
||||
if (! is_array($var_value) || empty($var_value)) {
|
||||
return "\$cfg['" . $var_name . "'] = "
|
||||
. var_export($var_value, true) . ';' . $crlf;
|
||||
. var_export($var_value, true) . ';' . $eol;
|
||||
}
|
||||
|
||||
if (self::isZeroBasedArray($var_value)) {
|
||||
return "\$cfg['" . $var_name . "'] = "
|
||||
. self::exportZeroBasedArray($var_value, $crlf)
|
||||
. ';' . $crlf;
|
||||
. self::exportZeroBasedArray($var_value, $eol)
|
||||
. ';' . $eol;
|
||||
}
|
||||
|
||||
$ret = '';
|
||||
@ -110,7 +108,7 @@ class ConfigGenerator
|
||||
foreach ($var_value as $k => $v) {
|
||||
$k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
|
||||
$ret .= "\$cfg['" . $var_name . "']['" . $k . "'] = "
|
||||
. var_export($v, true) . ';' . $crlf;
|
||||
. var_export($v, true) . ';' . $eol;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@ -136,11 +134,11 @@ class ConfigGenerator
|
||||
* Exports continuous 0-based array
|
||||
*
|
||||
* @param array $array Array to export
|
||||
* @param string $crlf Newline string
|
||||
* @param string $eol Newline string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function exportZeroBasedArray(array $array, $crlf)
|
||||
private static function exportZeroBasedArray(array $array, string $eol)
|
||||
{
|
||||
$retv = [];
|
||||
foreach ($array as $v) {
|
||||
@ -156,7 +154,7 @@ class ConfigGenerator
|
||||
// more than 4 values - value per line
|
||||
$imax = count($retv);
|
||||
for ($i = 0; $i < $imax; $i++) {
|
||||
$ret .= ($i > 0 ? ',' : '') . $crlf . ' ' . $retv[$i];
|
||||
$ret .= ($i > 0 ? ',' : '') . $eol . ' ' . $retv[$i];
|
||||
}
|
||||
|
||||
return $ret . ']';
|
||||
@ -166,36 +164,36 @@ class ConfigGenerator
|
||||
* Generate server part of config file
|
||||
*
|
||||
* @param ConfigFile $cf Config file
|
||||
* @param string $crlf Carriage return char
|
||||
* @param string $eol Carriage return char
|
||||
* @param array $servers Servers list
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected static function getServerPart(ConfigFile $cf, $crlf, array $servers)
|
||||
protected static function getServerPart(ConfigFile $cf, string $eol, array $servers)
|
||||
{
|
||||
if ($cf->getServerCount() === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ret = '/* Servers configuration */' . $crlf . '$i = 0;' . $crlf . $crlf;
|
||||
$ret = '/* Servers configuration */' . $eol . '$i = 0;' . $eol . $eol;
|
||||
foreach ($servers as $id => $server) {
|
||||
$ret .= '/* Server: '
|
||||
. strtr($cf->getServerName($id) . ' [' . $id . '] ', '*/', '-')
|
||||
. '*/' . $crlf
|
||||
. '$i++;' . $crlf;
|
||||
. '*/' . $eol
|
||||
. '$i++;' . $eol;
|
||||
foreach ($server as $k => $v) {
|
||||
$k = preg_replace('/[^A-Za-z0-9_]/', '_', (string) $k);
|
||||
$ret .= "\$cfg['Servers'][\$i]['" . $k . "'] = "
|
||||
. (is_array($v) && self::isZeroBasedArray($v)
|
||||
? self::exportZeroBasedArray($v, $crlf)
|
||||
? self::exportZeroBasedArray($v, $eol)
|
||||
: var_export($v, true))
|
||||
. ';' . $crlf;
|
||||
. ';' . $eol;
|
||||
}
|
||||
|
||||
$ret .= $crlf;
|
||||
$ret .= $eol;
|
||||
}
|
||||
|
||||
$ret .= '/* End of servers configuration */' . $crlf . $crlf;
|
||||
$ret .= '/* End of servers configuration */' . $eol . $eol;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ class Tracker
|
||||
}
|
||||
|
||||
$createSql .= self::getLogComment() .
|
||||
$exportSqlPlugin->getTableDef($dbName, $tableName, "\n", '');
|
||||
$exportSqlPlugin->getTableDef($dbName, $tableName, '');
|
||||
|
||||
// Save version
|
||||
$trackingFeature = $relation->getRelationParameters()->trackingFeature;
|
||||
|
||||
@ -9283,12 +9283,6 @@
|
||||
<code>$col_as</code>
|
||||
<code>$columns[$i]</code>
|
||||
</MixedAssignment>
|
||||
<PossiblyNullOperand occurrences="4">
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
</PossiblyNullOperand>
|
||||
</file>
|
||||
<file src="libraries/classes/Plugins/Export/ExportLatex.php">
|
||||
<MixedArgument occurrences="4">
|
||||
@ -9336,18 +9330,7 @@
|
||||
<code>$GLOBALS['plugin_param']['export_type']</code>
|
||||
<code>$GLOBALS['plugin_param']['single_table']</code>
|
||||
</PossiblyNullArrayAccess>
|
||||
<PossiblyNullOperand occurrences="13">
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<PossiblyNullOperand occurrences="2">
|
||||
<code>$table_alias</code>
|
||||
<code>$table_alias</code>
|
||||
</PossiblyNullOperand>
|
||||
@ -9682,39 +9665,7 @@
|
||||
<code>$GLOBALS['plugin_param']['export_type']</code>
|
||||
<code>$GLOBALS['plugin_param']['single_table']</code>
|
||||
</PossiblyNullArrayAccess>
|
||||
<PossiblyNullOperand occurrences="33">
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<PossiblyNullOperand occurrences="1">
|
||||
<code>$eventDef</code>
|
||||
</PossiblyNullOperand>
|
||||
<PropertyTypeCoercion occurrences="1">
|
||||
@ -9841,43 +9792,6 @@
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$table_alias</code>
|
||||
</PossiblyNullArgument>
|
||||
<PossiblyNullOperand occurrences="35">
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
<code>$GLOBALS['crlf']</code>
|
||||
</PossiblyNullOperand>
|
||||
<PropertyNotSetInConstructor occurrences="1">
|
||||
<code>$table</code>
|
||||
</PropertyNotSetInConstructor>
|
||||
@ -12620,7 +12534,7 @@
|
||||
<code>$v</code>
|
||||
</MixedAssignment>
|
||||
<PossiblyNullOperand occurrences="1">
|
||||
<code>self::getServerPart($cf, $crlf, $conf['Servers'])</code>
|
||||
<code>self::getServerPart($cf, $eol, $conf['Servers'])</code>
|
||||
</PossiblyNullOperand>
|
||||
</file>
|
||||
<file src="libraries/classes/Setup/Index.php">
|
||||
|
||||
@ -230,7 +230,6 @@
|
||||
config: PhpMyAdmin\Config,
|
||||
ConfigFile: PhpMyAdmin\Config\ConfigFile,
|
||||
containerBuilder: Symfony\Component\DependencyInjection\ContainerBuilder,
|
||||
crlf: string,
|
||||
csv_columns: bool,
|
||||
csv_enclosed: string,
|
||||
csv_escaped: string,
|
||||
|
||||
@ -161,7 +161,6 @@ class ExportTest extends AbstractTestCase
|
||||
['test_table'],
|
||||
['test_table'],
|
||||
new ExportSql(new Relation($dbi), $export, new Transformations()),
|
||||
"\n",
|
||||
'index.php?route=/database/export&db=test_db',
|
||||
'database',
|
||||
false,
|
||||
@ -238,7 +237,6 @@ SQL;
|
||||
['test_db'],
|
||||
'structure_and_data',
|
||||
new ExportSql(new Relation($dbi), $export, new Transformations()),
|
||||
"\n",
|
||||
'index.php?route=/server/export',
|
||||
'server',
|
||||
false,
|
||||
@ -250,7 +248,9 @@ SQL;
|
||||
);
|
||||
|
||||
$expected = <<<SQL
|
||||
CREATE DATABASE IF NOT EXISTS test_db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;USE test_db;
|
||||
CREATE DATABASE IF NOT EXISTS test_db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
USE test_db;
|
||||
|
||||
INSERT INTO test_table (id, name, datetimefield) VALUES
|
||||
('1', 'abcd', '2011-01-20 02:00:02'),
|
||||
('2', 'foo', '2010-01-20 02:00:02'),
|
||||
|
||||
@ -195,7 +195,7 @@ class ExportCodegenTest extends AbstractTestCase
|
||||
$GLOBALS['save_on_server'] = false;
|
||||
|
||||
ob_start();
|
||||
$this->object->exportData('test_db', 'test_table', "\n", 'localhost', 'SELECT * FROM `test_db`.`test_table`;');
|
||||
$this->object->exportData('test_db', 'test_table', 'localhost', 'SELECT * FROM `test_db`.`test_table`;');
|
||||
$result = ob_get_clean();
|
||||
|
||||
$this->assertIsString($result);
|
||||
@ -220,7 +220,7 @@ class ExportCodegenTest extends AbstractTestCase
|
||||
|
||||
$GLOBALS['codegen_format'] = 4;
|
||||
|
||||
$this->object->exportData('test_db', 'test_table', "\n", 'localhost', 'SELECT * FROM `test_db`.`test_table`;');
|
||||
$this->object->exportData('test_db', 'test_table', 'localhost', 'SELECT * FROM `test_db`.`test_table`;');
|
||||
|
||||
$this->expectOutputString('4 is not supported.');
|
||||
}
|
||||
@ -247,7 +247,7 @@ class ExportCodegenTest extends AbstractTestCase
|
||||
{
|
||||
$method = new ReflectionMethod(ExportCodegen::class, 'handleNHibernateCSBody');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->object, 'test_db', 'test_table', "\n");
|
||||
$result = $method->invoke($this->object, 'test_db', 'test_table');
|
||||
|
||||
$this->assertEquals(
|
||||
'using System;' . "\n" .
|
||||
@ -300,7 +300,7 @@ class ExportCodegenTest extends AbstractTestCase
|
||||
{
|
||||
$method = new ReflectionMethod(ExportCodegen::class, 'handleNHibernateXMLBody');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->object, 'test_db', 'test_table', "\n");
|
||||
$result = $method->invoke($this->object, 'test_db', 'test_table');
|
||||
|
||||
$this->assertEquals(
|
||||
'<?xml version="1.0" encoding="utf-8" ?>' . "\n" .
|
||||
|
||||
@ -299,7 +299,6 @@ class ExportCsvTest extends AbstractTestCase
|
||||
// case 5
|
||||
|
||||
$GLOBALS['what'] = 'notExcel';
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
$GLOBALS['csv_terminated'] = '';
|
||||
$GLOBALS['csv_separator'] = 'a\\t';
|
||||
|
||||
@ -379,7 +378,6 @@ class ExportCsvTest extends AbstractTestCase
|
||||
$this->assertFalse($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
));
|
||||
@ -400,7 +398,6 @@ class ExportCsvTest extends AbstractTestCase
|
||||
$this->assertTrue($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
));
|
||||
@ -419,7 +416,6 @@ class ExportCsvTest extends AbstractTestCase
|
||||
$this->assertTrue($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
));
|
||||
@ -441,7 +437,6 @@ class ExportCsvTest extends AbstractTestCase
|
||||
$this->assertTrue($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
));
|
||||
@ -462,7 +457,6 @@ class ExportCsvTest extends AbstractTestCase
|
||||
$this->assertTrue($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
));
|
||||
@ -483,7 +477,6 @@ class ExportCsvTest extends AbstractTestCase
|
||||
$this->assertTrue($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
));
|
||||
|
||||
@ -305,7 +305,6 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
$this->assertTrue($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
));
|
||||
@ -376,7 +375,7 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
'<td class="print"><strong>Null</strong></td>' .
|
||||
'<td class="print"><strong>Default</strong></td></tr>' .
|
||||
'1</tr></table>',
|
||||
$this->object->getTableDefStandIn('database', 'view', "\n")
|
||||
$this->object->getTableDefStandIn('database', 'view')
|
||||
);
|
||||
}
|
||||
|
||||
@ -642,7 +641,6 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'create_table',
|
||||
'test'
|
||||
@ -670,7 +668,6 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'triggers',
|
||||
'test'
|
||||
@ -694,7 +691,6 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'create_view',
|
||||
'test'
|
||||
@ -722,7 +718,6 @@ class ExportHtmlwordTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'stand_in',
|
||||
'test'
|
||||
|
||||
@ -19,6 +19,8 @@ use ReflectionProperty;
|
||||
|
||||
use function array_shift;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
/**
|
||||
* @covers \PhpMyAdmin\Plugins\Export\ExportJson
|
||||
* @group medium
|
||||
@ -122,8 +124,6 @@ class ExportJsonTest extends AbstractTestCase
|
||||
|
||||
public function testExportHeader(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
$this->expectOutputString(
|
||||
"[\n"
|
||||
. '{"type":"header","version":"' . Version::VERSION
|
||||
@ -138,9 +138,7 @@ class ExportJsonTest extends AbstractTestCase
|
||||
|
||||
public function testExportFooter(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = '';
|
||||
|
||||
$this->expectOutputString(']');
|
||||
$this->expectOutputString(']' . PHP_EOL);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->object->exportFooter()
|
||||
@ -149,8 +147,6 @@ class ExportJsonTest extends AbstractTestCase
|
||||
|
||||
public function testExportDBHeader(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
$this->expectOutputString('{"type":"database","name":"testDB"},' . "\n");
|
||||
|
||||
$this->assertTrue(
|
||||
@ -187,7 +183,6 @@ class ExportJsonTest extends AbstractTestCase
|
||||
$this->assertTrue($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
));
|
||||
@ -211,7 +206,6 @@ class ExportJsonTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'test_db',
|
||||
'test_table_complex',
|
||||
"\n",
|
||||
'example.com',
|
||||
'SELECT * FROM `test_db`.`test_table_complex`;'
|
||||
)
|
||||
@ -234,8 +228,7 @@ class ExportJsonTest extends AbstractTestCase
|
||||
$this->assertTrue(
|
||||
$this->object->exportRawQuery(
|
||||
'example.com',
|
||||
'SELECT * FROM `test_db`.`test_table_complex`;',
|
||||
"\n"
|
||||
'SELECT * FROM `test_db`.`test_table_complex`;'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -419,7 +419,6 @@ class ExportLatexTest extends AbstractTestCase
|
||||
|
||||
public function testExportHeader(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
$GLOBALS['cfg']['Server']['port'] = 80;
|
||||
$GLOBALS['cfg']['Server']['host'] = 'localhost';
|
||||
|
||||
@ -443,8 +442,6 @@ class ExportLatexTest extends AbstractTestCase
|
||||
|
||||
public function testExportDBHeader(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
$this->expectOutputString("% \n% Database: 'testDB'\n% \n");
|
||||
|
||||
$this->assertTrue(
|
||||
@ -481,7 +478,6 @@ class ExportLatexTest extends AbstractTestCase
|
||||
$this->assertTrue($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
));
|
||||
@ -513,7 +509,6 @@ class ExportLatexTest extends AbstractTestCase
|
||||
$this->assertTrue($this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
));
|
||||
@ -627,7 +622,6 @@ class ExportLatexTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'database',
|
||||
'',
|
||||
"\n",
|
||||
'example.com',
|
||||
'test',
|
||||
'test',
|
||||
@ -729,7 +723,6 @@ class ExportLatexTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'database',
|
||||
'',
|
||||
"\n",
|
||||
'example.com',
|
||||
'test',
|
||||
'test',
|
||||
@ -788,7 +781,6 @@ class ExportLatexTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'database',
|
||||
'',
|
||||
"\n",
|
||||
'example.com',
|
||||
'test',
|
||||
'test'
|
||||
@ -807,7 +799,6 @@ class ExportLatexTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'database',
|
||||
'',
|
||||
"\n",
|
||||
'example.com',
|
||||
'triggers',
|
||||
'test'
|
||||
|
||||
@ -263,7 +263,6 @@ class ExportMediawikiTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'db',
|
||||
'table',
|
||||
"\n",
|
||||
'example.com',
|
||||
'create_table',
|
||||
'test'
|
||||
@ -313,7 +312,6 @@ class ExportMediawikiTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
)
|
||||
|
||||
@ -283,7 +283,6 @@ class ExportOdsTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'db',
|
||||
'table',
|
||||
"\n",
|
||||
'example.com',
|
||||
'SELECT'
|
||||
)
|
||||
@ -357,7 +356,6 @@ class ExportOdsTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'db',
|
||||
'table',
|
||||
"\n",
|
||||
'example.com',
|
||||
'SELECT'
|
||||
)
|
||||
@ -410,7 +408,6 @@ class ExportOdsTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'db',
|
||||
'table',
|
||||
"\n",
|
||||
'example.com',
|
||||
'SELECT'
|
||||
)
|
||||
|
||||
@ -407,7 +407,6 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'db',
|
||||
'ta<ble',
|
||||
"\n",
|
||||
'example.com',
|
||||
'SELECT'
|
||||
)
|
||||
@ -474,7 +473,6 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'db',
|
||||
'table',
|
||||
"\n",
|
||||
'example.com',
|
||||
'SELECT'
|
||||
)
|
||||
@ -529,7 +527,6 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'db',
|
||||
'table',
|
||||
"\n",
|
||||
'example.com',
|
||||
'SELECT'
|
||||
)
|
||||
@ -549,7 +546,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
{
|
||||
$this->dummyDbi->addSelectDb('test_db');
|
||||
$this->assertSame(
|
||||
$this->object->getTableDefStandIn('test_db', 'test_table', "\n"),
|
||||
$this->object->getTableDefStandIn('test_db', 'test_table'),
|
||||
''
|
||||
);
|
||||
$this->dummyDbi->assertAllSelectsConsumed();
|
||||
@ -649,7 +646,6 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->object->getTableDef(
|
||||
'database',
|
||||
'',
|
||||
"\n",
|
||||
'example.com',
|
||||
true,
|
||||
true,
|
||||
@ -742,7 +738,6 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->object->getTableDef(
|
||||
'database',
|
||||
'',
|
||||
"\n",
|
||||
'example.com',
|
||||
true,
|
||||
true,
|
||||
@ -805,7 +800,6 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'create_table',
|
||||
'test'
|
||||
@ -847,7 +841,6 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'triggers',
|
||||
'test'
|
||||
@ -879,7 +872,6 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'create_view',
|
||||
'test'
|
||||
@ -921,7 +913,6 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'stand_in',
|
||||
'test'
|
||||
|
||||
@ -239,7 +239,6 @@ class ExportPdfTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'db',
|
||||
'table',
|
||||
"\n",
|
||||
'phpmyadmin.net/err',
|
||||
'SELECT'
|
||||
)
|
||||
|
||||
@ -20,6 +20,8 @@ use function array_shift;
|
||||
use function ob_get_clean;
|
||||
use function ob_start;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
/**
|
||||
* @covers \PhpMyAdmin\Plugins\Export\ExportPhparray
|
||||
* @group medium
|
||||
@ -123,8 +125,6 @@ class ExportPhparrayTest extends AbstractTestCase
|
||||
|
||||
public function testExportHeader(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = ' ';
|
||||
|
||||
ob_start();
|
||||
$this->assertTrue(
|
||||
$this->object->exportHeader()
|
||||
@ -133,7 +133,7 @@ class ExportPhparrayTest extends AbstractTestCase
|
||||
|
||||
$this->assertIsString($result);
|
||||
|
||||
$this->assertStringContainsString('<?php ', $result);
|
||||
$this->assertStringContainsString('<?php' . PHP_EOL, $result);
|
||||
}
|
||||
|
||||
public function testExportFooter(): void
|
||||
@ -145,8 +145,6 @@ class ExportPhparrayTest extends AbstractTestCase
|
||||
|
||||
public function testExportDBHeader(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
ob_start();
|
||||
$this->assertTrue(
|
||||
$this->object->exportDBHeader('db')
|
||||
@ -179,7 +177,6 @@ class ExportPhparrayTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'phpmyadmin.net/err',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
)
|
||||
@ -202,7 +199,6 @@ class ExportPhparrayTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'test_db',
|
||||
'0`932table',
|
||||
"\n",
|
||||
'phpmyadmin.net/err',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
)
|
||||
|
||||
@ -288,15 +288,14 @@ class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
public function testExportRoutines(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = '##';
|
||||
$GLOBALS['sql_drop_table'] = true;
|
||||
|
||||
$this->expectOutputString(
|
||||
'##DELIMITER $$##DROP PROCEDURE IF EXISTS `test_proc1`$$##CREATE PROCEDURE'
|
||||
. ' `test_proc1` (`p` INT) BEGIN END$$####DROP PROCEDURE IF EXISTS'
|
||||
. ' `test_proc2`$$##CREATE PROCEDURE `test_proc2` (`p` INT) BEGIN END$$####DROP'
|
||||
. ' FUNCTION IF EXISTS `test_func`$$##CREATE FUNCTION'
|
||||
. ' `test_func` (`p` INT) RETURNS INT(11) BEGIN END$$####DELIMITER ;##'
|
||||
"\n" . 'DELIMITER $$' . "\n" . 'DROP PROCEDURE IF EXISTS `test_proc1`$$' . "\n" . 'CREATE PROCEDURE'
|
||||
. ' `test_proc1` (`p` INT) BEGIN END$$' . "\n\n" . 'DROP PROCEDURE IF EXISTS'
|
||||
. ' `test_proc2`$$' . "\n" . 'CREATE PROCEDURE `test_proc2` (`p` INT) BEGIN END$$' . "\n\n" . 'DROP'
|
||||
. ' FUNCTION IF EXISTS `test_func`$$' . "\n" . 'CREATE FUNCTION'
|
||||
. ' `test_func` (`p` INT) RETURNS INT(11) BEGIN END$$' . "\n\n" . 'DELIMITER ;' . "\n"
|
||||
);
|
||||
|
||||
$this->object->exportRoutines('test_db');
|
||||
@ -307,16 +306,15 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$method = new ReflectionMethod(ExportSql::class, 'exportComment');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$GLOBALS['crlf'] = '##';
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
|
||||
$this->assertEquals(
|
||||
'--##',
|
||||
'--' . "\n",
|
||||
$method->invoke($this->object, '')
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'-- Comment##',
|
||||
'-- Comment' . "\n",
|
||||
$method->invoke($this->object, 'Comment')
|
||||
);
|
||||
|
||||
@ -340,16 +338,15 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$method = new ReflectionMethod(ExportSql::class, 'possibleCRLF');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$GLOBALS['crlf'] = '##';
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
|
||||
$this->assertEquals(
|
||||
'##',
|
||||
"\n",
|
||||
$method->invoke($this->object, '')
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'##',
|
||||
"\n",
|
||||
$method->invoke($this->object, 'Comment')
|
||||
);
|
||||
|
||||
@ -370,7 +367,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
public function testExportFooter(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = '';
|
||||
$GLOBALS['sql_disable_fk'] = true;
|
||||
$GLOBALS['sql_use_transaction'] = true;
|
||||
$GLOBALS['charset'] = 'utf-8';
|
||||
@ -389,7 +385,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$this->expectOutputString('SET FOREIGN_KEY_CHECKS=1;COMMIT;');
|
||||
$this->expectOutputString('SET FOREIGN_KEY_CHECKS=1;' . "\n" . 'COMMIT;' . "\n");
|
||||
|
||||
$this->assertTrue(
|
||||
$this->object->exportFooter()
|
||||
@ -398,7 +394,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
public function testExportHeader(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
$GLOBALS['sql_compatibility'] = 'NONE';
|
||||
$GLOBALS['cfg']['Server']['host'] = 'localhost';
|
||||
$GLOBALS['cfg']['Server']['port'] = 80;
|
||||
@ -465,7 +460,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['sql_create_database'] = true;
|
||||
$GLOBALS['sql_create_table'] = true;
|
||||
$GLOBALS['sql_create_view'] = true;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
@ -538,7 +532,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['sql_compatibility'] = 'MSSQL';
|
||||
$GLOBALS['sql_backquotes'] = true;
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
ob_start();
|
||||
$this->assertTrue(
|
||||
@ -567,7 +560,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
public function testExportEvents(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
$GLOBALS['sql_structure_or_data'] = 'structure';
|
||||
$GLOBALS['sql_procedure_function'] = true;
|
||||
|
||||
@ -610,7 +602,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
public function testExportDBFooter(): void
|
||||
{
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
$GLOBALS['sql_constraints'] = 'SqlConstraints';
|
||||
$GLOBALS['sql_structure_or_data'] = 'structure';
|
||||
$GLOBALS['sql_procedure_function'] = true;
|
||||
@ -654,11 +645,14 @@ class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$result = $this->object->getTableDefStandIn('db', 'view', '');
|
||||
$result = $this->object->getTableDefStandIn('db', 'view');
|
||||
|
||||
$this->assertStringContainsString('DROP VIEW IF EXISTS `view`;', $result);
|
||||
|
||||
$this->assertStringContainsString('CREATE TABLE IF NOT EXISTS `view` (`cname` int);', $result);
|
||||
$this->assertStringContainsString(
|
||||
'CREATE TABLE IF NOT EXISTS `view` (' . "\n" . '`cname` int' . "\n" . ');' . "\n",
|
||||
$result
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetTableDefForView(): void
|
||||
@ -695,7 +689,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
|
||||
$method = new ReflectionMethod(ExportSql::class, 'getTableDefForView');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->object, 'db', 'view', "\n");
|
||||
$result = $method->invoke($this->object, 'db', 'view');
|
||||
|
||||
$this->assertEquals(
|
||||
"CREATE TABLE `view`(\n" .
|
||||
@ -731,7 +725,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
);
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$result = $method->invoke($this->object, 'db', 'view', "\n");
|
||||
$result = $method->invoke($this->object, 'db', 'view');
|
||||
|
||||
$this->assertEquals(
|
||||
"CREATE TABLE IF NOT EXISTS `view`(\n" .
|
||||
@ -752,7 +746,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['sql_backquotes'] = true;
|
||||
$GLOBALS['sql_if_not_exists'] = true;
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
if (isset($GLOBALS['sql_constraints'])) {
|
||||
unset($GLOBALS['sql_constraints']);
|
||||
}
|
||||
@ -838,7 +831,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
|
||||
$result = $this->object->getTableDef('db', 'table', "\n", 'example.com/err', true, true, false);
|
||||
$result = $this->object->getTableDef('db', 'table', 'example.com/err', true, true, false);
|
||||
|
||||
$this->assertStringContainsString('-- Creation: Jan 01, 2000 at 10:00 AM', $result);
|
||||
|
||||
@ -875,7 +868,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['sql_backquotes'] = false;
|
||||
$GLOBALS['sql_if_not_exists'] = true;
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
if (isset($GLOBALS['sql_constraints'])) {
|
||||
unset($GLOBALS['sql_constraints']);
|
||||
@ -940,7 +932,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
|
||||
$result = $this->object->getTableDef('db', 'table', "\n", 'example.com/err', true, true, false);
|
||||
$result = $this->object->getTableDef('db', 'table', 'example.com/err', true, true, false);
|
||||
|
||||
$this->assertStringContainsString('-- Error reading structure for table db.table: error occurred', $result);
|
||||
}
|
||||
@ -957,7 +949,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
'column_info' => 'col',
|
||||
])->toArray();
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
@ -1014,7 +1005,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['sql_compatibility'] = 'MSSQL';
|
||||
$GLOBALS['sql_backquotes'] = true;
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
// case 1
|
||||
ob_start();
|
||||
@ -1022,7 +1012,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'create_table',
|
||||
'test'
|
||||
@ -1046,7 +1035,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'triggers',
|
||||
'test'
|
||||
@ -1073,7 +1061,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'create_view',
|
||||
'test'
|
||||
@ -1095,7 +1082,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'create_view',
|
||||
'test'
|
||||
@ -1114,7 +1100,6 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'stand_in',
|
||||
'test'
|
||||
@ -1224,7 +1209,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
|
||||
ob_start();
|
||||
$this->object->exportData('db', 'table', "\n", 'example.com/err', 'SELECT a FROM b WHERE 1');
|
||||
$this->object->exportData('db', 'table', 'example.com/err', 'SELECT a FROM b WHERE 1');
|
||||
$result = ob_get_clean();
|
||||
|
||||
$this->assertIsString($result);
|
||||
@ -1326,7 +1311,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
|
||||
ob_start();
|
||||
$this->object->exportData('db', 'table', "\n", 'example.com/err', 'SELECT a FROM b WHERE 1');
|
||||
$this->object->exportData('db', 'table', 'example.com/err', 'SELECT a FROM b WHERE 1');
|
||||
$result = ob_get_clean();
|
||||
|
||||
$this->assertIsString($result);
|
||||
@ -1364,14 +1349,13 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
$GLOBALS['sql_views_as_tables'] = false;
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
$oldVal = $GLOBALS['sql_compatibility'] ?? '';
|
||||
$GLOBALS['sql_compatibility'] = 'NONE';
|
||||
$GLOBALS['sql_backquotes'] = true;
|
||||
|
||||
ob_start();
|
||||
$this->assertTrue(
|
||||
$this->object->exportData('db', 'tbl', "\n", 'err.com', 'SELECT')
|
||||
$this->object->exportData('db', 'tbl', 'err.com', 'SELECT')
|
||||
);
|
||||
$result = ob_get_clean();
|
||||
|
||||
@ -1415,11 +1399,10 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
$GLOBALS['sql_views_as_tables'] = true;
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
|
||||
ob_start();
|
||||
$this->assertTrue(
|
||||
$this->object->exportData('db', 'table', "\n", 'err.com', 'SELECT')
|
||||
$this->object->exportData('db', 'table', 'err.com', 'SELECT')
|
||||
);
|
||||
$result = ob_get_clean();
|
||||
|
||||
|
||||
@ -214,7 +214,6 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
)
|
||||
@ -237,7 +236,7 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
public function testGetTableDefStandIn(): void
|
||||
{
|
||||
$this->dummyDbi->addSelectDb('test_db');
|
||||
$result = $this->object->getTableDefStandIn('test_db', 'test_table', "\n");
|
||||
$result = $this->object->getTableDefStandIn('test_db', 'test_table');
|
||||
$this->dummyDbi->assertAllSelectsConsumed();
|
||||
|
||||
$this->assertEquals(
|
||||
@ -334,7 +333,7 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
'column_info' => 'col',
|
||||
])->toArray();
|
||||
|
||||
$result = $this->object->getTableDef('db', 'table', "\n", 'example.com', true, true, true);
|
||||
$result = $this->object->getTableDef('db', 'table', 'example.com', true, true, true);
|
||||
|
||||
$this->assertStringContainsString('1|<ftable (ffield>)|comm|Test<', $result);
|
||||
}
|
||||
@ -382,7 +381,6 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'create_table',
|
||||
'test'
|
||||
@ -409,7 +407,6 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'triggers',
|
||||
'test'
|
||||
@ -433,7 +430,6 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'create_view',
|
||||
'test'
|
||||
@ -460,7 +456,6 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
$this->object->exportStructure(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'stand_in',
|
||||
'test'
|
||||
|
||||
@ -49,7 +49,6 @@ class ExportXmlTest extends AbstractTestCase
|
||||
$GLOBALS['plugin_param']['single_table'] = false;
|
||||
$GLOBALS['db'] = 'db';
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = true;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
$this->object = new ExportXml(
|
||||
new Relation($GLOBALS['dbi']),
|
||||
new Export($GLOBALS['dbi']),
|
||||
@ -185,7 +184,6 @@ class ExportXmlTest extends AbstractTestCase
|
||||
$GLOBALS['xml_export_triggers'] = 1;
|
||||
$GLOBALS['xml_export_procedures'] = 1;
|
||||
$GLOBALS['xml_export_functions'] = 1;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
$GLOBALS['db'] = 'd<"b';
|
||||
|
||||
$result = [
|
||||
@ -408,7 +406,6 @@ class ExportXmlTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table`;'
|
||||
)
|
||||
|
||||
@ -41,7 +41,6 @@ class ExportYamlTest extends AbstractTestCase
|
||||
$GLOBALS['buffer_needed'] = false;
|
||||
$GLOBALS['asfile'] = false;
|
||||
$GLOBALS['save_on_server'] = false;
|
||||
$GLOBALS['crlf'] = "\n";
|
||||
$GLOBALS['db'] = '';
|
||||
$GLOBALS['table'] = '';
|
||||
$GLOBALS['lang'] = 'en';
|
||||
@ -166,7 +165,6 @@ class ExportYamlTest extends AbstractTestCase
|
||||
$this->object->exportData(
|
||||
'test_db',
|
||||
'test_table',
|
||||
"\n",
|
||||
'localhost',
|
||||
'SELECT * FROM `test_db`.`test_table_yaml`;'
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user