Skip to content

Commit dd10e70

Browse files
committed
Promote Directory handler warning to error
1 parent 0d8a399 commit dd10e70

File tree

4 files changed

+52
-34
lines changed

4 files changed

+52
-34
lines changed

ext/standard/dir.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,21 @@ static zend_class_entry *dir_class_entry_ptr;
6868
myself = getThis(); \
6969
if (myself) { \
7070
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(myself), "handle", sizeof("handle")-1)) == NULL) { \
71-
php_error_docref(NULL, E_WARNING, "Unable to find my handle property"); \
72-
RETURN_FALSE; \
71+
zend_throw_error(NULL, "Unable to find my handle property"); \
72+
return; \
7373
} \
7474
if ((dirp = (php_stream *)zend_fetch_resource_ex(tmp, "Directory", php_file_le_stream())) == NULL) { \
75-
RETURN_FALSE; \
75+
return; \
7676
} \
7777
} else { \
7878
if (!DIRG(default_dir) || \
7979
(dirp = (php_stream *)zend_fetch_resource(DIRG(default_dir), "Directory", php_file_le_stream())) == NULL) { \
80-
RETURN_FALSE; \
80+
return; \
8181
} \
8282
} \
8383
} else { \
8484
if ((dirp = (php_stream *)zend_fetch_resource(Z_RES_P(id), "Directory", php_file_le_stream())) == NULL) { \
85-
RETURN_FALSE; \
85+
return; \
8686
} \
8787
}
8888

ext/standard/tests/directory/DirectoryClass_basic_001.phpt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ echo $rc;
1515
echo "Cannot instantiate a valid Directory directly:\n";
1616
$d = new Directory(getcwd());
1717
var_dump($d);
18-
var_dump($d->read());
18+
19+
try {
20+
var_dump($d->read());
21+
} catch (\Error $e) {
22+
echo $e->getMessage() . "\n";
23+
}
1924

2025
?>
2126
--EXPECTF--
@@ -60,6 +65,4 @@ Class [ <internal%s> class Directory ] {
6065
Cannot instantiate a valid Directory directly:
6166
object(Directory)#%d (0) {
6267
}
63-
64-
Warning: Directory::read(): Unable to find my handle property in %s on line 15
65-
bool(false)
68+
Unable to find my handle property

ext/standard/tests/directory/DirectoryClass_error_001-mb.phpt

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,22 @@ try {
2929
echo "\n--> Try all methods with no handle:\n";
3030
$d = new Directory($d);
3131
unset($d->handle);
32-
var_dump($d->read());
33-
var_dump($d->rewind());
34-
var_dump($d->close());
32+
33+
try {
34+
var_dump($d->read());
35+
} catch (\Error $e) {
36+
echo $e->getMessage() . "\n";
37+
}
38+
try {
39+
var_dump($d->rewind());
40+
} catch (\Error $e) {
41+
echo $e->getMessage() . "\n";
42+
}
43+
try {
44+
var_dump($d->close());
45+
} catch (\Error $e) {
46+
echo $e->getMessage() . "\n";
47+
}
3548

3649
?>
3750
--CLEAN--
@@ -40,19 +53,14 @@ $d = getcwd().PATH_SEPARATOR."私はガラスを食べられます";
4053
rmdir($d);
4154

4255
?>
43-
--EXPECTF--
56+
--EXPECT--
4457
--> Try all methods with bad handle:
4558
Directory::read(): supplied argument is not a valid Directory resource
4659
Directory::rewind(): supplied argument is not a valid Directory resource
4760
Directory::close(): supplied argument is not a valid Directory resource
4861

4962
--> Try all methods with no handle:
63+
Unable to find my handle property
64+
Unable to find my handle property
65+
Unable to find my handle property
5066

51-
Warning: Directory::read(): Unable to find my handle property in %s on line %d
52-
bool(false)
53-
54-
Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
55-
bool(false)
56-
57-
Warning: Directory::close(): Unable to find my handle property in %s on line %d
58-
bool(false)

ext/standard/tests/directory/DirectoryClass_error_001.phpt

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,31 @@ try {
2525
echo "\n--> Try all methods with no handle:\n";
2626
$d = new Directory(getcwd());
2727
unset($d->handle);
28-
var_dump($d->read());
29-
var_dump($d->rewind());
30-
var_dump($d->close());
28+
29+
try {
30+
var_dump($d->read());
31+
} catch (\Error $e) {
32+
echo $e->getMessage() . "\n";
33+
}
34+
try {
35+
var_dump($d->rewind());
36+
} catch (\Error $e) {
37+
echo $e->getMessage() . "\n";
38+
}
39+
try {
40+
var_dump($d->close());
41+
} catch (\Error $e) {
42+
echo $e->getMessage() . "\n";
43+
}
3144

3245
?>
33-
--EXPECTF--
46+
--EXPECT--
3447
--> Try all methods with bad handle:
3548
Directory::read(): supplied argument is not a valid Directory resource
3649
Directory::rewind(): supplied argument is not a valid Directory resource
3750
Directory::close(): supplied argument is not a valid Directory resource
3851

3952
--> Try all methods with no handle:
40-
41-
Warning: Directory::read(): Unable to find my handle property in %s on line %d
42-
bool(false)
43-
44-
Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
45-
bool(false)
46-
47-
Warning: Directory::close(): Unable to find my handle property in %s on line %d
48-
bool(false)
53+
Unable to find my handle property
54+
Unable to find my handle property
55+
Unable to find my handle property

0 commit comments

Comments
 (0)