ZF-7111: Zend_Cache backward incompatible change


I've been using ZF 1.8.1 for a project, today I installed the 1.8.4 release and then my application failed to start. I'm using a cache resource in my application, and I've been using the static method Zend_Cache_Backend_File::getTmpDir() to find the path to temp directory, but after the upgrade I have this exception:

Fatal error: Call to undefined method Application_Resource_Cache::_isGoodTmpDir() in /usr/share/php/Zend/Cache/Backend.php on line 177

I inspected the Zend Framework code and found out that in 1.8.1 release, the getTmpDir() was static method (as I've used it in my code), but in 1.8.4 this method is no longer static, and is calling the _isGoodTmpDir() member method. I read the release notes of 1.8.2, 1.8.3 and 1.8.4 before this upgrade and there was no mention in changing Zend_Cache API.

is it a permanent choice to make this method an instance method? because I'm using the getTmpDir() to configure settings of my cache object, before creating it. here is my code:

           if ( $backend['adapter'] == 'File' ) {
                $cachePath = realpath( Zend_Cache_Backend_File::getTmpDir() );
                if ( isset($backendOptions['cache_dir']) ) {
                    $cachePath = realpath( (string)$backendOptions['cache_dir'] );
                    if ( !$cachePath || !file_exists($cachePath) || !is_dir($cachePath) || !is_readable($cachePath) || !is_writable($cachePath) ) {
                        throw new Exception('cache_dir is not a valid readable/writable directory. check application configurations.');
                $backendOptions['cache_dir'] = $cachePath;
            $this->_cache = Zend_Cache::factory($frontend['adapter'], $backend['adapter'], $frontendOptions, $backendOptions);

so , if this method will not be static, I should first create a dummy Zend_Cache object, and then use this method to find out temp directory for my real cache object. I think static approach was better.


you are right but if you don't set a cache_dir the call to getTmpDir() is automatic

so your piece of code is useless, isn't it ?

yep! all my path validation and stuff are automatically done in Zend_Cache object. thanks for clearing me out.

change Assignee because I'm inactive now

Is this issue still active now?

Issue was in how user used the component, or a refactored/unintentionally public piece of internal functionality. Not an issue for resolution within the source code.