[wp-trac] [WordPress Trac] #64928: pomo/po.php: Replace deprecated auto_detect_line_endings with manual line-ending handling
WordPress Trac
noreply at wordpress.org
Mon Mar 23 14:54:38 UTC 2026
#64928: pomo/po.php: Replace deprecated auto_detect_line_endings with manual line-
ending handling
--------------------------------------+-----------------------------
Reporter: apermo | Owner: SergeyBiryukov
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 7.0
Component: I18N | Version: 5.9
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+-----------------------------
Changes (by SergeyBiryukov):
* status: reviewing => closed
* resolution: => fixed
Comment:
In [changeset:"62093" 62093]:
{{{
#!CommitTicketReference repository="" revision="62093"
Code Modernization: Replace the deprecated `auto_detect_line_endings`
setting.
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 commits adds code to replace the deprecated setting and still handle
old-style `\r` line-terminated files in `PO::read_line()` using `strpos()`
+ `fseek()`. Includes a unit test covering `\r`, `\n`, and `\r\n` line
endings.
Follow-up to [51633], [51636].
Props akirk, apermo, westonruter, SergeyBiryukov.
Fixes #64928.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64928#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list