mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- optimization improve speed of filetime checks on extends and extendsall resource
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
===== 3.1.29-dev ===== (xx.xx.2015)
|
===== 3.1.29-dev ===== (xx.xx.2015)
|
||||||
|
21.12.2015
|
||||||
|
- optimization improve speed of filetime checks on extends and extendsall resource
|
||||||
|
|
||||||
20.12.2015
|
20.12.2015
|
||||||
- bugfix failure when the default resource type was set to 'extendsall' https://github.com/smarty-php/smarty/issues/123
|
- bugfix failure when the default resource type was set to 'extendsall' https://github.com/smarty-php/smarty/issues/123
|
||||||
- update compilation of Smarty special variables
|
- update compilation of Smarty special variables
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
|
|||||||
{
|
{
|
||||||
$uid = '';
|
$uid = '';
|
||||||
$sources = array();
|
$sources = array();
|
||||||
$exists = true;
|
$timestamp = 0;
|
||||||
foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
|
foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
|
||||||
try {
|
try {
|
||||||
$s = Smarty_Resource::source(null, $source->smarty, 'file:' . '[' . $key . ']' . $source->name);
|
$s = Smarty_Resource::source(null, $source->smarty, 'file:' . '[' . $key . ']' . $source->name);
|
||||||
@@ -31,30 +31,35 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
|
|||||||
}
|
}
|
||||||
$sources[ $s->uid ] = $s;
|
$sources[ $s->uid ] = $s;
|
||||||
$uid .= $s->filepath;
|
$uid .= $s->filepath;
|
||||||
|
$timestamp = $s->timestamp > $timestamp ? $s->timestamp : $timestamp;
|
||||||
}
|
}
|
||||||
catch (SmartyException $e) {
|
catch (SmartyException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$sources) {
|
if (!$sources) {
|
||||||
$source->exists = false;
|
$source->exists = false;
|
||||||
$source->template = $_template;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sources = array_reverse($sources, true);
|
$sources = array_reverse($sources, true);
|
||||||
reset($sources);
|
reset($sources);
|
||||||
$s = current($sources);
|
$s = current($sources);
|
||||||
|
|
||||||
$source->components = $sources;
|
$source->components = $sources;
|
||||||
$source->filepath = $s->filepath;
|
$source->filepath = $s->filepath;
|
||||||
$source->uid = sha1($uid . $_template->smarty->_joined_template_dir);
|
$source->uid = sha1($uid . $_template->smarty->_joined_template_dir);
|
||||||
$source->exists = $exists;
|
$source->exists = true;
|
||||||
if ($_template && $_template->smarty->compile_check) {
|
$source->timestamp = $timestamp;
|
||||||
$source->timestamp = $s->timestamp;
|
|
||||||
}
|
}
|
||||||
// need the template at getContent()
|
|
||||||
$source->template = $_template;
|
/*
|
||||||
|
* Disable timestamp checks for extendsall resource.
|
||||||
|
* The individual source components will be checked.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function checkTimestamps()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.29-dev/17';
|
const SMARTY_VERSION = '3.1.29-dev/18';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
@@ -44,7 +44,7 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
|
|||||||
if ($_s->type == 'php') {
|
if ($_s->type == 'php') {
|
||||||
throw new SmartyException("Resource type {$_s->type} cannot be used with the extends resource type");
|
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;
|
$uid .= $_s->filepath;
|
||||||
if ($_template) {
|
if ($_template) {
|
||||||
$exists = $exists && $_s->exists;
|
$exists = $exists && $_s->exists;
|
||||||
@@ -110,4 +110,15 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
|
|||||||
{
|
{
|
||||||
return str_replace(':', '.', basename($source->filepath));
|
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') {
|
} elseif ($_file_to_check[2] == 'string') {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
$source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[0]);
|
$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();
|
$mtime = $source->getTimeStamp();
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!$mtime || $mtime > $_file_to_check[1]) {
|
if (!$mtime || $mtime > $_file_to_check[1]) {
|
||||||
$is_valid = false;
|
$is_valid = false;
|
||||||
|
@@ -240,6 +240,16 @@ abstract class Smarty_Resource
|
|||||||
return $resource->buildUniqueResourceName($smarty, $name);
|
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
|
* initialize Source Object for given resource
|
||||||
* wrapper for backward compatibility to versions < 3.1.22
|
* wrapper for backward compatibility to versions < 3.1.22
|
||||||
|
Reference in New Issue
Block a user