Skip to content

Commit 05edf64

Browse files
committed
Merge branch 'PHP-7.4' into master
* PHP-7.4: Fix #76735: Incorrect message in fopen on invalid mode
2 parents d211373 + a89ac98 commit 05edf64

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

ext/bz2/tests/002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ bool(false)
9090
resource(%d) of type (stream)
9191
resource(%d) of type (stream)
9292

93-
Warning: fopen(bz_open_002.txt): Failed to open stream: Bad file %s in %s on line %d
93+
Warning: fopen(bz_open_002.txt): Failed to open stream: `br' is not a valid mode for fopen in %s on line %d
9494
bzopen(): Argument #1 ($file) must be of type string or file-resource, bool given
9595

96-
Warning: fopen(bz_open_002.txt): Failed to open stream: Bad file %s in %s on line %d
96+
Warning: fopen(bz_open_002.txt): Failed to open stream: `br' is not a valid mode for fopen %s in %s on line %d
9797
bzopen(): Argument #1 ($file) must be of type string or file-resource, bool given
9898

9999
Warning: bzopen(): cannot write to a stream opened in read only mode in %s on line %d

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
@@ -1051,9 +1051,7 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, zen
10511051
char *persistent_id = NULL;
10521052

10531053
if (FAILURE == php_stream_parse_fopen_modes(mode, &open_flags)) {
1054-
if (options & REPORT_ERRORS) {
1055-
zend_value_error("\"%s\" is not a valid mode for fopen", mode);
1056-
}
1054+
php_stream_wrapper_log_error(&php_plain_files_wrapper, options, "`%s' is not a valid mode for fopen", mode);
10571055
return NULL;
10581056
}
10591057

0 commit comments

Comments
 (0)