diff --git a/lib/Cake/Cache/CacheEngine.php b/lib/Cake/Cache/CacheEngine.php index 7b285e041..3b1b74e67 100644 --- a/lib/Cake/Cache/CacheEngine.php +++ b/lib/Cake/Cache/CacheEngine.php @@ -170,7 +170,7 @@ abstract class CacheEngine { $prefix = vsprintf($this->_groupPrefix, $this->groups()); } - $key = Inflector::underscore(str_replace(array(DS, '/', '.'), '_', strval($key))); + $key = preg_replace('/[\s]+/', '_', strtolower(trim(str_replace(array(DS, '/', '.'), '_', strval($key))))); return $prefix . $key; } diff --git a/lib/Cake/Cache/Engine/ApcEngine.php b/lib/Cake/Cache/Engine/ApcEngine.php index d9c155abb..7b93cbb0c 100644 --- a/lib/Cake/Cache/Engine/ApcEngine.php +++ b/lib/Cake/Cache/Engine/ApcEngine.php @@ -44,7 +44,11 @@ class ApcEngine extends CacheEngine { * @see CacheEngine::__defaults */ public function init($settings = array()) { - parent::init(array_merge(array('engine' => 'Apc', 'prefix' => Inflector::slug(APP_DIR) . '_'), $settings)); + if (!isset($settings['prefix'])) { + $settings['prefix'] = Inflector::slug(APP_DIR) . '_'; + } + $settings += array('engine' => 'Apc'); + parent::init($settings); return function_exists('apc_dec'); } diff --git a/lib/Cake/Cache/Engine/FileEngine.php b/lib/Cake/Cache/Engine/FileEngine.php index 23e043b98..16c894c7f 100644 --- a/lib/Cake/Cache/Engine/FileEngine.php +++ b/lib/Cake/Cache/Engine/FileEngine.php @@ -68,13 +68,16 @@ class FileEngine extends CacheEngine { * @return boolean True if the engine has been successfully initialized, false if not */ public function init($settings = array()) { - parent::init(array_merge( - array( - 'engine' => 'File', 'path' => CACHE, 'prefix' => 'cake_', 'lock' => true, - 'serialize' => true, 'isWindows' => false, 'mask' => 0664 - ), - $settings - )); + $settings += array( + 'engine' => 'File', + 'path' => CACHE, + 'prefix' => 'cake_', + 'lock' => true, + 'serialize' => true, + 'isWindows' => false, + 'mask' => 0664 + ); + parent::init($settings); if (DS === '\\') { $this->settings['isWindows'] = true; diff --git a/lib/Cake/Cache/Engine/MemcacheEngine.php b/lib/Cake/Cache/Engine/MemcacheEngine.php index 4f588bf50..4729de358 100644 --- a/lib/Cake/Cache/Engine/MemcacheEngine.php +++ b/lib/Cake/Cache/Engine/MemcacheEngine.php @@ -66,19 +66,21 @@ class MemcacheEngine extends CacheEngine { if (!class_exists('Memcache')) { return false; } - parent::init(array_merge(array( + if (!isset($settings['prefix'])) { + $settings['prefix'] = Inflector::slug(APP_DIR) . '_'; + } + $settings += array( 'engine' => 'Memcache', - 'prefix' => Inflector::slug(APP_DIR) . '_', 'servers' => array('127.0.0.1'), 'compress' => false, 'persistent' => true - ), $settings) ); + parent::init($settings); if ($this->settings['compress']) { $this->settings['compress'] = MEMCACHE_COMPRESSED; } - if (!is_array($this->settings['servers'])) { + if (is_string($this->settings['servers'])) { $this->settings['servers'] = array($this->settings['servers']); } if (!isset($this->_Memcache)) { diff --git a/lib/Cake/Cache/Engine/WincacheEngine.php b/lib/Cake/Cache/Engine/WincacheEngine.php index 6482135c1..542172c0c 100644 --- a/lib/Cake/Cache/Engine/WincacheEngine.php +++ b/lib/Cake/Cache/Engine/WincacheEngine.php @@ -45,10 +45,11 @@ class WincacheEngine extends CacheEngine { * @see CacheEngine::__defaults */ public function init($settings = array()) { - parent::init(array_merge(array( - 'engine' => 'Wincache', - 'prefix' => Inflector::slug(APP_DIR) . '_'), - $settings)); + if (!isset($settings['prefix'])) { + $settings['prefix'] = Inflector::slug(APP_DIR) . '_'; + } + $settings += array('engine' => 'Wincache'); + parent::init($settings); return function_exists('wincache_ucache_info'); } diff --git a/lib/Cake/Cache/Engine/XcacheEngine.php b/lib/Cake/Cache/Engine/XcacheEngine.php index 35da1810d..c5f3b430f 100644 --- a/lib/Cake/Cache/Engine/XcacheEngine.php +++ b/lib/Cake/Cache/Engine/XcacheEngine.php @@ -45,13 +45,15 @@ class XcacheEngine extends CacheEngine { * @return boolean True if the engine has been successfully initialized, false if not */ public function init($settings = array()) { - parent::init(array_merge(array( + if (!isset($settings['prefix'])) { + $settings['prefix'] = Inflector::slug(APP_DIR) . '_'; + } + $settings += array( 'engine' => 'Xcache', - 'prefix' => Inflector::slug(APP_DIR) . '_', 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password' - ), $settings) ); + parent::init($settings); return function_exists('xcache_info'); }