Skip to content

Commit 196f969

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents 346be2c + 2fdd142 commit 196f969

File tree

7 files changed

+33
-9
lines changed

7 files changed

+33
-9
lines changed

ext/standard/php_fopen_wrapper.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,11 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
374374
}
375375
efree(pathdup);
376376

377+
if (EG(exception)) {
378+
php_stream_close(stream);
379+
return NULL;
380+
}
381+
377382
return stream;
378383
} else {
379384
/* invalid php://thingy */

ext/standard/tests/file/bug38450_2.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ var_dump($myvar);
102102
echo "Done\n";
103103
?>
104104
--EXPECTF--
105-
Warning: fopen(var://myvar): failed to open stream: "VariableStream::stream_open" call failed in %s on line %d
106-
107105
Fatal error: Uncaught Exception: constructor in %s:%d
108106
Stack trace:
109107
#0 [internal function]: VariableStream->__construct()

ext/standard/tests/file/bug38450_3.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ var_dump($myvar);
102102
echo "Done\n";
103103
?>
104104
--EXPECTF--
105-
Warning: fopen(var://myvar): failed to open stream: "VariableStream::stream_open" call failed in %sbug38450_3.php on line %d
106-
107105
Fatal error: Uncaught ArgumentCountError: Too few arguments to function VariableStream::__construct(), 0 passed and exactly 1 expected in %sbug38450_3.php:7
108106
Stack trace:
109107
#0 [internal function]: VariableStream->__construct()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Creating the stream filter object may fail (include variation)
3+
--FILE--
4+
<?php
5+
class SampleFilter extends php_user_filter {
6+
private $data = \FOO;
7+
}
8+
stream_filter_register('sample.filter', SampleFilter::class);
9+
try {
10+
include 'php://filter/read=sample.filter/resource='. __FILE__;
11+
} catch (Error $e) {
12+
echo $e->getMessage(), "\n";
13+
}
14+
?>
15+
--EXPECTF--
16+
Warning: main(): unable to create or locate filter "sample.filter" in %s on line %d
17+
18+
Warning: main(): Unable to create filter (sample.filter) in %s on line %d
19+
20+
Warning: main(): Failed opening '%s' for inclusion (include_path='%s') in %s on line %d
21+
Undefined constant 'FOO'

ext/standard/tests/streams/bug77664.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ stream_wrapper_register('error',ErrorWrapper::class);
1010
file_get_contents('error://test');
1111
?>
1212
--EXPECTF--
13-
Warning: file_get_contents(error://test): failed to open stream: operation failed in %sbug77664.php on line %d
14-
1513
Fatal error: Uncaught Error: Undefined class constant 'self::INVALID' in %sbug77664.php:%d
1614
Stack trace:
1715
#0 %sbug77664.php(%d): file_get_contents('error://test')

ext/standard/tests/streams/user-stream-error.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ stream_wrapper_register('mystream', 'FailStream');
1212
fopen('mystream://foo', 'r');
1313
echo 'Done';
1414
--EXPECTF--
15-
Warning: fopen(mystream://foo): failed to open stream: "FailStream::stream_open" call failed in %s%euser-stream-error.php on line %d
16-
1715
Fatal error: Uncaught Error: Call to undefined function _some_undefined_function() in %s%euser-stream-error.php:%d
1816
Stack trace:
1917
#0 [internal function]: FailStream->stream_open('mystream://foo', 'r', 0, NULL)

main/streams/streams.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,16 @@ static zend_llist *php_get_wrapper_errors_list(php_stream_wrapper *wrapper)
152152
/* {{{ wrapper error reporting */
153153
void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char *path, const char *caption)
154154
{
155-
char *tmp = estrdup(path);
155+
char *tmp;
156156
char *msg;
157157
int free_msg = 0;
158158

159+
if (EG(exception)) {
160+
/* Don't emit additional warnings if an exception has already been thrown. */
161+
return;
162+
}
163+
164+
tmp = estrdup(path);
159165
if (wrapper) {
160166
zend_llist *err_list = php_get_wrapper_errors_list(wrapper);
161167
if (err_list) {

0 commit comments

Comments
 (0)