- optimize nocache hash processing

This commit is contained in:
uwetews
2015-08-19 01:18:25 +02:00
parent 8292a3581c
commit 7935b181fb
4 changed files with 23 additions and 12 deletions
+16 -2
View File
@@ -65,6 +65,13 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
*/
public $source = null;
/**
* Nocache hash codes of processed compiled templates
*
* @var array
*/
public $hashes = array();
/**
* create Cached Object container
*
@@ -264,14 +271,21 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
* Sanitize content and write it to cache resource
*
* @param Smarty_Internal_Template $_template
* @param string $content
* @param bool $no_output_filter
*
* @throws SmartyException
* @throws \SmartyException
*/
public function updateCache(Smarty_Internal_Template $_template, $no_output_filter)
{
$content = ob_get_clean();
unset($this->hashes[$_template->compiled->nocache_hash]);
if (!empty($this->hashes)) {
$hash_array = array();
foreach ($this->hashes as $hash => $foo) {
$hash_array[] = "/{$hash}/";
}
$content = preg_replace($hash_array, $_template->compiled->nocache_hash, $content);
}
$_template->cached->has_nocache_code = false;
// get text between non-cached items
$cache_split = preg_split("!/\*%%SmartyNocache:{$_template->compiled->nocache_hash}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%\*/!s", $content);