mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- Introduced $compile_id class variable.
- Fixed a situation where if $cache_id and $compile_id were both null they were passed to auto functions as empty string instead of null.
This commit is contained in:
4
NEWS
4
NEWS
@@ -1,4 +1,6 @@
|
|||||||
- fixed bug in _rm_auto with catendated null values (Monte, Thomas Pundt)
|
- introduced $compile_id class variable that can be used to set persistent
|
||||||
|
compile identifier across multiple display calls. (Andrei)
|
||||||
|
- fixed bug in _rm_auto with catenated null values. (Monte, Thomas Pundt)
|
||||||
- added $smarty.section.* syntax for accessing section properties. (Andrei)
|
- added $smarty.section.* syntax for accessing section properties. (Andrei)
|
||||||
- added custom cache handling function ability. (Monte)
|
- added custom cache handling function ability. (Monte)
|
||||||
- added assign attribute to insert, fetch, math, and counter functions,
|
- added assign attribute to insert, fetch, math, and counter functions,
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Project: Smarty: the PHP compiling template engine
|
* Project: Smarty: the PHP compiling template engine
|
||||||
* File: Smarty.class.php
|
* File: Smarty.class.php
|
||||||
* Author: Monte Ohrt <monte@ispi.net>
|
* Author: Monte Ohrt <monte@ispi.net>
|
||||||
@@ -181,6 +181,8 @@ class Smarty
|
|||||||
// registered, similar to variables_order
|
// registered, similar to variables_order
|
||||||
// in php.ini
|
// in php.ini
|
||||||
|
|
||||||
|
var $compile_id = null; // persistent compile identifier
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* END SMARTY CONFIGURATION SECTION */
|
/* END SMARTY CONFIGURATION SECTION */
|
||||||
/* There should be no need to touch anything below this line. */
|
/* There should be no need to touch anything below this line. */
|
||||||
@@ -417,11 +419,19 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null)
|
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null)
|
||||||
{
|
{
|
||||||
|
if (!isset($compile_id))
|
||||||
|
$compile_id = $this->compile_id;
|
||||||
|
|
||||||
|
if (isset($compile_id) && isset($cache_id))
|
||||||
|
$auto_id = $compile_id . $cache_id;
|
||||||
|
else
|
||||||
|
$auto_id = null;
|
||||||
|
|
||||||
if (!empty($this->cache_handler_func)) {
|
if (!empty($this->cache_handler_func)) {
|
||||||
$funcname = $this->cache_handler_func;
|
$funcname = $this->cache_handler_func;
|
||||||
return $funcname('clear', $this, $dummy, $tpl_file, $cache_id, $compile_id);
|
return $funcname('clear', $this, $dummy, $tpl_file, $cache_id, $compile_id);
|
||||||
} else {
|
} else {
|
||||||
return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
return $this->_rm_auto($this->cache_dir, $tpl_file, $auto_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,6 +460,8 @@ class Smarty
|
|||||||
if (!$this->caching)
|
if (!$this->caching)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!isset($compile_id))
|
||||||
|
$compile_id = $this->compile_id;
|
||||||
return $this->_read_cache_file($tpl_file, $cache_id, $compile_id, $results);
|
return $this->_read_cache_file($tpl_file, $cache_id, $compile_id, $results);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,6 +483,8 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function clear_compiled_tpl($tpl_file = null, $compile_id = null)
|
function clear_compiled_tpl($tpl_file = null, $compile_id = null)
|
||||||
{
|
{
|
||||||
|
if (!isset($compile_id))
|
||||||
|
$compile_id = $this->compile_id;
|
||||||
return $this->_rm_auto($this->compile_dir, $tpl_file, $compile_id);
|
return $this->_rm_auto($this->compile_dir, $tpl_file, $compile_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +529,9 @@ class Smarty
|
|||||||
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_compile_id = $smarty_compile_id;
|
if (!isset($compile_id))
|
||||||
|
$compile_id = $this->compile_id;
|
||||||
|
|
||||||
$this->_inclusion_depth = 0;
|
$this->_inclusion_depth = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -1171,10 +1187,10 @@ function _run_insert_handler($args)
|
|||||||
if (!is_dir($auto_base))
|
if (!is_dir($auto_base))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (empty($auto_source)) {
|
if (!isset($auto_source)) {
|
||||||
$res = $this->_rmdir($auto_base, 0);
|
$res = $this->_rmdir($auto_base, 0);
|
||||||
} else {
|
} else {
|
||||||
if (!empty($auto_id)) {
|
if (isset($auto_id)) {
|
||||||
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
|
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
|
||||||
$res = is_file($tname) && unlink( $tname);
|
$res = is_file($tname) && unlink( $tname);
|
||||||
} else {
|
} else {
|
||||||
@@ -1253,7 +1269,12 @@ function _run_insert_handler($args)
|
|||||||
return $funcname('write', $this, $results, $tpl_file, $cache_id, $compile_id);
|
return $funcname('write', $this, $results, $tpl_file, $cache_id, $compile_id);
|
||||||
} else {
|
} else {
|
||||||
// use local cache file
|
// use local cache file
|
||||||
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
if (isset($compile_id) && isset($cache_id))
|
||||||
|
$auto_id = $compile_id . $cache_id;
|
||||||
|
else
|
||||||
|
$auto_id = null;
|
||||||
|
|
||||||
|
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $auto_id);
|
||||||
$this->_write_file($cache_file, $results, true);
|
$this->_write_file($cache_file, $results, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1279,8 +1300,12 @@ function _run_insert_handler($args)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// use local file cache
|
// use local file cache
|
||||||
|
if (isset($compile_id) && isset($cache_id))
|
||||||
|
$auto_id = $compile_id . $cache_id;
|
||||||
|
else
|
||||||
|
$auto_id = null;
|
||||||
|
|
||||||
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $auto_id);
|
||||||
$results = $this->_read_file($cache_file);
|
$results = $this->_read_file($cache_file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Project: Smarty: the PHP compiling template engine
|
* Project: Smarty: the PHP compiling template engine
|
||||||
* File: Smarty.class.php
|
* File: Smarty.class.php
|
||||||
* Author: Monte Ohrt <monte@ispi.net>
|
* Author: Monte Ohrt <monte@ispi.net>
|
||||||
@@ -181,6 +181,8 @@ class Smarty
|
|||||||
// registered, similar to variables_order
|
// registered, similar to variables_order
|
||||||
// in php.ini
|
// in php.ini
|
||||||
|
|
||||||
|
var $compile_id = null; // persistent compile identifier
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* END SMARTY CONFIGURATION SECTION */
|
/* END SMARTY CONFIGURATION SECTION */
|
||||||
/* There should be no need to touch anything below this line. */
|
/* There should be no need to touch anything below this line. */
|
||||||
@@ -417,11 +419,19 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null)
|
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null)
|
||||||
{
|
{
|
||||||
|
if (!isset($compile_id))
|
||||||
|
$compile_id = $this->compile_id;
|
||||||
|
|
||||||
|
if (isset($compile_id) && isset($cache_id))
|
||||||
|
$auto_id = $compile_id . $cache_id;
|
||||||
|
else
|
||||||
|
$auto_id = null;
|
||||||
|
|
||||||
if (!empty($this->cache_handler_func)) {
|
if (!empty($this->cache_handler_func)) {
|
||||||
$funcname = $this->cache_handler_func;
|
$funcname = $this->cache_handler_func;
|
||||||
return $funcname('clear', $this, $dummy, $tpl_file, $cache_id, $compile_id);
|
return $funcname('clear', $this, $dummy, $tpl_file, $cache_id, $compile_id);
|
||||||
} else {
|
} else {
|
||||||
return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
return $this->_rm_auto($this->cache_dir, $tpl_file, $auto_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,6 +460,8 @@ class Smarty
|
|||||||
if (!$this->caching)
|
if (!$this->caching)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!isset($compile_id))
|
||||||
|
$compile_id = $this->compile_id;
|
||||||
return $this->_read_cache_file($tpl_file, $cache_id, $compile_id, $results);
|
return $this->_read_cache_file($tpl_file, $cache_id, $compile_id, $results);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,6 +483,8 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function clear_compiled_tpl($tpl_file = null, $compile_id = null)
|
function clear_compiled_tpl($tpl_file = null, $compile_id = null)
|
||||||
{
|
{
|
||||||
|
if (!isset($compile_id))
|
||||||
|
$compile_id = $this->compile_id;
|
||||||
return $this->_rm_auto($this->compile_dir, $tpl_file, $compile_id);
|
return $this->_rm_auto($this->compile_dir, $tpl_file, $compile_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +529,9 @@ class Smarty
|
|||||||
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_compile_id = $smarty_compile_id;
|
if (!isset($compile_id))
|
||||||
|
$compile_id = $this->compile_id;
|
||||||
|
|
||||||
$this->_inclusion_depth = 0;
|
$this->_inclusion_depth = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -1171,10 +1187,10 @@ function _run_insert_handler($args)
|
|||||||
if (!is_dir($auto_base))
|
if (!is_dir($auto_base))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (empty($auto_source)) {
|
if (!isset($auto_source)) {
|
||||||
$res = $this->_rmdir($auto_base, 0);
|
$res = $this->_rmdir($auto_base, 0);
|
||||||
} else {
|
} else {
|
||||||
if (!empty($auto_id)) {
|
if (isset($auto_id)) {
|
||||||
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
|
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
|
||||||
$res = is_file($tname) && unlink( $tname);
|
$res = is_file($tname) && unlink( $tname);
|
||||||
} else {
|
} else {
|
||||||
@@ -1253,7 +1269,12 @@ function _run_insert_handler($args)
|
|||||||
return $funcname('write', $this, $results, $tpl_file, $cache_id, $compile_id);
|
return $funcname('write', $this, $results, $tpl_file, $cache_id, $compile_id);
|
||||||
} else {
|
} else {
|
||||||
// use local cache file
|
// use local cache file
|
||||||
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
if (isset($compile_id) && isset($cache_id))
|
||||||
|
$auto_id = $compile_id . $cache_id;
|
||||||
|
else
|
||||||
|
$auto_id = null;
|
||||||
|
|
||||||
|
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $auto_id);
|
||||||
$this->_write_file($cache_file, $results, true);
|
$this->_write_file($cache_file, $results, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1279,8 +1300,12 @@ function _run_insert_handler($args)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// use local file cache
|
// use local file cache
|
||||||
|
if (isset($compile_id) && isset($cache_id))
|
||||||
|
$auto_id = $compile_id . $cache_id;
|
||||||
|
else
|
||||||
|
$auto_id = null;
|
||||||
|
|
||||||
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $auto_id);
|
||||||
$results = $this->_read_file($cache_file);
|
$results = $this->_read_file($cache_file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user