com php-src: Promote Directory handler warning to error: 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/Directory Class_error_001.phpt

From: Date: Thu, 29 Aug 2019 21:08:25 +0000
Subject: com php-src: Promote Directory handler warning to error: 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/Directory Class_error_001.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-108142@lists.php.net to get a copy of this message
Commit: dd10e70d0c46e006be47d77b793a95729d2bb675 Author: George Peter Banyard <girgias@php.net> Thu, 29 Aug 2019 01:30:13 +0200 Parents: 0d8a399afad4b8c3d1cf918437ce1b1b987eb362 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dd10e70d0c46e006be47d77b793a95729d2bb675 Log: Promote Directory handler warning to error Changed paths: M ext/standard/dir.c M ext/standard/tests/directory/DirectoryClass_basic_001.phpt M ext/standard/tests/directory/DirectoryClass_error_001-mb.phpt M ext/standard/tests/directory/DirectoryClass_error_001.phpt Diff: diff --git a/ext/standard/dir.c b/ext/standard/dir.c index f54fe69..207b02f 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -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; \ } \ } diff --git a/ext/standard/tests/directory/DirectoryClass_basic_001.phpt b/ext/standard/tests/directory/DirectoryClass_basic_001.phpt index 73aac5b..5594207 100644 --- a/ext/standard/tests/directory/DirectoryClass_basic_001.phpt +++ b/ext/standard/tests/directory/DirectoryClass_basic_001.phpt @@ -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 diff --git a/ext/standard/tests/directory/DirectoryClass_error_001-mb.phpt b/ext/standard/tests/directory/DirectoryClass_error_001-mb.phpt index d4d3eb9..2949bd3 100644 --- a/ext/standard/tests/directory/DirectoryClass_error_001-mb.phpt +++ b/ext/standard/tests/directory/DirectoryClass_error_001-mb.phpt @@ -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) diff --git a/ext/standard/tests/directory/DirectoryClass_error_001.phpt b/ext/standard/tests/directory/DirectoryClass_error_001.phpt index 3ff3370..1a8bbf3 100644 --- a/ext/standard/tests/directory/DirectoryClass_error_001.phpt +++ b/ext/standard/tests/directory/DirectoryClass_error_001.phpt @@ -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

« previous php.cvs (#108142) next »