Skip to content

Commit

Permalink
Catch LogicException for Rewind and fix CP errors
Browse files Browse the repository at this point in the history
The rewind method is, as the valid() method, affected by an issue
with the GlobIterator where it throws a LogicException if the dataset
is empty (https://bugs.php.net/bug.php?id=55701).

This exception should be caught and correctly returned as this will
interfere with foreach statements at the invoker.

In addition to the above have several copy-paste errors in the 
DocBlocks been fixed.
  • Loading branch information
mvriel committed Mar 30, 2013
1 parent 876a18f commit bf89533
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions library/Zend/Cache/Storage/Adapter/FilesystemIterator.php
Expand Up @@ -16,9 +16,9 @@ class FilesystemIterator implements IteratorInterface
{

/**
* The apc storage instance
* The Filesystem storage instance
*
* @var Apc
* @var Filesystem
*/
protected $storage;

Expand Down Expand Up @@ -89,7 +89,7 @@ public function getMode()
* Set iterator mode
*
* @param int $mode
* @return ApcIterator Fluent interface
* @return FilesystemIterator Fluent interface
*/
public function setMode($mode)
{
Expand Down Expand Up @@ -164,10 +164,17 @@ public function valid()
/**
* Rewind the Iterator to the first element.
*
* @return void
* @return bool false if the operation failed.
*/
public function rewind()
{
return $this->globIterator->rewind();
try {
return $this->globIterator->rewind();
} catch (\LogicException $e) {
// @link https://bugs.php.net/bug.php?id=55701
// GlobIterator throws LogicException with message
// 'The parent constructor was not called: the object is in an invalid state'
return false;
}
}
}

0 comments on commit bf89533

Please sign in to comment.