- optimization improve speed of filetime checks on extends and extendsall resource

This commit is contained in:
uwetews
2015-12-21 02:18:27 +01:00
parent 3548de5fa1
commit efaa61cfb6
6 changed files with 49 additions and 15 deletions
@@ -44,7 +44,7 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
if ($_s->type == 'php') {
throw new SmartyException("Resource type {$_s->type} cannot be used with the extends resource type");
}
$sources[$_s->uid] = $_s;
$sources[ $_s->uid ] = $_s;
$uid .= $_s->filepath;
if ($_template) {
$exists = $exists && $_s->exists;
@@ -110,4 +110,15 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
{
return str_replace(':', '.', basename($source->filepath));
}
/*
* Disable timestamp checks for extends resource.
* The individual source components will be checked.
*
* @return bool
*/
public function checkTimestamps()
{
return false;
}
}
@@ -43,8 +43,13 @@ class Smarty_Internal_Runtime_ValidateCompiled
} elseif ($_file_to_check[2] == 'string') {
continue;
} else {
$source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[0]);
$mtime = $source->getTimeStamp();
$handler = Smarty_Resource::load($tpl->smarty, $_file_to_check[2]);
if ($handler->checkTimestamps()) {
$source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[ 0 ]);
$mtime = $source->getTimeStamp();
} else {
continue;
}
}
if (!$mtime || $mtime > $_file_to_check[1]) {
$is_valid = false;
+10
View File
@@ -240,6 +240,16 @@ abstract class Smarty_Resource
return $resource->buildUniqueResourceName($smarty, $name);
}
/*
* Check if resource must check time stamps when when loading complied or cached templates.
* Resources like 'extends' which use source components my disable timestamp checks on own resource.
*
* @return bool
*/
public function checkTimestamps() {
return true;
}
/**
* initialize Source Object for given resource
* wrapper for backward compatibility to versions < 3.1.22