xref: /php-src/Zend/tests/bug38779_1.phpt (revision 902d6439)
1--TEST--
2Bug #38779 (engine crashes when require()'ing file with syntax error through userspace stream wrapper)
3--FILE--
4<?php
5
6class Loader {
7    public $context;
8    private $position;
9    private $data;
10    public function stream_open($path, $mode, $options, &$opened_path)  {
11        $this->data = '<' . "?php \n\"\";ll l\n ?" . '>';
12        $this->position = 0;
13        return true;
14    }
15    function stream_read($count) {
16        $ret = substr($this->data, $this->position, $count);
17        $this->position += strlen($ret);
18        return $ret;
19    }
20    function stream_eof() {
21        return $this->position >= strlen($this->data);
22    }
23    function stream_flush() {
24        var_dump("flush!");
25    }
26    function stream_close() {
27        @unlink(__DIR__."/bug38779.txt");
28        var_dump("close!");
29    }
30}
31stream_wrapper_register('Loader', 'Loader');
32$fp = fopen ('Loader://qqq.php', 'r');
33
34$filename = __DIR__."/bug38779.txt";
35$fp1 = fopen($filename, "w");
36fwrite($fp1, "<"."?php blah blah?".">");
37fclose($fp1);
38
39include $filename;
40
41echo "Done\n";
42?>
43--CLEAN--
44<?php
45
46$filename = __DIR__."/bug38779.txt";
47if (file_exists($filename)) {
48	@unlink(__DIR__."/bug38779.txt");
49}
50?>
51--EXPECTF--
52Parse error: %s error%sin %s on line %d
53string(6) "close!"
54