Skip to content

Commit c98a51a

Browse files
committed
Merge branch 'bug40459' into PHP-5.4
* bug40459: News for bug#40459 fix bug #40459 - make all stream funcs that create object call ctor
2 parents 55b82ab + 128a4bb commit c98a51a

File tree

4 files changed

+188
-117
lines changed

4 files changed

+188
-117
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ PHP NEWS
77
the exit value). (Laruence)
88
. Fixed bug #51363 (Fatal error raised by var_export() not caught by error
99
handler). (Lonny Kapelushnik)
10+
. Fixed bug #40459 (Stat and Dir stream wrapper methods do not call
11+
constructor). (Stas)
1012

1113
- PDO:
1214
. Fixed bug #62685 (Wrong return datatype in PDO::inTransaction()). (Laruence)

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ PHP 5.4 UPGRADE NOTES
347347
allows for toggling if the list of namespaces starts from the document root
348348
or from the node you call the method on
349349

350+
- Since 5.4.7, ctor is always called when new user stream wrapper object is created.
351+
Before, it was called only when stream_open was called.
352+
350353
==============================
351354
5. Changes to existing classes
352355
==============================
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
--TEST--
2+
bug 40459 - Test whether the constructor of the user-space stream wrapper is called when stream functions are called
3+
--FILE--
4+
<?php
5+
// Test whether the constructor of the user-space stream wrapper is called when stream functions are called
6+
class testwrapper {
7+
private $constructorCalled = false;
8+
function __construct() {
9+
$this->constructorCalled = true;
10+
}
11+
12+
function stream_open($path, $mode, $options, &$opened_path)
13+
{
14+
echo $this->constructorCalled ? 'yes' : 'no';
15+
return true;
16+
}
17+
18+
function url_stat($url, $flags)
19+
{
20+
echo $this->constructorCalled ? 'yes' : 'no';
21+
return array();
22+
}
23+
24+
function unlink($url)
25+
{
26+
echo $this->constructorCalled ? 'yes' : 'no';
27+
}
28+
29+
function rename($from, $to)
30+
{
31+
echo $this->constructorCalled ? 'yes' : 'no';
32+
}
33+
34+
function mkdir($dir, $mode, $options)
35+
{
36+
echo $this->constructorCalled ? 'yes' : 'no';
37+
}
38+
39+
function rmdir($dir, $options)
40+
{
41+
echo $this->constructorCalled ? 'yes' : 'no';
42+
}
43+
44+
function dir_opendir($url, $options)
45+
{
46+
echo $this->constructorCalled ? 'yes' : 'no';
47+
return TRUE;
48+
}
49+
function stream_metadata()
50+
{
51+
echo $this->constructorCalled ? 'yes' : 'no';
52+
return TRUE;
53+
}
54+
}
55+
56+
stream_wrapper_register('test', 'testwrapper', STREAM_IS_URL);
57+
58+
echo 'stream_open: ';
59+
fopen('test://test', 'r');
60+
echo "\n";
61+
62+
echo 'url_stat: ';
63+
stat('test://test');
64+
echo "\n";
65+
66+
echo 'dir_opendir: ';
67+
opendir('test://test');
68+
echo "\n";
69+
70+
echo 'rmdir: ';
71+
rmdir('test://test');
72+
echo "\n";
73+
74+
echo 'mkdir: ';
75+
mkdir('test://test');
76+
echo "\n";
77+
78+
echo 'rename: ';
79+
rename('test://test', 'test://test2');
80+
echo "\n";
81+
82+
echo 'unlink: ';
83+
unlink('test://test');
84+
echo "\n";
85+
86+
echo 'touch: ';
87+
touch('test://test', time());
88+
echo "\n";
89+
90+
91+
92+
?>
93+
==DONE==
94+
--EXPECT--
95+
stream_open: yes
96+
url_stat: yes
97+
dir_opendir: yes
98+
rmdir: yes
99+
mkdir: yes
100+
rename: yes
101+
unlink: yes
102+
touch: yes
103+
==DONE==

0 commit comments

Comments
 (0)