cvs: smarty /libs/plugins core.write_cache_file.php core.write_compiled_template.php

From: Date: Fri, 30 May 2003 19:27:23 +0000
Subject: cvs: smarty /libs/plugins core.write_cache_file.php core.write_compiled_template.php
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-617@lists.php.net to get a copy of this message
mohrt Fri May 30 15:27:23 2003 EDT Modified files: /smarty/libs/plugins core.write_cache_file.php core.write_compiled_template.php Log: add discrete error checking pertaining to $cache_dir and $compile_dir, their existance and writability Index: smarty/libs/plugins/core.write_cache_file.php diff -u smarty/libs/plugins/core.write_cache_file.php:1.1 smarty/libs/plugins/core.write_cache_file.php:1.2 --- smarty/libs/plugins/core.write_cache_file.php:1.1 Thu May 8 16:21:16 2003 +++ smarty/libs/plugins/core.write_cache_file.php Fri May 30 15:27:23 2003 @@ -20,6 +20,17 @@ 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){ Index: smarty/libs/plugins/core.write_compiled_template.php diff -u smarty/libs/plugins/core.write_compiled_template.php:1.1 smarty/libs/plugins/core.write_compiled_template.php:1.2 --- smarty/libs/plugins/core.write_compiled_template.php:1.1 Thu May 8 16:21:16 2003 +++ smarty/libs/plugins/core.write_compiled_template.php Fri May 30 15:27:23 2003 @@ -15,8 +15,18 @@ */ function smarty_core_write_compiled_template($params, &$this) { + if(!@is_writable($this->compile_dir)) { + // compile_dir not writable, see if it exists + if(!@is_dir($this->compile_dir)) { + $this->trigger_error('the $compile_dir \'' . $this->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); + return false; + } + $this->trigger_error('unable to write to $compile_dir \'' . realpath($this->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); + return false; + } + $_params = array('filename' => $params['compile_path'], 'contents' => $params['template_compiled'], 'create_dirs' => true); - $this->_execute_core_function('write_file', $_params); + $this->_execute_core_function('write_file', $_params); touch($params['compile_path'], $params['template_timestamp']); return true; }

« previous php.smarty.cvs (#617) next »