]> granicus.if.org Git - php/commitdiff
Promote Directory handler warning to error
authorGeorge Peter Banyard <girgias@php.net>
Wed, 28 Aug 2019 23:30:13 +0000 (01:30 +0200)
committerGeorge Peter Banyard <girgias@php.net>
Thu, 29 Aug 2019 21:08:25 +0000 (23:08 +0200)
ext/standard/dir.c
ext/standard/tests/directory/DirectoryClass_basic_001.phpt
ext/standard/tests/directory/DirectoryClass_error_001-mb.phpt
ext/standard/tests/directory/DirectoryClass_error_001.phpt

index f54fe69e25196d01ad4de463e6b2eef3714f2ee2..207b02f5dbb0e4f268ab80eae8b711de02be5386 100644 (file)
@@ -68,21 +68,21 @@ static zend_class_entry *dir_class_entry_ptr;
                myself = getThis(); \
                if (myself) { \
                        if ((tmp = zend_hash_str_find(Z_OBJPROP_P(myself), "handle", sizeof("handle")-1)) == NULL) { \
-                               php_error_docref(NULL, E_WARNING, "Unable to find my handle property"); \
-                               RETURN_FALSE; \
+                               zend_throw_error(NULL, "Unable to find my handle property"); \
+                               return; \
                        } \
                        if ((dirp = (php_stream *)zend_fetch_resource_ex(tmp, "Directory", php_file_le_stream())) == NULL) { \
-                               RETURN_FALSE; \
+                               return; \
                        } \
                } else { \
                        if (!DIRG(default_dir) || \
                                (dirp = (php_stream *)zend_fetch_resource(DIRG(default_dir), "Directory", php_file_le_stream())) == NULL) { \
-                               RETURN_FALSE; \
+                               return; \
                        } \
                } \
        } else { \
                if ((dirp = (php_stream *)zend_fetch_resource(Z_RES_P(id), "Directory", php_file_le_stream())) == NULL) { \
-                       RETURN_FALSE; \
+                       return; \
                } \
        }
 
index 73aac5b43c804f79c3b8073f4612b9b493276e16..559420781251093af1e1474a823d1f06a2b1b90b 100644 (file)
@@ -15,7 +15,12 @@ echo $rc;
 echo "Cannot instantiate a valid Directory directly:\n";
 $d = new Directory(getcwd());
 var_dump($d);
-var_dump($d->read());
+
+try {
+    var_dump($d->read());
+} catch (\Error $e) {
+    echo $e->getMessage() . "\n";
+}
 
 ?>
 --EXPECTF--
@@ -60,6 +65,4 @@ Class [ <internal%s> class Directory ] {
 Cannot instantiate a valid Directory directly:
 object(Directory)#%d (0) {
 }
-
-Warning: Directory::read(): Unable to find my handle property in %s on line 15
-bool(false)
+Unable to find my handle property
index d4d3eb9295871bdf1d14034a29fcfc9a598b3eaa..2949bd3381e3e91cdb47283bfacb0798588c9627 100644 (file)
@@ -29,9 +29,22 @@ try {
 echo "\n--> Try all methods with no handle:\n";
 $d = new Directory($d);
 unset($d->handle);
-var_dump($d->read());
-var_dump($d->rewind());
-var_dump($d->close());
+
+try {
+    var_dump($d->read());
+} catch (\Error $e) {
+    echo $e->getMessage() . "\n";
+}
+try {
+    var_dump($d->rewind());
+} catch (\Error $e) {
+    echo $e->getMessage() . "\n";
+}
+try {
+    var_dump($d->close());
+} catch (\Error $e) {
+    echo $e->getMessage() . "\n";
+}
 
 ?>
 --CLEAN--
@@ -40,19 +53,14 @@ $d = getcwd().PATH_SEPARATOR."私はガラスを食べられます";
 rmdir($d);
 
 ?>
---EXPECTF--
+--EXPECT--
 --> Try all methods with bad handle:
 Directory::read(): supplied argument is not a valid Directory resource
 Directory::rewind(): supplied argument is not a valid Directory resource
 Directory::close(): supplied argument is not a valid Directory resource
 
 --> Try all methods with no handle:
+Unable to find my handle property
+Unable to find my handle property
+Unable to find my handle property
 
-Warning: Directory::read(): Unable to find my handle property in %s on line %d
-bool(false)
-
-Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
-bool(false)
-
-Warning: Directory::close(): Unable to find my handle property in %s on line %d
-bool(false)
index 3ff3370e4b7430cc62faac202addf1b75a23457c..1a8bbf3c1d29c89150c5768b20fa977e5b1dcb59 100644 (file)
@@ -25,24 +25,31 @@ try {
 echo "\n--> Try all methods with no handle:\n";
 $d = new Directory(getcwd());
 unset($d->handle);
-var_dump($d->read());
-var_dump($d->rewind());
-var_dump($d->close());
+
+try {
+    var_dump($d->read());
+} catch (\Error $e) {
+    echo $e->getMessage() . "\n";
+}
+try {
+    var_dump($d->rewind());
+} catch (\Error $e) {
+    echo $e->getMessage() . "\n";
+}
+try {
+    var_dump($d->close());
+} catch (\Error $e) {
+    echo $e->getMessage() . "\n";
+}
 
 ?>
---EXPECTF--
+--EXPECT--
 --> Try all methods with bad handle:
 Directory::read(): supplied argument is not a valid Directory resource
 Directory::rewind(): supplied argument is not a valid Directory resource
 Directory::close(): supplied argument is not a valid Directory resource
 
 --> Try all methods with no handle:
-
-Warning: Directory::read(): Unable to find my handle property in %s on line %d
-bool(false)
-
-Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
-bool(false)
-
-Warning: Directory::close(): Unable to find my handle property in %s on line %d
-bool(false)
+Unable to find my handle property
+Unable to find my handle property
+Unable to find my handle property