- change version checking

This commit is contained in:
uwetews
2016-11-19 18:13:00 +01:00
parent 91af9d090a
commit 04a2327c75
3 changed files with 9 additions and 27 deletions

View File

@@ -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

View File

@@ -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
*

View File

@@ -420,8 +420,12 @@ 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' ]) {
if (!isset($properties[ 'version' ]) || Smarty::SMARTY_VERSION !== $properties[ 'version' ]) {
if ($cache) {
$tpl->smarty->clearAllCache();
} else {
$tpl->smarty->clearCompiledTemplate();
}
return false;
}
$is_valid = true;