Skip to content

Commit d0247a6

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78535: auto_detect_line_endings value not parsed as bool
2 parents 3f76f94 + 00ad365 commit d0247a6

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ PHP NEWS
77
As a side effect this allowed passign left hean list() "by reference",
88
instead of compile-time error. (Dmitry)
99
. Fixed bug #78531 (Crash when using undefined variable as object). (Dmitry)
10+
. Fixed bug #78535 (auto_detect_line_endings value not parsed as bool).
11+
(bugreportuser)
1012

1113
- FFI:
1214
. Added missing FFI::isNull(). (Philip Hofstetter)

ext/standard/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ PHP_INI_BEGIN()
163163
STD_PHP_INI_ENTRY("user_agent", NULL, PHP_INI_ALL, OnUpdateString, user_agent, php_file_globals, file_globals)
164164
STD_PHP_INI_ENTRY("from", NULL, PHP_INI_ALL, OnUpdateString, from_address, php_file_globals, file_globals)
165165
STD_PHP_INI_ENTRY("default_socket_timeout", "60", PHP_INI_ALL, OnUpdateLong, default_socket_timeout, php_file_globals, file_globals)
166-
STD_PHP_INI_ENTRY("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateLong, auto_detect_line_endings, php_file_globals, file_globals)
166+
STD_PHP_INI_ENTRY("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateBool, auto_detect_line_endings, php_file_globals, file_globals)
167167
PHP_INI_END()
168168

169169
PHP_MINIT_FUNCTION(file)

ext/standard/file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ php_meta_tags_token php_next_meta_token(php_meta_tags_data *);
117117
typedef struct {
118118
int pclose_ret;
119119
size_t def_chunk_size;
120-
zend_long auto_detect_line_endings;
120+
zend_bool auto_detect_line_endings;
121121
zend_long default_socket_timeout;
122122
char *user_agent; /* for the http wrapper */
123123
char *from_address; /* for the ftp and http wrappers */

ext/standard/tests/file/auto_detect_line_endings_1.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
auto_detect_line_endings --INI-- bool
3+
--INI--
4+
auto_detect_line_endings=on
5+
--STDIN--
6+
fooBar1fooBar2fooBar3
7+
--FILE--
8+
<?php
9+
10+
var_dump(ini_get("auto_detect_line_endings"));
11+
12+
var_dump(fgets(STDIN));
13+
var_dump(fgets(STDIN));
14+
var_dump(fgets(STDIN));
15+
16+
echo "Done\n";
17+
?>
18+
--EXPECTF--
19+
string(1) "1"
20+
string(8) "fooBar1"
21+
string(8) "fooBar2"
22+
string(8) "fooBar3
23+
"
24+
Done

ext/standard/tests/file/auto_detect_line_endings_2.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
ini_set auto_detect_line_endings bool
3+
--FILE--
4+
<?php
5+
6+
ini_set("auto_detect_line_endings", "on");
7+
var_dump(ini_get("auto_detect_line_endings"));
8+
9+
$filePath = __DIR__ . DIRECTORY_SEPARATOR . "auto_detect_line_endings_2.txt";
10+
file_put_contents($filePath, "fooBar1\rfooBar2\rfooBar3");
11+
12+
$stdin = fopen($filePath, "r");
13+
var_dump(fgets($stdin));
14+
var_dump(fgets($stdin));
15+
var_dump(fgets($stdin));
16+
17+
echo "Done\n";
18+
?>
19+
--EXPECTF--
20+
string(2) "on"
21+
string(8) "fooBar1"
22+
string(8) "fooBar2"
23+
string(7) "fooBar3"
24+
Done
25+
--CLEAN--
26+
<?php
27+
unlink(__DIR__ . DIRECTORY_SEPARATOR . "auto_detect_line_endings_2.txt");
28+
?>

0 commit comments

Comments
 (0)