From 65dfa12d2b60aae3541fac4a27647d25a27103e9 Mon Sep 17 00:00:00 2001 From: messju Date: Thu, 19 Jun 2003 16:32:28 +0000 Subject: [PATCH] omit is-cache_dir-writable-check if a cache_handler_function is in use --- libs/core/core.write_cache_file.php | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/libs/core/core.write_cache_file.php b/libs/core/core.write_cache_file.php index 6d6a75a5..b1ca5c4d 100644 --- a/libs/core/core.write_cache_file.php +++ b/libs/core/core.write_cache_file.php @@ -15,22 +15,12 @@ * @param string $results * @return true|null */ - + // $tpl_file, $cache_id, $compile_id, $results - + function smarty_core_write_cache_file($params, &$this) { - if(!@is_writable($this->cache_dir)) { - // cache_dir not writable, see if it exists - if(!@is_dir($this->cache_dir)) { - $this->trigger_error('the $cache_dir \'' . $this->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); - return false; - } - $this->trigger_error('unable to write to $cache_dir \'' . realpath($this->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR); - return false; - } - // put timestamp in cache header $this->_cache_info['timestamp'] = time(); if ($this->cache_lifetime > -1){ @@ -55,13 +45,24 @@ function smarty_core_write_cache_file($params, &$this) if (!empty($this->cache_handler_func)) { // use cache_handler function call_user_func_array($this->cache_handler_func, - array('write', &$this, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'])); + array('write', &$this, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'])); } else { // use local cache file + + if(!@is_writable($this->cache_dir)) { + // cache_dir not writable, see if it exists + if(!@is_dir($this->cache_dir)) { + $this->trigger_error('the $cache_dir \'' . $this->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); + return false; + } + $this->trigger_error('unable to write to $cache_dir \'' . realpath($this->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR); + return false; + } + $_auto_id = $this->_get_auto_id($params['cache_id'], $params['compile_id']); $_cache_file = $this->_get_auto_filename($this->cache_dir, $params['tpl_file'], $_auto_id); - $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true); - require_once(SMARTY_DIR . 'core/core.write_file.php'); + $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true); + require_once(SMARTY_DIR . 'core/core.write_file.php'); smarty_core_write_file($_params, $this); return true; }