mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 19:34:27 +02:00
- observe umask settings when setting file permissions
- avoide unneeded cache file creation for subtemplates which did occur in some situations
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
11/18/2009
|
||||
- observe umask settings when setting file permissions
|
||||
- avoide unneeded cache file creation for subtemplates which did occur in some situations
|
||||
|
||||
11/17/2009
|
||||
- sanitize compile_id and cache_id (replace illegal chars with _)
|
||||
- use _dir_perms and _file_perms properties at file creation
|
||||
|
@@ -136,7 +136,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
// caching enabled
|
||||
public $caching = false;
|
||||
// merge compiled includea
|
||||
public $merge_compiled_includes = true;
|
||||
public $merge_compiled_includes = false;
|
||||
// cache lifetime
|
||||
public $cache_lifetime = 0;
|
||||
// force cache file creation
|
||||
|
@@ -101,7 +101,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
// default for included templates
|
||||
if ($this->compiler->template->caching && !$this->compiler->nocache) {
|
||||
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||
$_caching = 9999;
|
||||
} else {
|
||||
$_caching = SMARTY_CACHING_OFF;
|
||||
}
|
||||
@@ -113,6 +113,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
|
||||
if (isset($_attr['cache_lifetime'])) {
|
||||
$_cache_lifetime = $_attr['cache_lifetime'];
|
||||
$this->compiler->tag_nocache = true;
|
||||
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||
}
|
||||
if (isset($_attr['nocache'])) {
|
||||
if ($_attr['nocache'] == 'true') {
|
||||
@@ -124,6 +125,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
|
||||
if ($_attr['caching'] == 'true') {
|
||||
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||
} else {
|
||||
$this->compiler->tag_nocache = true;
|
||||
$_caching = SMARTY_CACHING_OFF;
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_TemplateBase {
|
||||
public static function end_compile($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['compile_time'] = self::get_time() - self::$template_data[$key]['start_time'];
|
||||
self::$template_data[$key]['compile_time'] += self::get_time() - self::$template_data[$key]['start_time'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_TemplateBase {
|
||||
public static function end_render($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['render_time'] = self::get_time() - self::$template_data[$key]['start_time'];
|
||||
self::$template_data[$key]['render_time'] += self::get_time() - self::$template_data[$key]['start_time'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_TemplateBase {
|
||||
public static function end_cache($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['cache_time'] = self::get_time() - self::$template_data[$key]['start_time'];
|
||||
self::$template_data[$key]['cache_time'] += self::get_time() - self::$template_data[$key]['start_time'];
|
||||
}
|
||||
/**
|
||||
* Opens a window for the Smarty Debugging Consol and display the data
|
||||
|
@@ -372,7 +372,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
if ($this->getCachedTimestamp() === false) {
|
||||
return $this->isCached;
|
||||
}
|
||||
if ($this->caching === SMARTY_CACHING_LIFETIME_SAVED || ($this->caching && (time() <= ($this->getCachedTimestamp() + $this->cache_lifetime) || $this->cache_lifetime < 0))) {
|
||||
if ($this->caching === SMARTY_CACHING_LIFETIME_SAVED || ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT && (time() <= ($this->getCachedTimestamp() + $this->cache_lifetime) || $this->cache_lifetime < 0))) {
|
||||
if ($this->smarty->debugging) {
|
||||
Smarty_Internal_Debug::start_cache($this);
|
||||
}
|
||||
@@ -481,7 +481,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
Smarty_Internal_Debug::end_render($this);
|
||||
}
|
||||
// write to cache when nessecary
|
||||
if (!$this->isEvaluated() && $this->caching) {
|
||||
if (!$this->isEvaluated() && ($this->caching == SMARTY_CACHING_LIFETIME_SAVED || $this->caching == SMARTY_CACHING_LIFETIME_CURRENT)) {
|
||||
if ($this->smarty->debugging) {
|
||||
Smarty_Internal_Debug::start_cache($this);
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ class Smarty_Internal_Write_File {
|
||||
*/
|
||||
public static function writeFile($_filepath, $_contents, $smarty)
|
||||
{
|
||||
$old_umask = umask(0);
|
||||
$_dirpath = dirname($_filepath);
|
||||
// if subdirs, create dir structure
|
||||
if ($_dirpath !== '.' && !file_exists($_dirpath)) {
|
||||
@@ -29,6 +30,7 @@ class Smarty_Internal_Write_File {
|
||||
$_tmp_file = tempnam($_dirpath, 'wrt');
|
||||
|
||||
if (!file_put_contents($_tmp_file, $_contents)) {
|
||||
umask($old_umask);
|
||||
throw new Exception("unable to write file {$_tmp_file}");
|
||||
return false;
|
||||
}
|
||||
@@ -39,7 +41,7 @@ class Smarty_Internal_Write_File {
|
||||
rename($_tmp_file, $_filepath);
|
||||
// set file permissions
|
||||
chmod($_filepath, $smarty->_file_perms);
|
||||
|
||||
umask($old_umask);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user