Issues

ZF-9737: Zend_Applicaton_Resource_Cachemanager cannot create a Zend Server backend

Issue Type: Bug Created: 2010-04-23T08:03:37.000+0000 Last Updated: 2010-07-17T12:40:46.000+0000 Status: Closed Fix version(s): - 1.10.7 (28/Jul/10)

Reporter: Kevin Schroeder (kschroeder) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Application_Resource

Related issues: Attachments: - ZF-9737.patch

Description

When using the cache manager via a Zend_Application resource, the Zend Server backends are not able to be loaded.

application.ini resources.cachemanager.youtube.frontend.name = Core resources.cachemanager.youtube.frontend.options.automatic_serialization = true resources.cachemanager.youtube.backend.name = ZendServer_Disk

This causes the backend to be named ZendserverDisk, which does not exist. Changing the application.ini file to

resources.cachemanager.youtube.backend.name = Zend_Cache_Backend_ZendServer_Disk

does not work either because the $customBackendNaming value is not available when calling Zend_Cache_Manager::getCache()

Comments

Posted by Kevin Schroeder (kschroeder) on 2010-04-23T09:14:18.000+0000

I have created a fix for this issue. It does not solve the naming problem, but it does allow for the custom naming and autoloading arguments to be passed to the Zend_Cache::factory call. That way you can at least explicitly create that backend.

Index: tests/Zend/Application/Resource/CacheManagerTest.php

--- tests/Zend/Application/Resource/CacheManagerTest.php (revision 21970) +++ tests/Zend/Application/Resource/CacheManagerTest.php (working copy) @@ -182,6 +182,31 @@ $cache = $manager->getCache('foo'); $this->assertTrue($cache instanceof Zend_Cache_Core); } +

  • public function testNamespacedBackend() + { + $options = array( + 'foo' => array( + 'frontend' => array( + 'name' => 'Zend_Cache_Core', + 'options' => array( + 'lifetime' => 7200, + 'customFrontendNaming' => true + ), + ), + 'backend' => array( + 'name' => 'Zend_Cache_Backend_ZendServer_Disk', + 'options' => array( + 'customBackendNaming' => true + ) + ), + ), + ); + $resource = new Zend_Application_Resource_Cachemanager($options); + $manager = $resource->init(); + $cache = $manager->getCache('foo')->getBackend(); + $this->assertTrue($cache instanceof Zend_Cache_Backend_ZendServer_Disk);
  • } }

if (PHPUnit_MAIN_METHOD == 'Zend_Application_Resource_CacheManagerTest::main') {

Index: library/Zend/Cache/Manager.php

--- library/Zend/Cache/Manager.php (revision 21970) +++ library/Zend/Cache/Manager.php (working copy) @@ -171,7 +171,10 @@ $this->_optionTemplates[$name]['frontend']['name'], $this->_optionTemplates[$name]['backend']['name'], isset($this->_optionTemplates[$name]['frontend']['options']) ? $this->_optionTemplates[$name]['frontend']['options'] : array(), - isset($this->_optionTemplates[$name]['backend']['options']) ? $this->_optionTemplates[$name]['backend']['options'] : array() + isset($this->_optionTemplates[$name]['backend']['options']) ? $this->_optionTemplates[$name]['backend']['options'] : array(), + isset($this->_optionTemplates[$name]['frontend']['options']['customFrontendNaming']) ? $this->_optionTemplates[$name]['frontend']['options']['customFrontendNaming'] : false, + isset($this->_optionTemplates[$name]['backend']['options']['customBackendNaming']) ? $this->_optionTemplates[$name]['backend']['options']['customBackendNaming'] : false, + isset($this->_optionTemplates[$name]['backend']['options']['autoload']) ? $this->_optionTemplates[$name]['backend']['options']['autoload'] : false ); return $this->_caches[$name]; }

Index: library/Zend/Cache.php

--- library/Zend/Cache.php (revision 21970) +++ library/Zend/Cache.php (working copy) @@ -143,6 +143,7 @@ } if (!$autoload) { $file = str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php'; +
if (!(self::_isReadable($file))) { self::throwException("file $file not found in include_path"); }

Posted by Alexander Veremyev (alexander) on 2010-04-23T11:12:31.000+0000

unit test is already included added within [ZF-9738] fix, updated patch is attached.

Patch looks good, but it's necessary to check if it's the best way to set additional parameters through backend/frontend option arrays

Posted by Alexander Veremyev (alexander) on 2010-04-23T12:37:53.000+0000

Done.

Provided patch is changed a bit.

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-04-23T12:41:20.000+0000

Thanks for fixing. Reopening however due to missing unit tests.

Posted by Ramon Henrique Ornelas (ramon) on 2010-04-23T13:08:35.000+0000

@Alexander In your commit Zend_Cache_Manager, corrected ZF-9134 and ZF-9240.

Thanks ;)

Posted by Ramon Henrique Ornelas (ramon) on 2010-07-17T12:40:46.000+0000

Test added in trunk r22617, applied to release 1.10 r22618.

Have you found an issue?

See the Overview section for more details.

Copyright

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

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

Contacts