From 75ad097c3612b6815848bcf813c879a1513479ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 23 Jan 2017 15:59:52 +0100 Subject: [PATCH] Replace Util::whichCrlf() with PHP_EOL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's available since PHP 5.0.2 so it's really time to use it. Signed-off-by: Michal Čihař --- export.php | 2 +- libraries/Util.php | 21 ----- libraries/plugins/import/ImportLdi.php | 2 +- test/libraries/common/PMA_whichCrlf_test.php | 87 -------------------- 4 files changed, 2 insertions(+), 110 deletions(-) delete mode 100644 test/libraries/common/PMA_whichCrlf_test.php diff --git a/export.php b/export.php index 836bf4f8f2..17ec404776 100644 --- a/export.php +++ b/export.php @@ -312,7 +312,7 @@ $time_start = time(); if ($what == 'sql') { $crlf = "\n"; } else { - $crlf = PMA\libraries\Util::whichCrlf(); + $crlf = PHP_EOL; } $output_kanji_conversion = Encoding::canConvertKanji(); diff --git a/libraries/Util.php b/libraries/Util.php index a3619f2866..b24a5c083b 100644 --- a/libraries/Util.php +++ b/libraries/Util.php @@ -933,27 +933,6 @@ class Util } } // end of the 'backquoteCompat()' function - /** - * Defines the value depending on the user OS. - * - * @return string the value to use - * - * @access public - */ - public static function whichCrlf() - { - // The 'PMA_USR_OS' constant is defined in "libraries/Config.php" - // Win case - if (PMA_USR_OS == 'Win') { - $the_crlf = "\r\n"; - } else { - // Others - $the_crlf = "\n"; - } - - return $the_crlf; - } // end of the 'whichCrlf()' function - /** * Prepare the message and the query * usually the message is the result of the query executed diff --git a/libraries/plugins/import/ImportLdi.php b/libraries/plugins/import/ImportLdi.php index e39d4b09e8..ae22147588 100644 --- a/libraries/plugins/import/ImportLdi.php +++ b/libraries/plugins/import/ImportLdi.php @@ -142,7 +142,7 @@ class ImportLdi extends AbstractImportCsv if (strlen($ldi_new_line) > 0) { if ($ldi_new_line == 'auto') { $ldi_new_line - = (PMA\libraries\Util::whichCrlf() == "\n") + = (PHP_EOL == "\n") ? '\n' : '\r\n'; } diff --git a/test/libraries/common/PMA_whichCrlf_test.php b/test/libraries/common/PMA_whichCrlf_test.php deleted file mode 100644 index f7eb768a54..0000000000 --- a/test/libraries/common/PMA_whichCrlf_test.php +++ /dev/null @@ -1,87 +0,0 @@ -assertEquals( - "\r\n", PMA\libraries\Util::whichCrlf() - ); - } else { - $this->assertEquals( - "\n", PMA\libraries\Util::whichCrlf() - ); - } - - $this->markTestIncomplete('Cannot redefine constant'); - - } else { - - if (PMA_HAS_RUNKIT) { - if (!defined('PMA_USR_OS')) { - define('PMA_USR_OS', 'Linux'); - } else { - runkit_constant_redefine('PMA_USR_OS', 'Linux'); - } - - $this->assertEquals( - "\n", PMA\libraries\Util::whichCrlf() - ); - } - - if (PMA_HAS_RUNKIT) { - runkit_constant_redefine('PMA_USR_OS', 'Win'); - } else { - define('PMA_USR_OS', 'Win'); - } - $this->assertEquals( - "\r\n", PMA\libraries\Util::whichCrlf() - ); - - } - - if (PMA_HAS_RUNKIT) { - if (isset($pma_usr_os)) { - runkit_constant_redefine('PMA_USR_OS', 'Win'); - } else { - runkit_constant_remove('PMA_USR_OS'); - } - } - } - -}