Skip to content

Commit 232aa34

Browse files
committed
Deprecate auto_detect_line_endings
Part of https://wiki.php.net/rfc/deprecations_php_8_1.
1 parent bed7139 commit 232aa34

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ PHP 8.1 UPGRADE NOTES
392392
instead (for locale-independent parsing) or IntlDateFormatter::parse() (for
393393
locale-dependent parsing).
394394
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
395+
. The auto_detect_line_endings ini setting has been deprecated. If necessary,
396+
handle "\r" line breaks manually instead.
397+
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
395398
. The FILE_BINARY and FILE_TEXT constants are deprecated. They already had
396399
no effect previously.
397400
RFC: https://wiki.php.net/rfc/deprecations_php_8_1

ext/standard/file.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,19 @@ static void file_globals_dtor(php_file_globals *file_globals_p)
153153
#endif
154154
}
155155

156+
static PHP_INI_MH(OnUpdateAutoDetectLineEndings)
157+
{
158+
if (zend_ini_parse_bool(new_value)) {
159+
zend_error(E_DEPRECATED, "auto_detect_line_endings is deprecated");
160+
}
161+
return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
162+
}
163+
156164
PHP_INI_BEGIN()
157165
STD_PHP_INI_ENTRY("user_agent", NULL, PHP_INI_ALL, OnUpdateString, user_agent, php_file_globals, file_globals)
158166
STD_PHP_INI_ENTRY("from", NULL, PHP_INI_ALL, OnUpdateString, from_address, php_file_globals, file_globals)
159167
STD_PHP_INI_ENTRY("default_socket_timeout", "60", PHP_INI_ALL, OnUpdateLong, default_socket_timeout, php_file_globals, file_globals)
160-
STD_PHP_INI_BOOLEAN("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateBool, auto_detect_line_endings, php_file_globals, file_globals)
168+
STD_PHP_INI_BOOLEAN("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateAutoDetectLineEndings, auto_detect_line_endings, php_file_globals, file_globals)
161169
PHP_INI_END()
162170

163171
PHP_MINIT_FUNCTION(file)

ext/standard/tests/file/auto_detect_line_endings_1.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var_dump(fgets(STDIN));
1616
echo "Done\n";
1717
?>
1818
--EXPECT--
19+
Deprecated: auto_detect_line_endings is deprecated in Unknown on line 0
1920
string(1) "1"
2021
string(8) "fooBar1"
2122
string(8) "fooBar2"

ext/standard/tests/file/auto_detect_line_endings_2.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ var_dump(fgets($stdin));
1616

1717
echo "Done\n";
1818
?>
19-
--EXPECT--
19+
--EXPECTF--
20+
Deprecated: auto_detect_line_endings is deprecated in %s on line %d
2021
string(2) "on"
2122
string(8) "fooBar1"
2223
string(8) "fooBar2"

0 commit comments

Comments
 (0)