mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
- better header for compiled includes (more in line with compiled
templates) - reuse cache_serials if a file is compiled more than once in one process (force_compile) - don't print nocache-delimiters wenn already inside process_cached_inserts()
This commit is contained in:
@@ -1419,7 +1419,7 @@ class Smarty
|
|||||||
// if a _cache_serial was set, we also have to write an include-file:
|
// if a _cache_serial was set, we also have to write an include-file:
|
||||||
if ($this->_cache_include_info) {
|
if ($this->_cache_include_info) {
|
||||||
require_once(SMARTY_CORE_DIR . 'core.write_compiled_include.php');
|
require_once(SMARTY_CORE_DIR . 'core.write_compiled_include.php');
|
||||||
smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content)), $this);
|
smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content, 'resource_name'=>$resource_name)), $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
$_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content);
|
$_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content);
|
||||||
@@ -1476,7 +1476,9 @@ class Smarty
|
|||||||
$smarty_compiler->_config = $this->_config;
|
$smarty_compiler->_config = $this->_config;
|
||||||
$smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals;
|
$smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals;
|
||||||
|
|
||||||
$smarty_compiler->_cache_serial = null;
|
if (isset($cache_include_path) && isset($this->_cache_serials[$cache_include_path])) {
|
||||||
|
$smarty_compiler->_cache_serial = $this->_cache_serials[$cache_include_path];
|
||||||
|
}
|
||||||
$smarty_compiler->_cache_include = $cache_include_path;
|
$smarty_compiler->_cache_include = $cache_include_path;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2161,7 +2161,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
if ($_cacheable
|
if ($_cacheable
|
||||||
|| 0<$this->_cacheable_state++) return '';
|
|| 0<$this->_cacheable_state++) return '';
|
||||||
if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty'));
|
if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty'));
|
||||||
$_ret = 'if ($this->caching) { echo \'{nocache:'
|
$_ret = 'if ($this->caching && !$this->_cache_including) { echo \'{nocache:'
|
||||||
. $this->_cache_serial . '#' . $this->_nocache_count
|
. $this->_cache_serial . '#' . $this->_nocache_count
|
||||||
. '}\';}';
|
. '}\';}';
|
||||||
return $_ret;
|
return $_ret;
|
||||||
@@ -2178,7 +2178,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
|
$_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
|
||||||
if ($_cacheable
|
if ($_cacheable
|
||||||
|| --$this->_cacheable_state>0) return '';
|
|| --$this->_cacheable_state>0) return '';
|
||||||
return 'if ($this->caching) { echo \'{/nocache:'
|
return 'if ($this->caching && !$this->_cache_including) { echo \'{/nocache:'
|
||||||
. $this->_cache_serial . '#' . ($this->_nocache_count++)
|
. $this->_cache_serial . '#' . ($this->_nocache_count++)
|
||||||
. '}\';}';
|
. '}\';}';
|
||||||
}
|
}
|
||||||
|
@@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
function smarty_core_write_compiled_include($params, &$smarty)
|
function smarty_core_write_compiled_include($params, &$smarty)
|
||||||
{
|
{
|
||||||
$_tag_start = 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
|
$_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
|
||||||
$_tag_end = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
|
$_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
|
||||||
|
|
||||||
preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
|
preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
|
||||||
$params['compiled_content'], $_match_source, PREG_SET_ORDER);
|
$params['compiled_content'], $_match_source, PREG_SET_ORDER);
|
||||||
@@ -25,7 +25,8 @@ function smarty_core_write_compiled_include($params, &$smarty)
|
|||||||
if (count($_match_source)==0) return;
|
if (count($_match_source)==0) return;
|
||||||
|
|
||||||
// convert the matched php-code to functions
|
// convert the matched php-code to functions
|
||||||
$_include_compiled = "<?php /* funky header here */\n\n";
|
$_include_compiled = "<?php /* Smarty version ".$smarty->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
|
||||||
|
$_include_compiled .= " compiled from " . strtr(urlencode($params['resource_name']), array('%2F'=>'/', '%3A'=>':')) . " */\n\n";
|
||||||
|
|
||||||
$_compile_path = $params['include_file_path'];
|
$_compile_path = $params['include_file_path'];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user