diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-09-13 03:54:21 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-09-13 20:08:57 +0300 |
commit | 873eb098b922638d33a7748fedc3b33ead33227c (patch) | |
tree | 911841423ce0a523c9e885b80f66802e9bd97ccd /libraries | |
parent | 5d74cd134e870837c69d71c8e291576f26149958 (diff) |
Remove crlf global variable
The crlf global variable is only diferent for SQL export method,
otherwise is always the value of the PHP_EOL constant.
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'libraries')
21 files changed, 258 insertions, 405 deletions
diff --git a/libraries/classes/Controllers/Export/ExportController.php b/libraries/classes/Controllers/Export/ExportController.php index c017a5daac..aa18144568 100644 --- a/libraries/classes/Controllers/Export/ExportController.php +++ b/libraries/classes/Controllers/Export/ExportController.php @@ -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'], diff --git a/libraries/classes/Export.php b/libraries/classes/Export.php index 1ff049ed36..6982ad58b7 100644 --- a/libraries/classes/Export.php +++ b/libraries/classes/Export.php @@ -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, diff --git a/libraries/classes/Operations.php b/libraries/classes/Operations.php index 679b313cf5..f7b339a249 100644 --- a/libraries/classes/Operations.php +++ b/libraries/classes/Operations.php @@ -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; diff --git a/libraries/classes/Plugins/Export/ExportCodegen.php b/libraries/classes/Plugins/Export/ExportCodegen.php index d7fdc45ae2..6bfc53ba24 100644 --- a/libraries/classes/Plugins/Export/ExportCodegen.php +++ b/libraries/classes/Plugins/Export/ExportCodegen.php @@ -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); } /** diff --git a/libraries/classes/Plugins/Export/ExportCsv.php b/libraries/classes/Plugins/Export/ExportCsv.php index 69e140b170..4b836452fa 100644 --- a/libraries/classes/Plugins/Export/ExportCsv.php +++ b/libraries/classes/Plugins/Export/ExportCsv.php @@ -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); } } diff --git a/libraries/classes/Plugins/Export/ExportHtmlword.php b/libraries/classes/Plugins/Export/ExportHtmlword.php index 1186ca52ab..daf1593650 100644 --- a/libraries/classes/Plugins/Export/ExportHtmlword.php +++ b/libraries/classes/Plugins/Export/ExportHtmlword.php @@ -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); diff --git a/libraries/classes/Plugins/Export/ExportJson.php b/libraries/classes/Plugins/Export/ExportJson.php index d09d03b2d8..1591c70f0f 100644 --- a/libraries/classes/Plugins/Export/ExportJson.php +++ b/libraries/classes/Plugins/Export/ExportJson.php @@ -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); } } diff --git a/libraries/classes/Plugins/Export/ExportLatex.php b/libraries/classes/Plugins/Export/ExportLatex.php index e40f993e86..68514f75ac 100644 --- a/libraries/classes/Plugins/Export/ExportLatex.php +++ b/libraries/classes/Plugins/Export/ExportLatex.php @@ -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); } diff --git a/libraries/classes/Plugins/Export/ExportMediawiki.php b/libraries/classes/Plugins/Export/ExportMediawiki.php index f11681ccc9..8ab15928b9 100644 --- a/libraries/classes/Plugins/Export/ExportMediawiki.php +++ b/libraries/classes/Plugins/Export/ExportMediawiki.php @@ -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); } /** diff --git a/libraries/classes/Plugins/Export/ExportOds.php b/libraries/classes/Plugins/Export/ExportOds.php index 20cc5ac83e..95be16cf16 100644 --- a/libraries/classes/Plugins/Export/ExportOds.php +++ b/libraries/classes/Plugins/Export/ExportOds.php @@ -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); } } diff --git a/libraries/classes/Plugins/Export/ExportOdt.php b/libraries/classes/Plugins/Export/ExportOdt.php index c26496af40..65e4b6f8e1 100644 --- a/libraries/classes/Plugins/Export/ExportOdt.php +++ b/libraries/classes/Plugins/Export/ExportOdt.php @@ -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; diff --git a/libraries/classes/Plugins/Export/ExportPdf.php b/libraries/classes/Plugins/Export/ExportPdf.php index 3a8b6ebffa..602da3c188 100644 --- a/libraries/classes/Plugins/Export/ExportPdf.php +++ b/libraries/classes/Plugins/Export/ExportPdf.php @@ -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); */ } diff --git a/libraries/classes/Plugins/Export/ExportPhparray.php b/libraries/classes/Plugins/Export/ExportPhparray.php index 0ae8e66d1f..29753e3386 100644 --- a/libraries/classes/Plugins/Export/ExportPhparray.php +++ b/libraries/classes/Plugins/Export/ExportPhparray.php @@ -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); } } diff --git a/libraries/classes/Plugins/Export/ExportSql.php b/libraries/classes/Plugins/Export/ExportSql.php index ed29f70463..0e085c4254 100644 --- a/libraries/classes/Plugins/Export/ExportSql.php +++ b/libraries/classes/Plugins/Export/ExportSql.php @@ -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( diff --git a/libraries/classes/Plugins/Export/ExportTexytext.php b/libraries/classes/Plugins/Export/ExportTexytext.php index 6280520c78..14b03c7e0f 100644 --- a/libraries/classes/Plugins/Export/ExportTexytext.php +++ b/libraries/classes/Plugins/Export/ExportTexytext.php @@ -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); diff --git a/libraries/classes/Plugins/Export/ExportXml.php b/libraries/classes/Plugins/Export/ExportXml.php index 473e8ed2ba..e203c495ea 100644 --- a/libraries/classes/Plugins/Export/ExportXml.php +++ b/libraries/classes/Plugins/Export/ExportXml.php @@ -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; diff --git a/libraries/classes/Plugins/Export/ExportYaml.php b/libraries/classes/Plugins/Export/ExportYaml.php index ac5def7dad..0b3c6c37f6 100644 --- a/libraries/classes/Plugins/Export/ExportYaml.php +++ b/libraries/classes/Plugins/Export/ExportYaml.php @@ -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); } } diff --git a/libraries/classes/Plugins/Export/README.md b/libraries/classes/Plugins/Export/README.md index 26c4c3839f..5dbe091110 100644 --- a/libraries/classes/Plugins/Export/README.md +++ b/libraries/classes/Plugins/Export/README.md @@ -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 = [] diff --git a/libraries/classes/Plugins/ExportPlugin.php b/libraries/classes/Plugins/ExportPlugin.php index f9ff02c950..0985f637aa 100644 --- a/libraries/classes/Plugins/ExportPlugin.php +++ b/libraries/classes/Plugins/ExportPlugin.php @@ -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 ''; } diff --git a/libraries/classes/Setup/ConfigGenerator.php b/libraries/classes/Setup/ConfigGenerator.php index d252636efa..189c8c9260 100644 --- a/libraries/classes/Setup/ConfigGenerator.php +++ b/libraries/classes/Setup/ConfigGenerator.php @@ -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; } diff --git a/libraries/classes/Tracker.php b/libraries/classes/Tracker.php index 5ba5e02c8a..c824c5f211 100644 --- a/libraries/classes/Tracker.php +++ b/libraries/classes/Tracker.php @@ -246,7 +246,7 @@ class Tracker } $createSql .= self::getLogComment() . - $exportSqlPlugin->getTableDef($dbName, $tableName, "\n", ''); + $exportSqlPlugin->getTableDef($dbName, $tableName, ''); // Save version $trackingFeature = $relation->getRelationParameters()->trackingFeature; |