Merge branch 'v3.1.18'

This commit is contained in:
Uwe Tews
2014-10-31 02:15:15 +01:00
12 changed files with 2830 additions and 2698 deletions

View File

@@ -1,5 +1,42 @@
===== trunk ===== ===== 3.1.19-dev ===== (xx.xx.2014)
19.04.2014
- bugfix calling createTemplate(template, data) with empty data array caused notice of array to string conversion (Issue 189)
- bugfix clearCompiledTemplate() did not delete files on WINDOWS when a compile_id was specified
18.04.2014
- revert bugfix of 5.4.2015 because %-e date format is not supported on all operating systems
===== 3.1.18 ===== (07.04.2014)
06.04.2014
- bugfix template inheritance fail when using custom resource after patch of 8.3.2014 (Issue 187)
- bugfix update of composer file (Issue 168 and 184)
05.04.2014
- bugfix default date format leads to extra spaces when displaying dates with single digit days (Issue 165)
26.03.2014
- bugfix Smart_Resource_Custom should not lowercase the resource name (Issue 183)
24.03.2014
- bugfix using a {foreach} property like @iteration could fail when used in inheritance parent templates (Issue 182)
20.03.2014
- bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899)
18.03.2014
- revert change of 17.03.2014
17.03.2014
- bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899)
15.03.2014
- bugfix Smarty_CacheResource_Keyvaluestore did use different keys on read/writes and clearCache() calls (Issue 169)
13.03.2014
- bugfix clearXxx() change of 27.1.2014 did not work when specifing cache_id or compile_id (forum topic 24868 and 24867)
===== 3.1.17 ===== ===== 3.1.17 =====
08.03.2014 08.03.2014
- bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177) - bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177)

View File

@@ -113,7 +113,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = 'Smarty-3.1-DEV'; const SMARTY_VERSION = 'Smarty-3.1.19-dev';
/** /**
* define variable scopes * define variable scopes
@@ -1220,11 +1220,11 @@ class Smarty extends Smarty_Internal_TemplateBase
*/ */
public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true) public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true)
{ {
if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) { if ($cache_id !== null && (is_object($cache_id) || is_array($cache_id))) {
$parent = $cache_id; $parent = $cache_id;
$cache_id = null; $cache_id = null;
} }
if (!empty($parent) && is_array($parent)) { if ($parent !== null && is_array($parent)) {
$data = $parent; $data = $parent;
$parent = null; $parent = null;
} else { } else {

View File

@@ -54,7 +54,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template) public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
{ {
$cached->filepath = $_template->source->uid $cached->filepath = $_template->source->uid
. '#' . $this->sanitize($cached->source->name) . '#' . $this->sanitize($cached->source->resource)
. '#' . $this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->cache_id)
. '#' . $this->sanitize($cached->compile_id); . '#' . $this->sanitize($cached->compile_id);

View File

@@ -139,7 +139,7 @@
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
$_dir_sep = $smarty->use_sub_dirs ? '/' : '^'; $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
$_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0; $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
$_dir = realpath($smarty->getCacheDir()); $_dir = realpath($smarty->getCacheDir()) . '/';
$_dir_length = strlen($_dir); $_dir_length = strlen($_dir);
if (isset($_cache_id)) { if (isset($_cache_id)) {
$_cache_id_parts = explode('|', $_cache_id); $_cache_id_parts = explode('|', $_cache_id);

View File

@@ -84,7 +84,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase
$this->template->block_data[$_name]['source'] = ''; $this->template->block_data[$_name]['source'] = '';
// build {block} for child block // build {block} for child block
self::$block_data[$_name]['source'] = self::$block_data[$_name]['source'] =
"{$compiler->smarty->left_delimiter}private_child_block name={$_attr['name']} file='{$compiler->template->source->filepath}'" . "{$compiler->smarty->left_delimiter}private_child_block name={$_attr['name']} file='{$compiler->template->source->filepath}' type='{$compiler->template->source->type}' resource='{$compiler->template->template_resource}'" .
" uid='{$compiler->template->source->uid}' line={$compiler->lex->line}"; " uid='{$compiler->template->source->uid}' line={$compiler->lex->line}";
if ($_attr['nocache']) { if ($_attr['nocache']) {
self::$block_data[$_name]['source'] .= ' nocache'; self::$block_data[$_name]['source'] .= ' nocache';
@@ -361,7 +361,7 @@ class Smarty_Internal_Compile_Private_Child_Block extends Smarty_Internal_Compil
* @var array * @var array
* @see Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase
*/ */
public $required_attributes = array('name', 'file', 'uid', 'line'); public $required_attributes = array('name', 'file', 'uid', 'line', 'type', 'resource');
/** /**
@@ -377,7 +377,11 @@ class Smarty_Internal_Compile_Private_Child_Block extends Smarty_Internal_Compil
$_attr = $this->getAttributes($compiler, $args); $_attr = $this->getAttributes($compiler, $args);
// update template with original template resource of {block} // update template with original template resource of {block}
$compiler->template->template_resource = realpath(trim($_attr['file'], "'")); if (trim($_attr['type'], "'") == 'file') {
$compiler->template->template_resource = realpath(trim($_attr['file'], "'"));
} else {
$compiler->template->template_resource = trim($_attr['resource'], "'");
}
// source object // source object
unset ($compiler->template->source); unset ($compiler->template->source);
$exists = $compiler->template->source->exists; $exists = $compiler->template->source->exists;

View File

@@ -49,7 +49,6 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase
*/ */
public function compile($args, $compiler, $parameter) public function compile($args, $compiler, $parameter)
{ {
$tpl = $compiler->template;
// check and get attributes // check and get attributes
$_attr = $this->getAttributes($compiler, $args); $_attr = $this->getAttributes($compiler, $args);
@@ -80,12 +79,12 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase
$ItemVarName = '$' . trim($item, '\'"') . '@'; $ItemVarName = '$' . trim($item, '\'"') . '@';
// evaluates which Smarty variables and properties have to be computed // evaluates which Smarty variables and properties have to be computed
if ($has_name) { if ($has_name) {
$usesSmartyFirst = strpos($tpl->source->content, $SmartyVarName . 'first') !== false; $usesSmartyFirst = strpos($compiler->lex->data, $SmartyVarName . 'first') !== false;
$usesSmartyLast = strpos($tpl->source->content, $SmartyVarName . 'last') !== false; $usesSmartyLast = strpos($compiler->lex->data, $SmartyVarName . 'last') !== false;
$usesSmartyIndex = strpos($tpl->source->content, $SmartyVarName . 'index') !== false; $usesSmartyIndex = strpos($compiler->lex->data, $SmartyVarName . 'index') !== false;
$usesSmartyIteration = strpos($tpl->source->content, $SmartyVarName . 'iteration') !== false; $usesSmartyIteration = strpos($compiler->lex->data, $SmartyVarName . 'iteration') !== false;
$usesSmartyShow = strpos($tpl->source->content, $SmartyVarName . 'show') !== false; $usesSmartyShow = strpos($compiler->lex->data, $SmartyVarName . 'show') !== false;
$usesSmartyTotal = strpos($tpl->source->content, $SmartyVarName . 'total') !== false; $usesSmartyTotal = strpos($compiler->lex->data, $SmartyVarName . 'total') !== false;
} else { } else {
$usesSmartyFirst = false; $usesSmartyFirst = false;
$usesSmartyLast = false; $usesSmartyLast = false;
@@ -93,12 +92,12 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase
$usesSmartyShow = false; $usesSmartyShow = false;
} }
$usesPropFirst = $usesSmartyFirst || strpos($tpl->source->content, $ItemVarName . 'first') !== false; $usesPropFirst = $usesSmartyFirst || strpos($compiler->lex->data, $ItemVarName . 'first') !== false;
$usesPropLast = $usesSmartyLast || strpos($tpl->source->content, $ItemVarName . 'last') !== false; $usesPropLast = $usesSmartyLast || strpos($compiler->lex->data, $ItemVarName . 'last') !== false;
$usesPropIndex = $usesPropFirst || strpos($tpl->source->content, $ItemVarName . 'index') !== false; $usesPropIndex = $usesPropFirst || strpos($compiler->lex->data, $ItemVarName . 'index') !== false;
$usesPropIteration = $usesPropLast || strpos($tpl->source->content, $ItemVarName . 'iteration') !== false; $usesPropIteration = $usesPropLast || strpos($compiler->lex->data, $ItemVarName . 'iteration') !== false;
$usesPropShow = strpos($tpl->source->content, $ItemVarName . 'show') !== false; $usesPropShow = strpos($compiler->lex->data, $ItemVarName . 'show') !== false;
$usesPropTotal = $usesSmartyTotal || $usesSmartyShow || $usesPropShow || $usesPropLast || strpos($tpl->source->content, $ItemVarName . 'total') !== false; $usesPropTotal = $usesSmartyTotal || $usesSmartyShow || $usesPropShow || $usesPropLast || strpos($compiler->lex->data, $ItemVarName . 'total') !== false;
// generate output code // generate output code
$output = "<?php "; $output = "<?php ";
$output .= " \$_smarty_tpl->tpl_vars[$item] = new Smarty_Variable; \$_smarty_tpl->tpl_vars[$item]->_loop = false;\n"; $output .= " \$_smarty_tpl->tpl_vars[$item] = new Smarty_Variable; \$_smarty_tpl->tpl_vars[$item]->_loop = false;\n";

View File

@@ -34,7 +34,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
if ($template === null && $this instanceof $this->template_class) { if ($template === null && $this instanceof $this->template_class) {
$template = $this; $template = $this;
} }
if (!empty($cache_id) && is_object($cache_id)) { if ($cache_id !== null && is_object($cache_id)) {
$parent = $cache_id; $parent = $cache_id;
$cache_id = null; $cache_id = null;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -182,9 +182,9 @@ class Smarty_Internal_Utility
*/ */
public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty) public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty)
{ {
$_compile_dir = realpath($smarty->getCompileDir()); $_compile_dir = realpath($smarty->getCompileDir()).'/';
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
$_dir_sep = $smarty->use_sub_dirs ? DS : '^'; $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
if (isset($resource_name)) { if (isset($resource_name)) {
$_save_stat = $smarty->caching; $_save_stat = $smarty->caching;
$smarty->caching = false; $smarty->caching = false;
@@ -218,7 +218,7 @@ class Smarty_Internal_Utility
$_dir .= $_compile_id . $_dir_sep; $_dir .= $_compile_id . $_dir_sep;
} }
if (isset($_compile_id)) { if (isset($_compile_id)) {
$_compile_id_part = $_compile_dir . $_compile_id . $_dir_sep; $_compile_id_part = str_replace('\\','/',$_compile_dir . $_compile_id . $_dir_sep);
$_compile_id_part_length = strlen($_compile_id_part); $_compile_id_part_length = strlen($_compile_id_part);
} }
$_count = 0; $_count = 0;
@@ -233,7 +233,7 @@ class Smarty_Internal_Utility
if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false)
continue; continue;
$_filepath = (string) $_file; $_filepath = str_replace('\\','/',(string) $_file);
if ($_file->isDir()) { if ($_file->isDir()) {
if (!$_compile->isDot()) { if (!$_compile->isDot()) {
@@ -242,7 +242,7 @@ class Smarty_Internal_Utility
} }
} else { } else {
$unlink = false; $unlink = false;
if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && $a = !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length)))
&& (!isset($resource_name) && (!isset($resource_name)
|| (isset($_filepath[$_resource_part_1_length]) || (isset($_filepath[$_resource_part_1_length])
&& substr_compare($_filepath, $_resource_part_1, -$_resource_part_1_length, $_resource_part_1_length) == 0) && substr_compare($_filepath, $_resource_part_1, -$_resource_part_1_length, $_resource_part_1_length) == 0)

View File

@@ -48,7 +48,7 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource
*/ */
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null) public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
{ {
$source->filepath = strtolower($source->type . ':' . $source->name); $source->filepath = $source->type . ':' . $source->name;
$source->uid = sha1($source->type . ':' . $source->name); $source->uid = sha1($source->type . ':' . $source->name);
$mtime = $this->fetchTimestamp($source->name); $mtime = $this->fetchTimestamp($source->name);