mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- update scope handling
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
===== 3.1.30-dev ===== (xx.xx.xx)
|
===== 3.1.30-dev ===== (xx.xx.xx)
|
||||||
|
02.01.2016
|
||||||
|
- update scope handling
|
||||||
|
|
||||||
01.01.2016
|
01.01.2016
|
||||||
- remove Smarty::$resource_cache_mode property
|
- remove Smarty::$resource_cache_mode property
|
||||||
|
|
||||||
|
@@ -121,7 +121,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.30-dev/15';
|
const SMARTY_VERSION = '3.1.30-dev/16';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
@@ -134,8 +134,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
|
|
||||||
const SCOPE_ROOT = 8;
|
const SCOPE_ROOT = 8;
|
||||||
|
|
||||||
const SCOPE_SMARTY = 16;
|
|
||||||
|
|
||||||
const SCOPE_GLOBAL = 32;
|
const SCOPE_GLOBAL = 32;
|
||||||
|
|
||||||
const SCOPE_BUBBLE_UP = 64;
|
const SCOPE_BUBBLE_UP = 64;
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true, 'global' => true,
|
public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true, 'global' => true,
|
||||||
'smarty' => true, 'tpl_root' => true);
|
'tpl_root' => true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {assign} tag
|
* Compiles code for the {assign} tag
|
||||||
@@ -68,8 +68,6 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
|||||||
$_scope = Smarty::SCOPE_ROOT;
|
$_scope = Smarty::SCOPE_ROOT;
|
||||||
} elseif ($_attr[ 'scope' ] == 'global') {
|
} elseif ($_attr[ 'scope' ] == 'global') {
|
||||||
$_scope = Smarty::SCOPE_GLOBAL;
|
$_scope = Smarty::SCOPE_GLOBAL;
|
||||||
} elseif ($_attr[ 'scope' ] == 'smarty') {
|
|
||||||
$_scope = Smarty::SCOPE_SMARTY;
|
|
||||||
} elseif ($_attr[ 'scope' ] == 'tpl_root') {
|
} elseif ($_attr[ 'scope' ] == 'tpl_root') {
|
||||||
$_scope = Smarty::SCOPE_TPL_ROOT;
|
$_scope = Smarty::SCOPE_TPL_ROOT;
|
||||||
}
|
}
|
||||||
|
@@ -45,8 +45,8 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true, 'global' => true,
|
public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true,
|
||||||
'smarty' => true, 'tpl_root' => true);
|
'tpl_root' => true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {config_load} tag
|
* Compiles code for the {config_load} tag
|
||||||
@@ -84,10 +84,6 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
|||||||
$_scope = Smarty::SCOPE_PARENT;
|
$_scope = Smarty::SCOPE_PARENT;
|
||||||
} elseif ($_attr['scope'] == 'root') {
|
} elseif ($_attr['scope'] == 'root') {
|
||||||
$_scope = Smarty::SCOPE_ROOT;
|
$_scope = Smarty::SCOPE_ROOT;
|
||||||
} elseif ($_attr['scope'] == 'global') {
|
|
||||||
$_scope = Smarty::SCOPE_GLOBAL;
|
|
||||||
} elseif ($_attr['scope'] == 'smarty') {
|
|
||||||
$_scope = Smarty::SCOPE_SMARTY;
|
|
||||||
} elseif ($_attr['scope'] == 'tpl_root') {
|
} elseif ($_attr['scope'] == 'tpl_root') {
|
||||||
$_scope = Smarty::SCOPE_TPL_ROOT;
|
$_scope = Smarty::SCOPE_TPL_ROOT;
|
||||||
}
|
}
|
||||||
|
@@ -58,8 +58,8 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true, 'global' => true,
|
public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true,
|
||||||
'smarty' => true, 'tpl_root' => true);
|
'tpl_root' => true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {include} tag
|
* Compiles code for the {include} tag
|
||||||
@@ -124,16 +124,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
$_scope = Smarty::SCOPE_PARENT;
|
$_scope = Smarty::SCOPE_PARENT;
|
||||||
} elseif ($_attr['scope'] == 'root') {
|
} elseif ($_attr['scope'] == 'root') {
|
||||||
$_scope = Smarty::SCOPE_ROOT;
|
$_scope = Smarty::SCOPE_ROOT;
|
||||||
} elseif ($_attr['scope'] == 'global') {
|
|
||||||
$_scope = Smarty::SCOPE_GLOBAL;
|
|
||||||
} elseif ($_attr['scope'] == 'smarty') {
|
|
||||||
$_scope = Smarty::SCOPE_SMARTY;
|
|
||||||
} elseif ($_attr['scope'] == 'tpl_root') {
|
} elseif ($_attr['scope'] == 'tpl_root') {
|
||||||
$_scope = Smarty::SCOPE_TPL_ROOT;
|
$_scope = Smarty::SCOPE_TPL_ROOT;
|
||||||
}
|
}
|
||||||
if ($_attr['bubble_up'] === true) {
|
$_scope += (isset($_attr[ 'bubble_up' ]) && $_attr[ 'bubble_up' ] == 'false') ? 0 :
|
||||||
$_scope = $_scope + Smarty::SCOPE_BUBBLE_UP;
|
Smarty::SCOPE_BUBBLE_UP;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -83,10 +83,17 @@ class Smarty_Internal_Method_ConfigLoad
|
|||||||
{
|
{
|
||||||
$this->_assignConfigVars($tpl->parent, $tpl, $_config_vars);
|
$this->_assignConfigVars($tpl->parent, $tpl, $_config_vars);
|
||||||
$scope = $tpl->source->scope;
|
$scope = $tpl->source->scope;
|
||||||
if (!$scope && !$tpl->scope) {
|
$scopes = array();
|
||||||
|
if ($scope) {
|
||||||
|
$scopes[] = $scope;
|
||||||
|
}
|
||||||
|
if ($tpl->scope) {
|
||||||
|
$scopes[] = $tpl->scope;
|
||||||
|
}
|
||||||
|
if (empty($scopes)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach (array($scope, $tpl->scope) as $s) {
|
foreach ($scopes as $s) {
|
||||||
$s = ($bubble_up = $s >= Smarty::SCOPE_BUBBLE_UP) ? $s - Smarty::SCOPE_BUBBLE_UP : $s;
|
$s = ($bubble_up = $s >= Smarty::SCOPE_BUBBLE_UP) ? $s - Smarty::SCOPE_BUBBLE_UP : $s;
|
||||||
if ($bubble_up && $s) {
|
if ($bubble_up && $s) {
|
||||||
$ptr = $tpl->parent->parent;
|
$ptr = $tpl->parent->parent;
|
||||||
@@ -103,15 +110,11 @@ class Smarty_Internal_Method_ConfigLoad
|
|||||||
}
|
}
|
||||||
if ($s == Smarty::SCOPE_TPL_ROOT) {
|
if ($s == Smarty::SCOPE_TPL_ROOT) {
|
||||||
continue;
|
continue;
|
||||||
} elseif ($s == Smarty::SCOPE_SMARTY) {
|
|
||||||
$this->_assignConfigVars($tpl->smarty, $tpl, $_config_vars);
|
|
||||||
} elseif ($s == Smarty::SCOPE_GLOBAL) {
|
|
||||||
$this->_assignConfigVars($tpl->smarty, $tpl, $_config_vars);
|
|
||||||
} elseif ($s == Smarty::SCOPE_ROOT) {
|
} elseif ($s == Smarty::SCOPE_ROOT) {
|
||||||
while (isset($ptr->parent)) {
|
while (isset($ptr->parent)) {
|
||||||
$ptr = $ptr->parent;
|
$ptr = $ptr->parent;
|
||||||
|
$this->_assignConfigVars($ptr, $tpl, $_config_vars);
|
||||||
}
|
}
|
||||||
$this->_assignConfigVars($ptr, $tpl, $_config_vars);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,12 +34,25 @@ class Smarty_Internal_Runtime_UpdateScope
|
|||||||
foreach ($scopes as $s) {
|
foreach ($scopes as $s) {
|
||||||
$s = ($bubble_up = $s >= Smarty::SCOPE_BUBBLE_UP) ? $s - Smarty::SCOPE_BUBBLE_UP : $s;
|
$s = ($bubble_up = $s >= Smarty::SCOPE_BUBBLE_UP) ? $s - Smarty::SCOPE_BUBBLE_UP : $s;
|
||||||
if ($bubble_up && $s) {
|
if ($bubble_up && $s) {
|
||||||
if (isset($tpl->parent)) {
|
$oldGlobal = null;
|
||||||
|
if ($s == Smarty::SCOPE_GLOBAL) {
|
||||||
|
$oldGlobal =
|
||||||
|
isset(Smarty::$global_tpl_vars[ $varName ]) ? Smarty::$global_tpl_vars[ $varName ] : null;
|
||||||
|
Smarty::$global_tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ];
|
||||||
|
}
|
||||||
|
if (isset($tpl->parent) && $tpl->parent->_objType == 2) {
|
||||||
$ptr = $tpl->parent;
|
$ptr = $tpl->parent;
|
||||||
|
if ($s == Smarty::SCOPE_GLOBAL && isset($oldGlobal) && isset($ptr->tpl_vars[ $varName ]) &&
|
||||||
|
$ptr->tpl_vars[ $varName ] !== $oldGlobal
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$ptr->tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ];
|
$ptr->tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ];
|
||||||
if (isset($ptr->parent)) {
|
if (isset($ptr->parent)) {
|
||||||
$ptr = $ptr->parent;
|
$ptr = $ptr->parent;
|
||||||
}
|
}
|
||||||
|
} elseif (isset($tpl->parent)) {
|
||||||
|
$ptr = $tpl->parent;
|
||||||
}
|
}
|
||||||
if ($s == Smarty::SCOPE_PARENT) {
|
if ($s == Smarty::SCOPE_PARENT) {
|
||||||
continue;
|
continue;
|
||||||
@@ -50,15 +63,10 @@ class Smarty_Internal_Runtime_UpdateScope
|
|||||||
}
|
}
|
||||||
if ($s == Smarty::SCOPE_TPL_ROOT) {
|
if ($s == Smarty::SCOPE_TPL_ROOT) {
|
||||||
continue;
|
continue;
|
||||||
} elseif ($s == Smarty::SCOPE_SMARTY) {
|
}
|
||||||
$tpl->smarty->tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ];
|
while (isset($ptr) && $s != Smarty::SCOPE_GLOBAL) {
|
||||||
} elseif ($s == Smarty::SCOPE_GLOBAL) {
|
|
||||||
Smarty::$global_tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ];
|
|
||||||
} elseif ($s == Smarty::SCOPE_ROOT) {
|
|
||||||
while (isset($ptr->parent)) {
|
|
||||||
$ptr = $ptr->parent;
|
|
||||||
}
|
|
||||||
$ptr->tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ];
|
$ptr->tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ];
|
||||||
|
$ptr = isset($ptr->parent) ? $ptr->parent : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -119,7 +119,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* render template
|
* render template
|
||||||
*
|
*
|
||||||
* @param bool $no_output_filter if true do not run output filter
|
* @param bool $no_output_filter if true do not run output filter
|
||||||
* @param null|bool $display true: display, false: fetch null: sub-template
|
* @param null|bool $display true: display, false: fetch null: sub-template
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
@@ -168,8 +168,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
isset($content) ? $content : ob_get_clean());
|
isset($content) ? $content : ob_get_clean());
|
||||||
} else {
|
} else {
|
||||||
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
|
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
|
||||||
!$no_output_filter && (isset($this->smarty->autoload_filters['output']) ||
|
!$no_output_filter && (isset($this->smarty->autoload_filters[ 'output' ]) ||
|
||||||
isset($this->smarty->registered_filters['output']))
|
isset($this->smarty->registered_filters[ 'output' ]))
|
||||||
) {
|
) {
|
||||||
echo $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
|
echo $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
|
||||||
} else {
|
} else {
|
||||||
@@ -197,14 +197,15 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
foreach ($this->compiled->required_plugins as $code => $tmp1) {
|
foreach ($this->compiled->required_plugins as $code => $tmp1) {
|
||||||
foreach ($tmp1 as $name => $tmp) {
|
foreach ($tmp1 as $name => $tmp) {
|
||||||
foreach ($tmp as $type => $data) {
|
foreach ($tmp as $type => $data) {
|
||||||
$this->parent->compiled->required_plugins[$code][$name][$type] = $data;
|
$this->parent->compiled->required_plugins[ $code ][ $name ][ $type ] = $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$no_output_filter &&
|
if (!$no_output_filter &&
|
||||||
(!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
|
(!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
|
||||||
(isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))
|
(isset($this->smarty->autoload_filters[ 'output' ]) ||
|
||||||
|
isset($this->smarty->registered_filters[ 'output' ]))
|
||||||
) {
|
) {
|
||||||
return $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
|
return $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
|
||||||
}
|
}
|
||||||
@@ -266,8 +267,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
if (isset($tpl->compiled->file_dependency[ $uid ])) {
|
if (isset($tpl->compiled->file_dependency[ $uid ])) {
|
||||||
list($filepath, $timestamp, $type) = $tpl->compiled->file_dependency[ $uid ];
|
list($filepath, $timestamp, $type) = $tpl->compiled->file_dependency[ $uid ];
|
||||||
$tpl->source =
|
$tpl->source =
|
||||||
new Smarty_Template_Source(isset($tpl->smarty->_cache['resource_handlers'][$type]) ?
|
new Smarty_Template_Source(isset($tpl->smarty->_cache[ 'resource_handlers' ][ $type ]) ?
|
||||||
$tpl->smarty->_cache['resource_handlers'][$type] :
|
$tpl->smarty->_cache[ 'resource_handlers' ][ $type ] :
|
||||||
Smarty_Resource::load($tpl->smarty, $type), $tpl->smarty,
|
Smarty_Resource::load($tpl->smarty, $type), $tpl->smarty,
|
||||||
$filepath, $type, $filepath);
|
$filepath, $type, $filepath);
|
||||||
$tpl->source->filepath = $filepath;
|
$tpl->source->filepath = $filepath;
|
||||||
@@ -295,30 +296,22 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
// set template scope
|
// set template scope
|
||||||
$tpl->scope = $scope;
|
$tpl->scope = $scope;
|
||||||
$scopePtr = false;
|
$scopePtr = false;
|
||||||
if ($scope & ~Smarty::SCOPE_BUBBLE_UP) {
|
$scope = $scope & ~Smarty::SCOPE_BUBBLE_UP;
|
||||||
if ($scope == Smarty::SCOPE_GLOBAL) {
|
if ($scope) {
|
||||||
$tpl->tpl_vars = Smarty::$global_tpl_vars;
|
if ($scope == Smarty::SCOPE_PARENT) {
|
||||||
$tpl->config_vars = $tpl->smarty->config_vars;
|
$scopePtr = $this;
|
||||||
$scopePtr = true;
|
|
||||||
} else {
|
} else {
|
||||||
if ($scope == Smarty::SCOPE_PARENT) {
|
$scopePtr = $tpl;
|
||||||
$scopePtr = $this;
|
while (isset($scopePtr->parent)) {
|
||||||
} elseif ($scope == Smarty::SCOPE_SMARTY) {
|
if (!$scopePtr->_isParentTemplate() && $scope & Smarty::SCOPE_TPL_ROOT) {
|
||||||
$scopePtr = $tpl->smarty;
|
break;
|
||||||
} else {
|
|
||||||
$scopePtr = $tpl;
|
|
||||||
while (isset($scopePtr->parent)) {
|
|
||||||
if (!$scopePtr->_isParentTemplate() && $scope & Smarty::SCOPE_TPL_ROOT) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$scopePtr = $scopePtr->parent;
|
|
||||||
}
|
}
|
||||||
|
$scopePtr = $scopePtr->parent;
|
||||||
}
|
}
|
||||||
$tpl->tpl_vars = $scopePtr->tpl_vars;
|
|
||||||
$tpl->config_vars = $scopePtr->config_vars;
|
|
||||||
}
|
}
|
||||||
|
$tpl->tpl_vars = $scopePtr->tpl_vars;
|
||||||
|
$tpl->config_vars = $scopePtr->config_vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($tpl->smarty->_cache[ 'tplObjects' ][ $tpl->templateId ]) && !$tpl->source->handler->recompiled) {
|
if (!isset($tpl->smarty->_cache[ 'tplObjects' ][ $tpl->templateId ]) && !$tpl->source->handler->recompiled) {
|
||||||
// if template is called multiple times set flag to to cache template objects
|
// if template is called multiple times set flag to to cache template objects
|
||||||
$forceTplCache = $forceTplCache ||
|
$forceTplCache = $forceTplCache ||
|
||||||
@@ -326,7 +319,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
$tpl->smarty->_cache[ 'subTplInfo' ][ $tpl->template_resource ] > 1);
|
$tpl->smarty->_cache[ 'subTplInfo' ][ $tpl->template_resource ] > 1);
|
||||||
// check if template object should be cached
|
// check if template object should be cached
|
||||||
if ($tpl->_isParentTemplate() && isset($tpl->smarty->_cache[ 'tplObjects' ][ $tpl->parent->templateId ]) ||
|
if ($tpl->_isParentTemplate() && isset($tpl->smarty->_cache[ 'tplObjects' ][ $tpl->parent->templateId ]) ||
|
||||||
$forceTplCache) {
|
$forceTplCache
|
||||||
|
) {
|
||||||
$tpl->smarty->_cache[ 'tplObjects' ][ $tpl->templateId ] = $tpl;
|
$tpl->smarty->_cache[ 'tplObjects' ][ $tpl->templateId ] = $tpl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -358,13 +352,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($scopePtr) {
|
if ($scopePtr) {
|
||||||
if ($scope == Smarty::SCOPE_GLOBAL) {
|
$scopePtr->tpl_vars = $tpl->tpl_vars;
|
||||||
Smarty::$global_tpl_vars = $tpl->tpl_vars;
|
$scopePtr->config_vars = $tpl->config_vars;
|
||||||
$tpl->smarty->config_vars = $tpl->config_vars;
|
|
||||||
} else {
|
|
||||||
$scopePtr->tpl_vars = $tpl->tpl_vars;
|
|
||||||
$scopePtr->config_vars = $tpl->config_vars;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,27 +442,29 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
public function _decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false)
|
public function _decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false)
|
||||||
{
|
{
|
||||||
$is_valid = true;
|
$is_valid = true;
|
||||||
if (Smarty::SMARTY_VERSION != $properties['version']) {
|
if (Smarty::SMARTY_VERSION != $properties[ 'version' ]) {
|
||||||
// new version must rebuild
|
// new version must rebuild
|
||||||
$is_valid = false;
|
$is_valid = false;
|
||||||
} elseif ($is_valid && !empty($properties['file_dependency']) &&
|
} elseif ($is_valid && !empty($properties[ 'file_dependency' ]) &&
|
||||||
((!$cache && $tpl->smarty->compile_check) || $tpl->smarty->compile_check == 1)
|
((!$cache && $tpl->smarty->compile_check) || $tpl->smarty->compile_check == 1)
|
||||||
) {
|
) {
|
||||||
// check file dependencies at compiled code
|
// check file dependencies at compiled code
|
||||||
foreach ($properties['file_dependency'] as $_file_to_check) {
|
foreach ($properties[ 'file_dependency' ] as $_file_to_check) {
|
||||||
if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'extends' || $_file_to_check[2] == 'php') {
|
if ($_file_to_check[ 2 ] == 'file' || $_file_to_check[ 2 ] == 'extends' ||
|
||||||
if ($tpl->source->filepath == $_file_to_check[0]) {
|
$_file_to_check[ 2 ] == 'php'
|
||||||
|
) {
|
||||||
|
if ($tpl->source->filepath == $_file_to_check[ 0 ]) {
|
||||||
// do not recheck current template
|
// do not recheck current template
|
||||||
continue;
|
continue;
|
||||||
//$mtime = $tpl->source->getTimeStamp();
|
//$mtime = $tpl->source->getTimeStamp();
|
||||||
} else {
|
} else {
|
||||||
// file and php types can be checked without loading the respective resource handlers
|
// file and php types can be checked without loading the respective resource handlers
|
||||||
$mtime = is_file($_file_to_check[0]) ? filemtime($_file_to_check[0]) : false;
|
$mtime = is_file($_file_to_check[ 0 ]) ? filemtime($_file_to_check[ 0 ]) : false;
|
||||||
}
|
}
|
||||||
} elseif ($_file_to_check[2] == 'string') {
|
} elseif ($_file_to_check[ 2 ] == 'string') {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
$handler = Smarty_Resource::load($tpl->smarty, $_file_to_check[2]);
|
$handler = Smarty_Resource::load($tpl->smarty, $_file_to_check[ 2 ]);
|
||||||
if ($handler->checkTimestamps()) {
|
if ($handler->checkTimestamps()) {
|
||||||
$source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[ 0 ]);
|
$source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[ 0 ]);
|
||||||
$mtime = $source->getTimeStamp();
|
$mtime = $source->getTimeStamp();
|
||||||
@@ -481,7 +472,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$mtime || $mtime > $_file_to_check[1]) {
|
if (!$mtime || $mtime > $_file_to_check[ 1 ]) {
|
||||||
$is_valid = false;
|
$is_valid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -489,32 +480,31 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
if ($cache) {
|
if ($cache) {
|
||||||
// CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
|
// CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
|
||||||
if ($tpl->caching === Smarty::CACHING_LIFETIME_SAVED && $properties['cache_lifetime'] >= 0 &&
|
if ($tpl->caching === Smarty::CACHING_LIFETIME_SAVED && $properties[ 'cache_lifetime' ] >= 0 &&
|
||||||
(time() > ($tpl->cached->timestamp + $properties['cache_lifetime']))
|
(time() > ($tpl->cached->timestamp + $properties[ 'cache_lifetime' ]))
|
||||||
) {
|
) {
|
||||||
$is_valid = false;
|
$is_valid = false;
|
||||||
}
|
}
|
||||||
$tpl->cached->cache_lifetime = $properties['cache_lifetime'];
|
$tpl->cached->cache_lifetime = $properties[ 'cache_lifetime' ];
|
||||||
$tpl->cached->valid = $is_valid;
|
$tpl->cached->valid = $is_valid;
|
||||||
$resource = $tpl->cached;
|
$resource = $tpl->cached;
|
||||||
} else {
|
} else {
|
||||||
$tpl->mustCompile = !$is_valid;
|
$tpl->mustCompile = !$is_valid;
|
||||||
$resource = $tpl->compiled;
|
$resource = $tpl->compiled;
|
||||||
$resource->includes = isset($properties['includes']) ? $properties['includes'] : array();
|
$resource->includes = isset($properties[ 'includes' ]) ? $properties[ 'includes' ] : array();
|
||||||
}
|
}
|
||||||
if ($is_valid) {
|
if ($is_valid) {
|
||||||
$resource->unifunc = $properties['unifunc'];
|
$resource->unifunc = $properties[ 'unifunc' ];
|
||||||
$resource->has_nocache_code = $properties['has_nocache_code'];
|
$resource->has_nocache_code = $properties[ 'has_nocache_code' ];
|
||||||
// $tpl->compiled->nocache_hash = $properties['nocache_hash'];
|
// $tpl->compiled->nocache_hash = $properties['nocache_hash'];
|
||||||
$resource->file_dependency = $properties['file_dependency'];
|
$resource->file_dependency = $properties[ 'file_dependency' ];
|
||||||
if (isset($properties['tpl_function'])) {
|
if (isset($properties[ 'tpl_function' ])) {
|
||||||
$tpl->tpl_function = $properties['tpl_function'];
|
$tpl->tpl_function = $properties[ 'tpl_function' ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $is_valid && !function_exists($properties['unifunc']);
|
return $is_valid && !function_exists($properties[ 'unifunc' ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles the template
|
* Compiles the template
|
||||||
* If the template is not evaluated the compiled template is saved on disk
|
* If the template is not evaluated the compiled template is saved on disk
|
||||||
|
Reference in New Issue
Block a user