ZF-12109: Zend Cache - Custom backend via config .ini file is not possible.
Description
It is currently not possible to use a custom class when setting cache options via the config .ini file.
A normal config setting would look like this :
resources.cachemanager.default.backend.name = "Apc"
To use a custom class one needs to set the option "customBackendNaming" so the setting would then look like this :
resources.cachemanager.default.backend.name = "My_Cache_Backend_Apc" resources.cachemanager.default.backend.customBackendNaming = true
The issue occurs in the Zend_Cache_Manager class. The problem is that the customBackendNaming option is never passed to the Zend_Cache::factory method. This is because this class assumes the only options from the config .ini file will be a key called "name" and a key called "options" and other settings are filtered out in the _mergeOptions method.
Below I have posted the Zend_Cache_Manager::_mergeOptions method with a proposed fix.
/** * Simple method to merge two configuration arrays * * @param array $current * @param array $options * @return array */ protected function _mergeOptions(array $current, array $options) { if (isset($options['frontend']['name'])) { $current['frontend']['name'] = $options['frontend']['name']; }
if (isset($options['backend']['name'])) {
$current['backend']['name'] = $options['backend']['name'];
}
if (isset($options['frontend']['options'])) {
foreach ($options['frontend']['options'] as $key=>$value) {
$current['frontend']['options'][$key] = $value;
}
}
if (isset($options['backend']['options'])) {
foreach ($options['backend']['options'] as $key=>$value) {
$current['backend']['options'][$key] = $value;
}
}
// BEGIN EDIT
if (isset($options['frontend']['customFrontendNaming'])) {
$current['frontend']['customFrontendNaming'] = $options['frontend']['customFrontendNaming'];
}
if (isset($options['backend']['customBackendNaming'])) {
$current['backend']['customBackendNaming'] = $options['backend']['customBackendNaming'];
}
// END EDIT
return $current;
}
Comments
No comments to display