diff --git a/UPGRADING b/UPGRADING index 94dc22eae18..64b26778a10 100644 --- a/UPGRADING +++ b/UPGRADING @@ -392,6 +392,9 @@ PHP 8.1 UPGRADE NOTES instead (for locale-independent parsing) or IntlDateFormatter::parse() (for locale-dependent parsing). RFC: https://wiki.php.net/rfc/deprecations_php_8_1 + . The auto_detect_line_endings ini setting has been deprecated. If necessary, + handle "\r" line breaks manually instead. + RFC: https://wiki.php.net/rfc/deprecations_php_8_1 . The FILE_BINARY and FILE_TEXT constants are deprecated. They already had no effect previously. RFC: https://wiki.php.net/rfc/deprecations_php_8_1 diff --git a/ext/standard/file.c b/ext/standard/file.c index 17006d51911..d54201f3e43 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -153,11 +153,19 @@ static void file_globals_dtor(php_file_globals *file_globals_p) #endif } +static PHP_INI_MH(OnUpdateAutoDetectLineEndings) +{ + if (zend_ini_parse_bool(new_value)) { + zend_error(E_DEPRECATED, "auto_detect_line_endings is deprecated"); + } + return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); +} + PHP_INI_BEGIN() STD_PHP_INI_ENTRY("user_agent", NULL, PHP_INI_ALL, OnUpdateString, user_agent, php_file_globals, file_globals) STD_PHP_INI_ENTRY("from", NULL, PHP_INI_ALL, OnUpdateString, from_address, php_file_globals, file_globals) STD_PHP_INI_ENTRY("default_socket_timeout", "60", PHP_INI_ALL, OnUpdateLong, default_socket_timeout, php_file_globals, file_globals) - STD_PHP_INI_BOOLEAN("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateBool, auto_detect_line_endings, php_file_globals, file_globals) + STD_PHP_INI_BOOLEAN("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateAutoDetectLineEndings, auto_detect_line_endings, php_file_globals, file_globals) PHP_INI_END() PHP_MINIT_FUNCTION(file) diff --git a/ext/standard/tests/file/auto_detect_line_endings_1.phpt b/ext/standard/tests/file/auto_detect_line_endings_1.phpt index 5a4ff0a10f8..4bdbabb03b5 100644 --- a/ext/standard/tests/file/auto_detect_line_endings_1.phpt +++ b/ext/standard/tests/file/auto_detect_line_endings_1.phpt @@ -16,6 +16,7 @@ var_dump(fgets(STDIN)); echo "Done\n"; ?> --EXPECT-- +Deprecated: auto_detect_line_endings is deprecated in Unknown on line 0 string(1) "1" string(8) "fooBar1 " string(8) "fooBar2 " diff --git a/ext/standard/tests/file/auto_detect_line_endings_2.phpt b/ext/standard/tests/file/auto_detect_line_endings_2.phpt index 3994f1ee3b8..79d51535cb0 100644 --- a/ext/standard/tests/file/auto_detect_line_endings_2.phpt +++ b/ext/standard/tests/file/auto_detect_line_endings_2.phpt @@ -16,7 +16,8 @@ var_dump(fgets($stdin)); echo "Done\n"; ?> ---EXPECT-- +--EXPECTF-- +Deprecated: auto_detect_line_endings is deprecated in %s on line %d string(2) "on" string(8) "fooBar1 " string(8) "fooBar2 "