- 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:
messju
2004-10-01 15:26:44 +00:00
parent 4465197142
commit e9c72aedce
3 changed files with 10 additions and 7 deletions

View File

@@ -1419,7 +1419,7 @@ class Smarty
// if a _cache_serial was set, we also have to write an include-file:
if ($this->_cache_include_info) {
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);
@@ -1476,7 +1476,9 @@ class Smarty
$smarty_compiler->_config = $this->_config;
$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;

View File

@@ -2161,7 +2161,7 @@ class Smarty_Compiler extends Smarty {
if ($_cacheable
|| 0<$this->_cacheable_state++) return '';
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
. '}\';}';
return $_ret;
@@ -2178,7 +2178,7 @@ class Smarty_Compiler extends Smarty {
$_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
if ($_cacheable
|| --$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++)
. '}\';}';
}

View File

@@ -15,8 +15,8 @@
function smarty_core_write_compiled_include($params, &$smarty)
{
$_tag_start = 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
$_tag_end = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
$_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
$_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
$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;
// 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'];