mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
fixed compiled include handling
This commit is contained in:
@@ -564,13 +564,6 @@ reques * @var string
|
|||||||
'insert' => array());
|
'insert' => array());
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cache serial
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
var $_cache_serial = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cache serials
|
* cache serials
|
||||||
*
|
*
|
||||||
@@ -1291,6 +1284,7 @@ reques * @var string
|
|||||||
}
|
}
|
||||||
|
|
||||||
$_smarty_compile_path = $this->_get_compile_path($resource_name);
|
$_smarty_compile_path = $this->_get_compile_path($resource_name);
|
||||||
|
$this->_cache_include = substr($_smarty_compile_path, 0, -4).'.inc';
|
||||||
|
|
||||||
// if we just need to display the results, don't perform output
|
// if we just need to display the results, don't perform output
|
||||||
// buffering - for speed
|
// buffering - for speed
|
||||||
@@ -1496,16 +1490,14 @@ reques * @var string
|
|||||||
$_resource_timestamp = $_params['resource_timestamp'];
|
$_resource_timestamp = $_params['resource_timestamp'];
|
||||||
|
|
||||||
if ($this->_compile_source($resource_name, $_source_content, $_compiled_content)) {
|
if ($this->_compile_source($resource_name, $_source_content, $_compiled_content)) {
|
||||||
$_params = array('compile_path' => $compile_path, 'compiled_content' => $_compiled_content, 'resource_timestamp' => $_resource_timestamp);
|
$_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content, 'resource_timestamp' => $_resource_timestamp);
|
||||||
require_once(SMARTY_DIR . 'core/core.write_compiled_resource.php');
|
require_once(SMARTY_DIR . 'core/core.write_compiled_resource.php');
|
||||||
smarty_core_write_compiled_resource($_params, $this);
|
smarty_core_write_compiled_resource($_params, $this);
|
||||||
|
|
||||||
// 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_serial = $smarty_compiler->_cache_serial) {
|
if ($this->_cache_include_info) {
|
||||||
$_params['plugins_code'] = $smarty_compiler->_plugins_code;
|
|
||||||
$_params['include_file_path'] = $smarty_compiler->_cache_include;
|
|
||||||
require_once(SMARTY_DIR . 'core/core.write_compiled_include.php');
|
require_once(SMARTY_DIR . 'core/core.write_compiled_include.php');
|
||||||
smarty_core_write_compiled_include($_params, $this);
|
smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content)), $this);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -1557,13 +1549,27 @@ reques * @var string
|
|||||||
|
|
||||||
$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;
|
|
||||||
$smarty_compiler->_cache_include = substr($compile_path, 0, -4).'.inc';
|
|
||||||
$smarty_compiler->_cache_paths = $this->_cache_paths;
|
$smarty_compiler->_cache_paths = $this->_cache_paths;
|
||||||
$smarty_compiler->_cache_paths_file = $this->_cache_paths_file;
|
$smarty_compiler->_cache_paths_file = $this->_cache_paths_file;
|
||||||
|
|
||||||
return $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
|
$smarty_compiler->_cache_serial = null;
|
||||||
|
$smarty_compiler->_cache_include = $this->_cache_include;
|
||||||
|
|
||||||
|
|
||||||
|
$_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
|
||||||
|
|
||||||
|
if ($smarty_compiler->_cache_serial) {
|
||||||
|
$this->_cache_include_info = array(
|
||||||
|
'cache_serial'=>$smarty_compiler->_cache_serial
|
||||||
|
,'plugins_code'=>$smarty_compiler->_plugins_code
|
||||||
|
,'include_file_path' => $smarty_compiler->_cache_include);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$this->_cache_include_info = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $_results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -16,12 +16,11 @@
|
|||||||
|
|
||||||
function smarty_core_write_compiled_include($params, &$this)
|
function smarty_core_write_compiled_include($params, &$this)
|
||||||
{
|
{
|
||||||
|
$_tag_start = 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
|
||||||
$_tag_start = 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$this->_cache_serial.')#(\d+)\}\';\}';
|
|
||||||
$_tag_end = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
|
$_tag_end = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
|
||||||
|
|
||||||
preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
|
preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
|
||||||
$params['file_compiled'], $_match_source, PREG_SET_ORDER);
|
$params['compiled_content'], $_match_source, PREG_SET_ORDER);
|
||||||
|
|
||||||
// no nocache-parts found: done
|
// no nocache-parts found: done
|
||||||
if (count($_match_source)==0) return;
|
if (count($_match_source)==0) return;
|
||||||
@@ -32,7 +31,7 @@ function smarty_core_write_compiled_include($params, &$this)
|
|||||||
$_compile_path = $params['include_file_path'];
|
$_compile_path = $params['include_file_path'];
|
||||||
|
|
||||||
$this->_cache_serials[$_compile_path] = $this->_cache_serial;
|
$this->_cache_serials[$_compile_path] = $this->_cache_serial;
|
||||||
$_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$this->_cache_serial."';\n\n?>";
|
$_include_compiled .= "\$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."';\n\n?>";
|
||||||
|
|
||||||
$_include_compiled .= $params['plugins_code'];
|
$_include_compiled .= $params['plugins_code'];
|
||||||
$_include_compiled .= "<?";
|
$_include_compiled .= "<?";
|
||||||
|
Reference in New Issue
Block a user