From 04a2327c75cee3481fb0bb9205ef32335d2f7b92 Mon Sep 17 00:00:00 2001 From: uwetews Date: Sat, 19 Nov 2016 18:13:00 +0100 Subject: [PATCH] - change version checking --- change_log.txt | 1 + libs/Smarty.class.php | 25 +------------------- libs/sysplugins/smarty_internal_template.php | 10 +++++--- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/change_log.txt b/change_log.txt index eb8d6133..6dd8c150 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,6 +2,7 @@ 19.11.2016 - bugfix inheritance root child templates containing nested {block}{/block} could call sub-bock content from parent template https://github.com/smarty-php/smarty/issues/317 + - change version checking 11.11.2016 - bugfix when Smarty is using a cached template object on Smarty::fetch() or Smarty::isCached() the inheritance data diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index c247ac6e..ee93082d 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -108,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.31-dev/45'; + const SMARTY_VERSION = '3.1.31-dev/46'; /** * define variable scopes @@ -1008,9 +1008,6 @@ class Smarty extends Smarty_Internal_TemplateBase if (!$this->_compileDirNormalized) { $this->_normalizeDir('compile_dir', $this->compile_dir); $this->_compileDirNormalized = true; - if ($this->_isNewRelease($this->compile_dir)) { - $this->clearCompiledTemplate(); - } } return $this->compile_dir; } @@ -1039,9 +1036,6 @@ class Smarty extends Smarty_Internal_TemplateBase if (!$this->_cacheDirNormalized) { $this->_normalizeDir('cache_dir', $this->cache_dir); $this->_cacheDirNormalized = true; - if ($this->_isNewRelease($this->cache_dir)) { - $this->clearAllCache(); - } } return $this->cache_dir; } @@ -1258,23 +1252,6 @@ class Smarty extends Smarty_Internal_TemplateBase $this->_cache[ 'tplObjects' ] = array(); } - /** - * check if new release was installed - * - * @param string $dir compiled oder cache dir path - * - * @return bool - */ - public function _isNewRelease($dir) - { - if (!is_file($file = $dir . preg_replace('#[^a-zA-Z0-9.-]#', '.', Smarty::SMARTY_VERSION) . 'version.txt')) { - file_put_contents($file, Smarty::SMARTY_VERSION); - return true; - } else { - return false; - } - } - /** * Get Smarty object * diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index 5096eee3..8545740e 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -420,13 +420,17 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase public function _decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false) { // on cache resources other than file check version stored in cache code - if ($cache && $tpl->smarty->caching_type !== 'file' && Smarty::SMARTY_VERSION !== $properties[ 'version' ]) { - $tpl->smarty->clearAllCache(); + if (!isset($properties[ 'version' ]) || Smarty::SMARTY_VERSION !== $properties[ 'version' ]) { + if ($cache) { + $tpl->smarty->clearAllCache(); + } else { + $tpl->smarty->clearCompiledTemplate(); + } return false; } $is_valid = true; if (!empty($properties[ 'file_dependency' ]) && - ((!$cache && $tpl->smarty->compile_check) || $tpl->smarty->compile_check == 1) + ((!$cache && $tpl->smarty->compile_check) || $tpl->smarty->compile_check == 1) ) { // check file dependencies at compiled code foreach ($properties[ 'file_dependency' ] as $_file_to_check) {