mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
- optimization of resource class loading
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
===== 3.1.22-dev ===== (xx.xx.2015)
|
===== 3.1.22-dev ===== (xx.xx.2015)
|
||||||
07.05.2015
|
07.05.2015
|
||||||
- improvement of the debugging console. Read NEW_FEATURES.txt
|
- improvement of the debugging console. Read NEW_FEATURES.txt
|
||||||
|
- optimization of resource class loading
|
||||||
|
|
||||||
06.05.2015
|
06.05.2015
|
||||||
- bugfix in 3.1.22-dev cache resource must not be loaded for subtemplates
|
- bugfix in 3.1.22-dev cache resource must not be loaded for subtemplates
|
||||||
|
@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.22-dev/29';
|
const SMARTY_VERSION = '3.1.22-dev/30';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
@@ -226,7 +226,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
$isCacheTpl = $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
|
$isCacheTpl = $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
|
||||||
if ($isCacheTpl) {
|
if ($isCacheTpl) {
|
||||||
if (!isset($this->cached)) {
|
if (!isset($this->cached)) {
|
||||||
$this->cached = Smarty_Template_Cached::load($this);
|
$this->loadCached();
|
||||||
}
|
}
|
||||||
$this->cached->isCached($this, true);
|
$this->cached->isCached($this, true);
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
if (!$this->source->uncompiled) {
|
if (!$this->source->uncompiled) {
|
||||||
// render compiled code
|
// render compiled code
|
||||||
if (!isset($this->compiled)) {
|
if (!isset($this->compiled)) {
|
||||||
$this->compiled = Smarty_Template_Compiled::load($this);
|
$this->loadCompiled();
|
||||||
}
|
}
|
||||||
$content = $this->compiled->render($this);
|
$content = $this->compiled->render($this);
|
||||||
} else {
|
} else {
|
||||||
@@ -790,6 +790,45 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load compiled object
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function loadCompiled()
|
||||||
|
{
|
||||||
|
if (!isset($this->compiled)) {
|
||||||
|
if (!class_exists('Smarty_Template_Compiled', false)) {
|
||||||
|
require SMARTY_SYSPLUGINS_DIR . 'smarty_template_compiled.php';
|
||||||
|
}
|
||||||
|
$this->compiled = Smarty_Template_Compiled::load($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load cached object
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function loadCached()
|
||||||
|
{
|
||||||
|
if (!isset($this->cached)) {
|
||||||
|
if (!class_exists('Smarty_Template_Cached', false)) {
|
||||||
|
require SMARTY_SYSPLUGINS_DIR . 'smarty_template_cached.php';
|
||||||
|
}
|
||||||
|
$this->cached = Smarty_Template_Cached::load($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load compiler object
|
||||||
|
*
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function loadCompiler()
|
||||||
|
{
|
||||||
|
$this->smarty->loadPlugin($this->source->compiler_class);
|
||||||
|
$this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle unknown class methods
|
* Handle unknown class methods
|
||||||
*
|
*
|
||||||
@@ -824,18 +863,14 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
case 'cached':
|
case 'cached':
|
||||||
case 'compiler':
|
case 'compiler':
|
||||||
$this->$property_name = $value;
|
$this->$property_name = $value;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: routing of template -> smarty attributes
|
|
||||||
default:
|
default:
|
||||||
|
// Smarty property ?
|
||||||
if (property_exists($this->smarty, $property_name)) {
|
if (property_exists($this->smarty, $property_name)) {
|
||||||
$this->smarty->$property_name = $value;
|
$this->smarty->$property_name = $value;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new SmartyException("invalid template property '$property_name'.");
|
throw new SmartyException("invalid template property '$property_name'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -855,26 +890,22 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
return $this->source;
|
return $this->source;
|
||||||
|
|
||||||
case 'compiled':
|
case 'compiled':
|
||||||
$this->compiled = Smarty_Template_Compiled::load($this);
|
$this->loadCompiled();
|
||||||
return $this->compiled;
|
return $this->compiled;
|
||||||
|
|
||||||
case 'cached':
|
case 'cached':
|
||||||
$this->cached = Smarty_Template_Cached::load($this);
|
$this->loadCached();
|
||||||
return $this->cached;
|
return $this->cached;
|
||||||
|
|
||||||
case 'compiler':
|
case 'compiler':
|
||||||
$this->smarty->loadPlugin($this->source->compiler_class);
|
$this->loadCompiler();
|
||||||
$this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);
|
|
||||||
|
|
||||||
return $this->compiler;
|
return $this->compiler;
|
||||||
|
|
||||||
// FIXME: routing of template -> smarty attributes
|
|
||||||
default:
|
default:
|
||||||
|
// Smarty property ?
|
||||||
if (property_exists($this->smarty, $property_name)) {
|
if (property_exists($this->smarty, $property_name)) {
|
||||||
return $this->smarty->$property_name;
|
return $this->smarty->$property_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new SmartyException("template property '$property_name' does not exist.");
|
throw new SmartyException("template property '$property_name' does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,6 +67,9 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return cache status of template
|
// return cache status of template
|
||||||
|
if (!isset($template->cached)) {
|
||||||
|
$template->loadCached();
|
||||||
|
}
|
||||||
return $template->cached->isCached($template);
|
return $template->cached->isCached($template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -109,7 +109,13 @@ class Smarty_Template_Cached
|
|||||||
{
|
{
|
||||||
$this->compile_id = $_template->compile_id;
|
$this->compile_id = $_template->compile_id;
|
||||||
$this->cache_id = $_template->cache_id;
|
$this->cache_id = $_template->cache_id;
|
||||||
|
if (!isset($_template->source)) {
|
||||||
|
$_template->loadSource();
|
||||||
|
}
|
||||||
$this->source = $_template->source;
|
$this->source = $_template->source;
|
||||||
|
if (!class_exists('Smarty_CacheResource', false)) {
|
||||||
|
require SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php';
|
||||||
|
}
|
||||||
$this->handler = Smarty_CacheResource::load($_template->smarty);
|
$this->handler = Smarty_CacheResource::load($_template->smarty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,6 +62,9 @@ class Smarty_Template_Compiled
|
|||||||
*/
|
*/
|
||||||
static function load($_template)
|
static function load($_template)
|
||||||
{
|
{
|
||||||
|
if (!isset($_template->source)) {
|
||||||
|
$_template->loadSource();
|
||||||
|
}
|
||||||
// check runtime cache
|
// check runtime cache
|
||||||
if (!$_template->source->recompiled && $_template->smarty->resource_caching) {
|
if (!$_template->source->recompiled && $_template->smarty->resource_caching) {
|
||||||
$_cache_key = $_template->source->unique_resource . '#';
|
$_cache_key = $_template->source->unique_resource . '#';
|
||||||
|
Reference in New Issue
Block a user