Make WordPress Core

Changeset 51633


Ignore:
Timestamp:
08/18/2021 01:22:02 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Only set auto_detect_line_endings in PHP < 8.1.

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: 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: 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pomo/po.php

    r49186 r51633  
    1414}
    1515
    16 ini_set( 'auto_detect_line_endings', 1 );
     16// This setting has been deprecated in PHP 8.1.
     17if ( PHP_VERSION_ID < 80100 ) {
     18    ini_set( 'auto_detect_line_endings', 1 );
     19}
    1720
    1821/**
Note: See TracChangeset for help on using the changeset viewer.