}
efree(pathdup);
+ if (EG(exception)) {
+ php_stream_close(stream);
+ return NULL;
+ }
+
return stream;
} else {
/* invalid php://thingy */
echo "Done\n";
?>
--EXPECTF--
-Warning: fopen(var://myvar): failed to open stream: "VariableStream::stream_open" call failed in %s on line %d
-
Fatal error: Uncaught Exception: constructor in %s:%d
Stack trace:
#0 [internal function]: VariableStream->__construct()
echo "Done\n";
?>
--EXPECTF--
-Warning: fopen(var://myvar): failed to open stream: "VariableStream::stream_open" call failed in %sbug38450_3.php on line %d
-
Fatal error: Uncaught ArgumentCountError: Too few arguments to function VariableStream::__construct(), 0 passed and exactly 1 expected in %sbug38450_3.php:7
Stack trace:
#0 [internal function]: VariableStream->__construct()
--- /dev/null
+--TEST--
+Creating the stream filter object may fail (include variation)
+--FILE--
+<?php
+class SampleFilter extends php_user_filter {
+ private $data = \FOO;
+}
+stream_filter_register('sample.filter', SampleFilter::class);
+try {
+ include 'php://filter/read=sample.filter/resource='. __FILE__;
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+?>
+--EXPECTF--
+Warning: main(): unable to create or locate filter "sample.filter" in %s on line %d
+
+Warning: main(): Unable to create filter (sample.filter) in %s on line %d
+
+Warning: main(): Failed opening '%s' for inclusion (include_path='%s') in %s on line %d
+Undefined constant 'FOO'
file_get_contents('error://test');
?>
--EXPECTF--
-Warning: file_get_contents(error://test): failed to open stream: operation failed in %sbug77664.php on line %d
-
Fatal error: Uncaught Error: Undefined class constant 'self::INVALID' in %sbug77664.php:%d
Stack trace:
#0 %sbug77664.php(%d): file_get_contents('error://test')
fopen('mystream://foo', 'r');
echo 'Done';
--EXPECTF--
-Warning: fopen(mystream://foo): failed to open stream: "FailStream::stream_open" call failed in %s%euser-stream-error.php on line %d
-
Fatal error: Uncaught Error: Call to undefined function _some_undefined_function() in %s%euser-stream-error.php:%d
Stack trace:
#0 [internal function]: FailStream->stream_open('mystream://foo', 'r', 0, NULL)
/* {{{ wrapper error reporting */
void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char *path, const char *caption)
{
- char *tmp = estrdup(path);
+ char *tmp;
char *msg;
int free_msg = 0;
+ if (EG(exception)) {
+ /* Don't emit additional warnings if an exception has already been thrown. */
+ return;
+ }
+
+ tmp = estrdup(path);
if (wrapper) {
zend_llist *err_list = php_get_wrapper_errors_list(wrapper);
if (err_list) {