Zend Framework

Zend/Cache/Backend/File.php: Error on cache clean with hashed_directory_level > 0 when at least one subdir is empty

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.10.0, 1.10.1, 1.10.2
  • Fix Version/s: 1.10.3
  • Component/s: Zend_Cache
  • Labels:
    None

Description

Zend/Cache/Backend/File.php:803

if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
     // Recursive call
     $result = array_unique(array_merge($result, $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags)));
}

If the directory $file is empty then this:

line 741

if ($glob === false) {
     return true;
}

will return true and

line 808

return array_unique($result);

will turn it to false (true or false does not matter) - problem is that this is NOT an array.

So next "array_merge()" will start a cascade of errors for each recursive call.

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/libraries/ZendFramework-1.10.0-minimal/library/Zend/Cache/Backend/File.php on line 805

Maybe there is a better solution, but this seems to work fine for me:

line 803

if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
    // Recursive call
    $tmp_result = $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags);
    if (is_array($tmp_result)) {
        $result = array_unique(array_merge($result, $tmp_result));
    }
}

Best regards, Anton


Anton Stöckl
as@pixeltalents.com
http://www.pixeltalents.com

Activity

Hide
Renan de Lima added a comment -

just a code styling change to understand this issue

Show
Renan de Lima added a comment - just a code styling change to understand this issue
Hide
Marc Bennewitz (private) added a comment -

I did some small changes in trunk on r21636.

The failure isn't on clean - it's on get*.
I don't know how I can write a test for it because the failure only generates if glob returns false.
Normally glob retuns an empty array but a note on php.net says:

On some systems it is impossible to distinguish between empty match and an error.

Can you please test it.

Show
Marc Bennewitz (private) added a comment - I did some small changes in trunk on r21636. The failure isn't on clean - it's on get*. I don't know how I can write a test for it because the failure only generates if glob returns false. Normally glob retuns an empty array but a note on php.net says:
On some systems it is impossible to distinguish between empty match and an error.
Can you please test it.
Hide
Anton Stöckl added a comment -

You are right, it's on _get!
Triggered by "clean" which sometimes makes one directory empty.

I have copied you changed File.php and will test tomorrow as I can't do today.

Cheers, Anton

Show
Anton Stöckl added a comment - You are right, it's on _get! Triggered by "clean" which sometimes makes one directory empty. I have copied you changed File.php and will test tomorrow as I can't do today. Cheers, Anton
Hide
Anton Stöckl added a comment -

Just tested your changes -> works fine for me!

Cheers, Anton

Show
Anton Stöckl added a comment - Just tested your changes -> works fine for me! Cheers, Anton
Hide
Marc Bennewitz (private) added a comment -

fixed in r21636 (trunk) and r21642 (1.10 branch)

Thanks for testing Anton.

Show
Marc Bennewitz (private) added a comment - fixed in r21636 (trunk) and r21642 (1.10 branch) Thanks for testing Anton.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: