1--TEST--
2Bug #67626: Exceptions not properly handled in user stream handlers
3--FILE--
4<?php
5class MyStream
6{
7    public $context;
8
9    public function stream_open() { return true; }
10
11    public function stream_read()
12    {
13        throw new Exception('stream_read_exception');
14        return 'read';
15    }
16
17    public function stream_eof()
18    {
19        return true;
20    }
21
22    public function stream_write()
23    {
24        throw new Exception('stream_write_exception');
25        return 42;
26    }
27}
28
29stream_wrapper_register("my", "MyStream");
30
31$fp = fopen('my://foobar', 'r+');
32
33try {
34    fread($fp, 42);
35} catch (Exception $e) {
36    echo $e->getMessage();
37}
38echo "\n";
39try {
40    fwrite($fp, 'foobar');
41} catch (Exception $e) {
42    echo $e->getMessage();
43}
44?>
45--EXPECT--
46stream_read_exception
47stream_write_exception
48