Glob::glob() should throw an exception on error #4353

Merged
merged 1 commit into from Apr 29, 2013

Projects

None yet

3 participants

@marc-mabe
Member

this fixes #3949.

It also makes the second argument $flags optional.

Please note: This could be a BC break as Glob::glob() no longer returns false on error and instead throws a Zend\Stdlib\Exception\RuntimeException but the ZF2 doesn't check against false.

@DASPRiD DASPRiD commented on the diff Apr 29, 2013
library/Zend/Stdlib/Glob.php
@@ -75,7 +80,13 @@ protected static function systemGlob($pattern, $flags)
$globFlags = 0;
}
- return glob($pattern, $globFlags);
+ ErrorHandler::start();
+ $res = glob($pattern, $globFlags);
+ $err = ErrorHandler::stop();
+ if ($res === false) {
@DASPRiD
DASPRiD Apr 29, 2013 Member

False may actually not directly be an error. Best is to just return an array() on false if no error is thrown. Just throw an exception if there was actually an error.

@marc-mabe
marc-mabe Apr 29, 2013 Member

glob returns false in cases of an error only. empty results, unreadable folders by permission ... are resulting in an empty array. tested with PHP-5.3.10 on Ubuntu12.

@weierophinney weierophinney added a commit that referenced this pull request Apr 29, 2013
@weierophinney weierophinney Merge branch 'hotfix/4353' into develop
Close #4353
Fixes #3949
b25f7c0
@weierophinney weierophinney merged commit ef307f3 into zendframework:develop Apr 29, 2013

1 check failed

default The Travis build failed
Details
@weierophinney weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge pull request zendframework/zendframework#4353 from marc-mabe/ho…
…tfix/3949

Glob::glob() should throw an exception on error

Conflicts:
	library/Zend/Stdlib/Glob.php
e44cbd8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment