add discrete error checking pertaining to $cache_dir

and $compile_dir, their existance and writability
This commit is contained in:
mohrt
2003-05-30 19:27:23 +00:00
parent f4a44e3315
commit d1c6ce0d60
2 changed files with 22 additions and 1 deletions

View File

@@ -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){

View File

@@ -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;
}