ZF-10682: Undefined offset: 0 Notice in Zend_Cache_Frontend_File


PHP Notice is being reported in Zend_Cache_Frontend_File and 'master_file' option left blank if 'master_files' options array has non-numeric indexes, or if index 0 (zero) does not exist. This occurs when a string-indexed array is being given as the third argument to Zend_Cache::factory() or when using cache manager XML config, for instance:

my_file.xml (...)

Affects all versions, including trunk.

How to reproduce:

<?php include 'Zend/Cache.php'; Zend_Cache::factory( 'File', 'File', array( 'master_files' => array( 'my_file' => 'my_file.xml', ), ), array() ); ?>

$ php test.php PHP Notice: Undefined offset: 0 in Zend/Cache/Frontend/File.php on line 107


replace Zend/Cache/Frontend/File.php line 107:

$this->_specificOptions['master_file'] = $masterFiles[0]; // to keep a compatibility


$this->_specificOptions['master_file'] = reset($masterFiles); // to keep a compatibility


Thank you for your report.

fixed in r23329 (trunk) - can you please test it again before I'll commit to 1.11 branch


Thanks for looking into it. The notice is gone and the trunk version seems to work as expected.

fixed in r23329 (trunk) and r23330 (1.11 branch)

Hi mabe

I think that have of typo in line 122. Current code:

$this->_specificOptions['master_files'] = $masterFile;

Should be:

$this->_specificOptions['master_file'] = $masterFile;

Thanks advance Ramon