_cacheFileName = $GLOBALS['sugar_config']['external_cache_filename']; } /** * @see SugarCacheAbstract::__destruct() * * For this backend, we'll write the SugarCacheFile::$localCache array serialized out to a file */ public function __destruct() { parent::__destruct(); if ( $this->_cacheChanged ) sugar_file_put_contents(sugar_cached($this->_cacheFileName), serialize($this->_localStore)); } /** * This is needed to prevent unserialize vulnerability */ public function __wakeup() { // clean all properties foreach(get_object_vars($this) as $k => $v) { $this->$k = null; } throw new Exception("Not a serializable object"); } /** * @see SugarCacheAbstract::_setExternal() * * Does nothing; we write to cache on destroy */ protected function _setExternal( $key, $value ) { $this->_cacheChanged = true; } /** * @see SugarCacheAbstract::_getExternal() */ protected function _getExternal( $key ) { // load up the external cache file if ( sugar_is_file($cachedfile = sugar_cached($this->_cacheFileName))) $this->localCache = unserialize(file_get_contents($cachedfile)); if ( isset($this->_localStore[$key]) ) return $this->_localStore[$key]; return null; } /** * @see SugarCacheAbstract::_clearExternal() * * Does nothing; we write to cache on destroy */ protected function _clearExternal( $key ) { $this->_cacheChanged = true; } /** * @see SugarCacheAbstract::_resetExternal() * * Does nothing; we write to cache on destroy */ protected function _resetExternal() { $this->_cacheChanged = true; } }