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

Issue Type: Bug Created: 2010-03-22T08:07:21.000+0000 Last Updated: 2010-03-25T10:09:42.000+0000 Status: Closed Fix version(s): - 1.10.3 (01/Apr/10)

Reporter: Anton Stöckl (flytony) Assignee: Marc Bennewitz (private) (mabe) Tags: - Zend_Cache

Related issues: Attachments:



<pre class="highlight">
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

<pre class="highlight">
if ($glob === false) {
     return true;

will return true and

line 808

<pre class="highlight">
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

<pre class="highlight">
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


Posted by Renan de Lima (renanbr) on 2010-03-22T08:27:32.000+0000

just a code styling change to understand this issue

Posted by Marc Bennewitz (private) (mabe) on 2010-03-24T10:16:10.000+0000

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 says: {quote} On some systems it is impossible to distinguish between empty match and an error. {quote}

Can you please test it.

Posted by Anton Stöckl (flytony) on 2010-03-24T10:32:54.000+0000

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

Posted by Anton Stöckl (flytony) on 2010-03-25T02:27:49.000+0000

Just tested your changes -> works fine for me! :-)

Cheers, Anton

Posted by Marc Bennewitz (private) (mabe) on 2010-03-25T10:09:41.000+0000

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

Thanks for testing Anton.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.