Skip to content

Commit a89ac98

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #76735: Incorrect message in fopen on invalid mode
2 parents d30ec2c + 2576c57 commit a89ac98

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ PHP NEWS
2525
- Standard:
2626
. Fixed bug #80114 (parse_url does not accept URLs with port 0). (cmb, twosee)
2727
. Fixed bug #76943 (Inconsistent stream_wrapper_restore() errors). (cmb)
28+
. Fixed bug #76735 (Incorrect message in fopen on invalid mode). (cmb)
2829

2930
01 Oct 2020, PHP 7.4.11
3031

ext/bz2/tests/002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ bool(false)
8383
resource(%d) of type (stream)
8484
resource(%d) of type (stream)
8585

86-
Warning: fopen(bz_open_002.txt): failed to open stream: Bad file %s in %s on line %d
86+
Warning: fopen(bz_open_002.txt): failed to open stream: `br' is not a valid mode for fopen in %s on line %d
8787

8888
Warning: bzopen(): first parameter has to be string or file-resource in %s on line %d
8989
bool(false)
9090

91-
Warning: fopen(bz_open_002.txt): failed to open stream: Bad file %s in %s on line %d
91+
Warning: fopen(bz_open_002.txt): failed to open stream: `br' is not a valid mode for fopen in %s on line %d
9292

9393
Warning: bzopen(): first parameter has to be string or file-resource in %s on line %d
9494
bool(false)

ext/standard/tests/file/bug76735.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
Bug #76735 (Incorrect message in fopen on invalid mode)
3+
--FILE--
4+
<?php
5+
fopen(__FILE__, 'Q');
6+
?>
7+
--EXPECTF--
8+
Warning: fopen(%s): failed to open stream: `Q' is not a valid mode for fopen in %s on line %d

main/streams/plain_wrapper.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,9 +1047,7 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, zen
10471047
char *persistent_id = NULL;
10481048

10491049
if (FAILURE == php_stream_parse_fopen_modes(mode, &open_flags)) {
1050-
if (options & REPORT_ERRORS) {
1051-
php_error_docref(NULL, E_WARNING, "`%s' is not a valid mode for fopen", mode);
1052-
}
1050+
php_stream_wrapper_log_error(&php_plain_files_wrapper, options, "`%s' is not a valid mode for fopen", mode);
10531051
return NULL;
10541052
}
10551053

0 commit comments

Comments
 (0)