Smarty bugfix release 3.1.17 - read changelog
This commit is contained in:
parent
95cddcd6a2
commit
e7072aaf6e
@ -1,4 +1,4 @@
|
||||
In Smarty 3.1 template inheritance is a compile time process. All the extending of {block} tags
|
||||
In Smarty 3.1 template inheritance is a compile time process. All the extending of {block} tags
|
||||
is done at compile time and the parent and child templates are compiled in a single compiled template.
|
||||
{include} subtemplate could also {block} tags. Such subtemplate could not compiled by it's own because
|
||||
it could be used in other context where the {block} extended with a different result. For that reasion
|
||||
@ -19,16 +19,17 @@ With this setting all {include} subtemplate will be merge into the compiled inhe
|
||||
could be rejected by exception.
|
||||
|
||||
|
||||
If $smarty->inheritance_merge_compiled_includes = false; {include} subtemplate will not be merged.
|
||||
If $smarty->inheritance_merge_compiled_includes = false; {include} subtemplate will not be merged.
|
||||
You must now manually merge all {include} subtemplate which do contain {block} tags. This is done by setting the "inline" option.
|
||||
{include file='foo.bar' inline}
|
||||
|
||||
1. In case of a variable file name like {include file=$foo inline} you must you the variable in a compile_id $smarty->compile_id = $foo;
|
||||
2. If you use individual compile_id in {include file='foo.tpl' compile_id=$bar inline} it must be used in the
|
||||
global compile_id as well $smarty->compile_id = $foo;
|
||||
1. In case of a variable file name like {include file=$foo inline} you must you the variable in a compile_id $smarty->compile_id = $foo;
|
||||
2. If you use individual compile_id in {include file='foo.tpl' compile_id=$bar inline} it must be used in the
|
||||
global compile_id as well $smarty->compile_id = $foo;
|
||||
3. If call templates with different template_dir configurations and a parent could same named child template from different folders
|
||||
you must make the folder name part of the compile_id.
|
||||
you must make the folder name part of the compile_id.
|
||||
|
||||
|
||||
In the upcomming major release Smarty 3.2 inheritance will no longer be a compile time process.
|
||||
All restrictions will be then removed.
|
||||
In the upcomming major release Smarty 3.2 inheritance will no longer be a compile time process.
|
||||
All restrictions will be then removed.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
Smarty 3.1.16
|
||||
Smarty 3.1.17
|
||||
|
||||
Author: Monte Ohrt <monte at ohrt dot com >
|
||||
Author: Uwe Tews
|
||||
|
@ -1,4 +1,35 @@
|
||||
===== trunk =====
|
||||
===== 3.1.17 =====
|
||||
08.03.2014
|
||||
- bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177)
|
||||
|
||||
17.02.2014
|
||||
- bugfix Smarty failed when executing PHP on HHVM (Hip Hop 2.4) because uniqid('',true) does return string with ',' (forum topic 20343)
|
||||
|
||||
16.02.2014
|
||||
- bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175)
|
||||
|
||||
05.02.2014
|
||||
- bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group)
|
||||
|
||||
27.01.2014
|
||||
- bugfix $smarty->debugging = true; did show the variable of the $smarty object not the variables used in display() call (forum topic 24764)
|
||||
- bugfix clearCompiledTemplate(), clearAll() and clear() should use realpath to avoid possible exception from RecursiveDirectoryIterator (Issue 171)
|
||||
|
||||
26.01.2014
|
||||
- bugfix undo block nesting checks for {nocache} for reasons like forum topic 23280 (forum topic 24762)
|
||||
|
||||
18.01.2014
|
||||
- bugfix the compiler did fail when using template inheritance and recursive {include} (smarty-developers group)
|
||||
|
||||
11.01.2014
|
||||
- bugfix "* }" (spaces before right delimiter) was interpreted by mistake as comment end tag (Issue 170)
|
||||
- internals content cache should be clear when updating cache file
|
||||
|
||||
08.01.2014
|
||||
- bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 169)
|
||||
- bugfix SmartyBC.class.php should use require_once to load Smarty.class.php (forum topic 24683)
|
||||
|
||||
===== 3.1.16 =====
|
||||
15.12.2013
|
||||
- bugfix {include} with {block} tag handling (forum topic 24599, 24594, 24682) (Issue 161)
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: Smarty.class.php
|
||||
* SVN: $Id: Smarty.class.php 4800 2013-12-15 15:19:01Z Uwe.Tews@googlemail.com $
|
||||
* SVN: $Id: Smarty.class.php 4814 2014-02-16 18:34:08Z Uwe.Tews@googlemail.com $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -28,7 +28,7 @@
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
* @version 3.1-DEV
|
||||
* @version 3.1.17
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -113,7 +113,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = 'Smarty-3.1.16';
|
||||
const SMARTY_VERSION = 'Smarty-3.1.17';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
@ -835,7 +835,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
{
|
||||
$this->template_dir = array();
|
||||
foreach ((array) $template_dir as $k => $v) {
|
||||
$this->template_dir[$k] = rtrim($v, '/\\') . DS;
|
||||
$this->template_dir[$k] = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS;
|
||||
}
|
||||
|
||||
$this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
|
||||
@ -858,20 +858,24 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
|
||||
if (is_array($template_dir)) {
|
||||
foreach ($template_dir as $k => $v) {
|
||||
$v = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS;
|
||||
if (is_int($k)) {
|
||||
// indexes are not merged but appended
|
||||
$this->template_dir[] = rtrim($v, '/\\') . DS;
|
||||
$this->template_dir[] = $v;
|
||||
} else {
|
||||
// string indexes are overridden
|
||||
$this->template_dir[$k] = rtrim($v, '/\\') . DS;
|
||||
$this->template_dir[$k] = $v;
|
||||
}
|
||||
}
|
||||
} elseif ($key !== null) {
|
||||
// override directory at specified index
|
||||
$this->template_dir[$key] = rtrim($template_dir, '/\\') . DS;
|
||||
} else {
|
||||
// append new directory
|
||||
$this->template_dir[] = rtrim($template_dir, '/\\') . DS;
|
||||
$v = str_replace(array('//','\\\\'), DS, rtrim($template_dir, '/\\')) . DS;
|
||||
if ($key !== null) {
|
||||
// override directory at specified index
|
||||
$this->template_dir[$key] = $v;
|
||||
} else {
|
||||
// append new directory
|
||||
$this->template_dir[] = $v;
|
||||
}
|
||||
}
|
||||
$this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
|
||||
|
||||
@ -903,7 +907,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
{
|
||||
$this->config_dir = array();
|
||||
foreach ((array) $config_dir as $k => $v) {
|
||||
$this->config_dir[$k] = rtrim($v, '/\\') . DS;
|
||||
$this->config_dir[$k] = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS;
|
||||
}
|
||||
|
||||
$this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
|
||||
@ -925,20 +929,24 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
|
||||
if (is_array($config_dir)) {
|
||||
foreach ($config_dir as $k => $v) {
|
||||
$v = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS;
|
||||
if (is_int($k)) {
|
||||
// indexes are not merged but appended
|
||||
$this->config_dir[] = rtrim($v, '/\\') . DS;
|
||||
$this->config_dir[] = $v;
|
||||
} else {
|
||||
// string indexes are overridden
|
||||
$this->config_dir[$k] = rtrim($v, '/\\') . DS;
|
||||
$this->config_dir[$k] = $v;
|
||||
}
|
||||
}
|
||||
} elseif ($key !== null) {
|
||||
// override directory at specified index
|
||||
$this->config_dir[$key] = rtrim($config_dir, '/\\') . DS;
|
||||
} else {
|
||||
// append new directory
|
||||
$this->config_dir[] = rtrim($config_dir, '/\\') . DS;
|
||||
$v = str_replace(array('//','\\\\'), DS, rtrim($config_dir, '/\\')) . DS;
|
||||
if ($key !== null) {
|
||||
// override directory at specified index
|
||||
$this->config_dir[$key] = rtrim($v, '/\\') . DS;
|
||||
} else {
|
||||
// append new directory
|
||||
$this->config_dir[] = rtrim($v, '/\\') . DS;
|
||||
}
|
||||
}
|
||||
|
||||
$this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
|
||||
|
@ -32,7 +32,7 @@
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require(dirname(__FILE__) . '/Smarty.class.php');
|
||||
require_once(dirname(__FILE__) . '/Smarty.class.php');
|
||||
|
||||
/**
|
||||
* Smarty Backward Compatability Wrapper Class
|
||||
|
@ -62,7 +62,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
*
|
||||
* Bug: create_function() use exhausts memory when used in long loops
|
||||
* Fix: use declared functions for callbacks instead of using create_function()
|
||||
|
@ -23,7 +23,7 @@ function smarty_literal_compiler_param($params, $index, $default=null)
|
||||
return $default;
|
||||
}
|
||||
// test if param is a literal
|
||||
if (!preg_match('/^([\'"]?)[a-zA-Z0-9]+(\\1)$/', $params[$index])) {
|
||||
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[$index])) {
|
||||
throw new SmartyException('$param[' . $index . '] is not a literal and is thus not evaluatable at compile time');
|
||||
}
|
||||
|
||||
|
@ -372,6 +372,7 @@ class Smarty_Template_Cached
|
||||
{
|
||||
if (!$_template->source->recompiled) {
|
||||
if ($this->handler->writeCachedContent($_template, $content)) {
|
||||
$this->content = null;
|
||||
$this->timestamp = time();
|
||||
$this->exists = true;
|
||||
$this->valid = true;
|
||||
|
@ -186,8 +186,34 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||
{
|
||||
$this->cache = array();
|
||||
$cache_name = null;
|
||||
|
||||
return $this->delete($resource_name, $cache_id, $compile_id, $exp_time);
|
||||
if (isset($resource_name)) {
|
||||
$_save_stat = $smarty->caching;
|
||||
$smarty->caching = true;
|
||||
$tpl = new $smarty->template_class($resource_name, $smarty);
|
||||
$smarty->caching = $_save_stat;
|
||||
|
||||
if ($tpl->source->exists) {
|
||||
$cache_name = $tpl->source->name;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
// remove from template cache
|
||||
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])) {
|
||||
$_templateId = sha1($_templateId);
|
||||
}
|
||||
unset($smarty->template_objects[$_templateId]);
|
||||
// template object no longer needed
|
||||
unset($tpl);
|
||||
}
|
||||
|
||||
return $this->delete($cache_name, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,7 +139,7 @@
|
||||
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
|
||||
$_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
|
||||
$_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
|
||||
$_dir = $smarty->getCacheDir();
|
||||
$_dir = realpath($smarty->getCacheDir());
|
||||
$_dir_length = strlen($_dir);
|
||||
if (isset($_cache_id)) {
|
||||
$_cache_id_parts = explode('|', $_cache_id);
|
||||
|
@ -376,6 +376,13 @@ class Smarty_Internal_Compile_Private_Child_Block extends Smarty_Internal_Compil
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
// update template with original template resource of {block}
|
||||
$compiler->template->template_resource = realpath(trim($_attr['file'], "'"));
|
||||
// source object
|
||||
unset ($compiler->template->source);
|
||||
$exists = $compiler->template->source->exists;
|
||||
|
||||
|
||||
// must merge includes
|
||||
if ($_attr['nocache'] == true) {
|
||||
$compiler->tag_nocache = true;
|
||||
|
@ -166,10 +166,10 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
$nocache = false;
|
||||
$_smarty_tpl = $compiler->template;
|
||||
eval("\$tpl_name = $include_file;");
|
||||
if (!isset($compiler->smarty->merged_templates_func[$tpl_name][$uid]) || $compiler->inheritance) {
|
||||
if (!isset($compiler->smarty->merged_templates_func[$tpl_name][$uid])) {
|
||||
$tpl = new $compiler->smarty->template_class ($tpl_name, $compiler->smarty, $compiler->template, $compiler->template->cache_id, $compiler->template->compile_id);
|
||||
// save unique function name
|
||||
$compiler->smarty->merged_templates_func[$tpl_name][$uid]['func'] = $tpl->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true));
|
||||
$compiler->smarty->merged_templates_func[$tpl_name][$uid]['func'] = $tpl->properties['unifunc'] = 'content_' . str_replace(array('.',','), '_', uniqid('', true));
|
||||
// use current nocache hash for inlined code
|
||||
$compiler->smarty->merged_templates_func[$tpl_name][$uid]['nocache_hash'] = $tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash'];
|
||||
if ($compiler->template->caching && $_caching == self::CACHING_NOCACHE_CODE) {
|
||||
|
@ -32,11 +32,8 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
|
||||
}
|
||||
if ($compiler->template->caching) {
|
||||
// enter nocache mode
|
||||
$this->openTag($compiler, 'nocache', $compiler->nocache);
|
||||
$compiler->nocache = true;
|
||||
}
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
|
||||
@ -65,10 +62,8 @@ class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($compiler->template->caching) {
|
||||
// restore old nocache mode
|
||||
$compiler->nocache = $this->closeTag($compiler, 'nocache');
|
||||
}
|
||||
// leave nocache mode
|
||||
$compiler->nocache = false;
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
/**
|
||||
* Smarty Internal Plugin Configfilelexer
|
||||
*
|
||||
* This is the lexer to break the config file source into tokens
|
||||
* This is the lexer to break the config file source into tokens
|
||||
* @package Smarty
|
||||
* @subpackage Config
|
||||
* @author Uwe Tews
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Configfilelexer
|
||||
@ -24,7 +24,8 @@ class Smarty_Internal_Configfilelexer
|
||||
public $yyTracePrompt;
|
||||
public $state_name = array (1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION', 6 => 'TRIPPLE');
|
||||
public $smarty_token_names = array ( // Text for parser error messages
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
function __construct($data, $smarty)
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
return false;
|
||||
}
|
||||
$this->properties['cache_lifetime'] = $this->cache_lifetime;
|
||||
$this->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true));
|
||||
$this->properties['unifunc'] = 'content_' . str_replace(array('.',','), '_', uniqid('', true));
|
||||
$content = $this->createTemplateCodeFrame($content, true);
|
||||
$_smarty_tpl = $this;
|
||||
eval("?>" . $content);
|
||||
@ -399,7 +399,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
}
|
||||
$this->properties['version'] = Smarty::SMARTY_VERSION;
|
||||
if (!isset($this->properties['unifunc'])) {
|
||||
$this->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true));
|
||||
$this->properties['unifunc'] = 'content_' . str_replace(array('.',','), '_', uniqid('', true));
|
||||
}
|
||||
if (!$this->source->recompiled) {
|
||||
$output .= "\$_valid = \$_smarty_tpl->decodeProperties(" . var_export($this->properties, true) . ',' . ($cache ? 'true' : 'false') . "); /*/%%SmartyHeaderCode%%*/?>\n";
|
||||
|
@ -343,7 +343,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
}
|
||||
// debug output
|
||||
if ($this->smarty->debugging) {
|
||||
Smarty_Internal_Debug::display_debug($this);
|
||||
Smarty_Internal_Debug::display_debug($_template);
|
||||
}
|
||||
if ($merge_tpl_vars) {
|
||||
// restore local variables
|
||||
|
@ -203,7 +203,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->nocache_hash = str_replace('.', '-', uniqid(rand(), true));
|
||||
$this->nocache_hash = str_replace(array('.',','), '-', uniqid(rand(), true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,7 +167,7 @@ class Smarty_Internal_Templatelexer
|
||||
if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G(\\{\\})|\G(".$this->ldel."\\s*\\*([\S\s]*?)\\*\\s*".$this->rdel.")|\G(".$this->ldel."\\s*strip\\s*".$this->rdel.")|\G(".$this->ldel."\\s*\/strip\\s*".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s*setfilter\\s+)|\G(".$this->ldel."\\s*\/)|\G(".$this->ldel."\\s*)|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(\\s*".$this->rdel.")|\G(<%)|\G(%>)|\G([\S\s])/iS";
|
||||
$yy_global_pattern = "/\G(\\{\\})|\G(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|\G(".$this->ldel."\\s*strip\\s*".$this->rdel.")|\G(".$this->ldel."\\s*\/strip\\s*".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s*setfilter\\s+)|\G(".$this->ldel."\\s*\/)|\G(".$this->ldel."\\s*)|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(\\s*".$this->rdel.")|\G(<%)|\G(%>)|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
|
@ -182,7 +182,7 @@ class Smarty_Internal_Utility
|
||||
*/
|
||||
public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty)
|
||||
{
|
||||
$_compile_dir = $smarty->getCompileDir();
|
||||
$_compile_dir = realpath($smarty->getCompileDir());
|
||||
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
|
||||
$_dir_sep = $smarty->use_sub_dirs ? DS : '^';
|
||||
if (isset($resource_name)) {
|
||||
|
@ -38,7 +38,7 @@ class Smarty_Internal_Write_File
|
||||
}
|
||||
|
||||
// write to tmp file, then move to overt file lock race condition
|
||||
$_tmp_file = $_dirpath . DS . uniqid('wrt', true);
|
||||
$_tmp_file = $_dirpath . DS . str_replace(array('.',','), '_', uniqid('wrt', true));
|
||||
if (!file_put_contents($_tmp_file, $_contents)) {
|
||||
error_reporting($_error_reporting);
|
||||
throw new SmartyException("unable to write file {$_tmp_file}");
|
||||
|
Loading…
x
Reference in New Issue
Block a user