mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
- add Smarty::$allow_ambiguous_resources to activate unique resource handling (Forum Topic 20128)
see http://www.smarty.net/forums/viewtopic.php?t=20128
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
21.10.2011
|
21.10.2011
|
||||||
- bugfix apostrophe in plugins_dir path name failed (forum topic 20199)
|
- bugfix apostrophe in plugins_dir path name failed (forum topic 20199)
|
||||||
- improvement sha1() for array keys longer than 150 characters
|
- improvement sha1() for array keys longer than 150 characters
|
||||||
|
- add Smarty::$allow_ambiguous_resources to activate unique resource handling (Forum Topic 20128)
|
||||||
|
|
||||||
20.10.2011
|
20.10.2011
|
||||||
- @silenced unlink() in Smarty_Internal_Write_File since debuggers go haywire without it.
|
- @silenced unlink() in Smarty_Internal_Write_File since debuggers go haywire without it.
|
||||||
|
@@ -251,6 +251,11 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
|||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
public $use_sub_dirs = false;
|
public $use_sub_dirs = false;
|
||||||
|
/**
|
||||||
|
* allow ambiguous resources (that are made unique by the resource handler)
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
public $allow_ambiguous_resources = false;
|
||||||
/**
|
/**
|
||||||
* caching enabled
|
* caching enabled
|
||||||
* @var boolean
|
* @var boolean
|
||||||
@@ -1172,8 +1177,11 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
|||||||
$cache_id = $cache_id === null ? $this->cache_id : $cache_id;
|
$cache_id = $cache_id === null ? $this->cache_id : $cache_id;
|
||||||
$compile_id = $compile_id === null ? $this->compile_id : $compile_id;
|
$compile_id = $compile_id === null ? $this->compile_id : $compile_id;
|
||||||
// already in template cache?
|
// already in template cache?
|
||||||
$unique_template_name = Smarty_Resource::getUniqueTemplateName($this, $template);
|
if ($this->allow_ambiguous_resources) {
|
||||||
$_templateId = $unique_template_name . $cache_id . $compile_id;
|
$_templateId = Smarty_Resource::getUniqueTemplateName($this, $template) . $cache_id . $compile_id;
|
||||||
|
} else {
|
||||||
|
$_templateId = $this->joined_template_dir . '#' . $template . $cache_id . $compile_id;
|
||||||
|
}
|
||||||
if (isset($_templateId[150])) {
|
if (isset($_templateId[150])) {
|
||||||
$_templateId = sha1($_templateId);
|
$_templateId = sha1($_templateId);
|
||||||
}
|
}
|
||||||
|
@@ -178,7 +178,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove from template cache
|
// remove from template cache
|
||||||
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
|
if ($smarty->allow_ambiguous_resources) {
|
||||||
|
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
|
||||||
|
} else {
|
||||||
|
$_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
|
||||||
|
}
|
||||||
if (isset($_templateId[150])) {
|
if (isset($_templateId[150])) {
|
||||||
$_templateId = sha1($_templateId);
|
$_templateId = sha1($_templateId);
|
||||||
}
|
}
|
||||||
|
@@ -154,7 +154,11 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource {
|
|||||||
|
|
||||||
// remove from template cache
|
// remove from template cache
|
||||||
$tpl->source; // have the template registered before unset()
|
$tpl->source; // have the template registered before unset()
|
||||||
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
|
if ($smarty->allow_ambiguous_resources) {
|
||||||
|
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
|
||||||
|
} else {
|
||||||
|
$_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
|
||||||
|
}
|
||||||
if (isset($_templateId[150])) {
|
if (isset($_templateId[150])) {
|
||||||
$_templateId = sha1($_templateId);
|
$_templateId = sha1($_templateId);
|
||||||
}
|
}
|
||||||
|
@@ -245,8 +245,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
|||||||
public function getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
|
public function getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
|
||||||
{
|
{
|
||||||
// already in template cache?
|
// already in template cache?
|
||||||
$unique_template_name = Smarty_Resource::getUniqueTemplateName($this->smarty, $template);
|
if ($this->smarty->allow_ambiguous_resources) {
|
||||||
$_templateId = $unique_template_name . $cache_id . $compile_id;
|
$_templateId = Smarty_Resource::getUniqueTemplateName($this->smarty, $template) . $cache_id . $compile_id;
|
||||||
|
} else {
|
||||||
|
$_templateId = $this->smarty->joined_template_dir . '#' . $template . $cache_id . $compile_id;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_templateId[150])) {
|
if (isset($_templateId[150])) {
|
||||||
$_templateId = sha1($_templateId);
|
$_templateId = sha1($_templateId);
|
||||||
}
|
}
|
||||||
@@ -625,7 +629,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
|||||||
// cache template object under a unique ID
|
// cache template object under a unique ID
|
||||||
// do not cache eval resources
|
// do not cache eval resources
|
||||||
if ($this->source->type != 'eval') {
|
if ($this->source->type != 'eval') {
|
||||||
$_templateId = $this->source->unique_resource . $this->cache_id . $this->compile_id;
|
if ($this->smarty->allow_ambiguous_resources) {
|
||||||
|
$_templateId = $this->source->unique_resource . $this->cache_id . $this->compile_id;
|
||||||
|
} else {
|
||||||
|
$_templateId = $this->smarty->joined_template_dir . '#' . $this->template_resource . $this->cache_id . $this->compile_id;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_templateId[150])) {
|
if (isset($_templateId[150])) {
|
||||||
$_templateId = sha1($_templateId);
|
$_templateId = sha1($_templateId);
|
||||||
}
|
}
|
||||||
|
@@ -192,7 +192,11 @@ class Smarty_Internal_Utility {
|
|||||||
|
|
||||||
// remove from template cache
|
// remove from template cache
|
||||||
$tpl->source; // have the template registered before unset()
|
$tpl->source; // have the template registered before unset()
|
||||||
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
|
if ($smarty->allow_ambiguous_resources) {
|
||||||
|
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
|
||||||
|
} else {
|
||||||
|
$_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
|
||||||
|
}
|
||||||
if (isset($_templateId[150])) {
|
if (isset($_templateId[150])) {
|
||||||
$_templateId = sha1($_templateId);
|
$_templateId = sha1($_templateId);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user