From 27a2a804a33a3d414c33d7d543743455325e22fb Mon Sep 17 00:00:00 2001 From: SergeyBiryukov Date: Wed, 18 Aug 2021 13:22:02 +0000 Subject: [PATCH] Code Modernization: Only set `auto_detect_line_endings` in PHP < 8.1. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since PHP 8.1, the `auto_detect_line_endings` setting is deprecated: > The `auto_detect_line_endings` ini setting modifies the behavior of `file()` and `fgets()` to support an isolated `\r` (as opposed to `\n` or `\r\n`) as a newline character. These newlines were used by “Classic” Mac OS, a system which has been discontinued in 2001, nearly two decades ago. Interoperability with such systems is no longer relevant. Reference: [https://wiki.php.net/rfc/deprecations_php_8_1#auto_detect_line_endings_ini_setting PHP RFC: Deprecations for PHP 8.1: auto_detect_line_endings ini setting] > The `auto_detect_line_endings` ini setting has been deprecated. If necessary, handle `\r` line breaks manually instead. Reference: [https://github.com/php/php-src/blob/1cf4fb739f7a4fa8404a4c0958f13d04eae519d4/UPGRADING#L456-L457 PHP 8.1 Upgrade Notes]. This commit fixes the warning when running tests for the `PO` class: {{{ Deprecated: auto_detect_line_endings is deprecated in /var/www/src/wp-includes/pomo/po.php on line 16 }}} Follow-up to [10584], [51628]. See #53635. git-svn-id: https://develop.svn.wordpress.org/trunk@51633 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/pomo/po.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/pomo/po.php b/src/wp-includes/pomo/po.php index 99bb6891b1..22b94c11bf 100644 --- a/src/wp-includes/pomo/po.php +++ b/src/wp-includes/pomo/po.php @@ -13,7 +13,10 @@ if ( ! defined( 'PO_MAX_LINE_LEN' ) ) { define( 'PO_MAX_LINE_LEN', 79 ); } -ini_set( 'auto_detect_line_endings', 1 ); +// This setting has been deprecated in PHP 8.1. +if ( PHP_VERSION_ID < 80100 ) { + ini_set( 'auto_detect_line_endings', 1 ); +} /** * Routines for working with PO files