Skip to content

Commit

Permalink
- bugfix Class 'Smarty_Internal_Runtime_ValidateCompiled' not found w…
Browse files Browse the repository at this point in the history
…hen upgrading from some older Smarty versions with existing

           compiled or cached template files #269
  • Loading branch information
uwetews committed Aug 14, 2016
1 parent fee77db commit 1b6d2a9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
2 changes: 2 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
===== 3.1.31-dev ===== (xx.xx.xx)
14.08.2016
- bugfix $smarty_>debugging = true; did E_NOTICE messages when {eval} tag was used https://github.com/smarty-php/smarty/issues/266
- bugfix Class 'Smarty_Internal_Runtime_ValidateCompiled' not found when upgrading from some older Smarty versions with existing
compiled or cached template files https://github.com/smarty-php/smarty/issues/269

===== 3.1.30 ===== (07.08.2016)

Expand Down
2 changes: 1 addition & 1 deletion libs/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.31-dev/2';
const SMARTY_VERSION = '3.1.31-dev/3';

/**
* define variable scopes
Expand Down
19 changes: 14 additions & 5 deletions libs/sysplugins/smarty_internal_extension_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@
* @subpackage PluginsInternal
* @author Uwe Tews
*
* @property Smarty_Internal_Runtime_TplFunction $_tplFunction
* @property Smarty_Internal_Runtime_Foreach $_foreach
* @property Smarty_Internal_Runtime_WriteFile $_writeFile
* Runtime extensions
* @property Smarty_Internal_Runtime_CacheModify $_cacheModify
* @property Smarty_Internal_Runtime_Capture $_capture
* @property Smarty_Internal_Runtime_CodeFrame $_codeFrame
* @property Smarty_Internal_Runtime_FilterHandler $_filterHandler
* @property Smarty_Internal_Runtime_Foreach $_foreach
* @property Smarty_Internal_Runtime_GetIncludePath $_getIncludePath
* @property Smarty_Internal_Runtime_UpdateScope $_updateScope
* @property Smarty_Internal_Runtime_CacheModify $_cacheModify
* @property Smarty_Internal_Runtime_Make_Nocache $_make_nocache
* @property Smarty_Internal_Runtime_UpdateCache $_updateCache
* @property Smarty_Internal_Runtime_UpdateScope $_updateScope
* @property Smarty_Internal_Runtime_TplFunction $_tplFunction
* @property Smarty_Internal_Runtime_WriteFile $_writeFile
*
* Method extensions
* @property Smarty_Internal_Method_GetTemplateVars $getTemplateVars
* @property Smarty_Internal_Method_Append $append
* @property Smarty_Internal_Method_AppendByRef $appendByRef
Expand Down Expand Up @@ -64,6 +69,7 @@ public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args)
if (!isset($smarty->ext->$name)) {
$class = 'Smarty_Internal_Method_' . ucfirst($name);
if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
$pn = '';
if (!isset($this->_property_info[ $prop = $match[ 2 ] ])) {
// convert camel case to underscored name
$this->resolvedProperties[ $prop ] = $pn = strtolower(join('_',
Expand Down Expand Up @@ -127,6 +133,9 @@ public function __get($property_name)
} else {
$class = 'Smarty_Internal_Method_' . ucfirst($property_name);
}
if (!class_exists($class)) {
return $this->$property_name = new Smarty_Internal_Undefined($class);
}
return $this->$property_name = new $class();
}

Expand Down
33 changes: 26 additions & 7 deletions libs/sysplugins/smarty_internal_undefined.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/**
* Smarty Method AppendByRef
* Smarty Internal Undefined
*
* Smarty::appendByRef() method
* Class to handle undefined method calls or calls to obsolete runtime extensions
*
* @package Smarty
* @subpackage PluginsInternal
Expand All @@ -13,15 +13,30 @@ class Smarty_Internal_Undefined
{

/**
* This function is executed automatically when a compiled or cached template file is included
* - Decode saved properties from compiled template and cache files
* - Check if compiled or cache file is valid
* Name of undefined extension class
*
* @var string|null
*/
public $class = null;

/**
* Smarty_Internal_Undefined constructor.
*
* @param null|string $class name of undefined extension class
*/
public function __construct($class = null)
{
$this->class = $class;
}

/**
* Wrapper for obsolete class Smarty_Internal_Runtime_ValidateCompiled
*
* @param \Smarty_Internal_Template $tpl
* @param array $properties special template properties
* @param bool $cache flag if called from cache file
*
* @return bool flag if compiled or cache file is valid
* @return bool false
*/
public function decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false)
{
Expand All @@ -44,6 +59,10 @@ public function decodeProperties(Smarty_Internal_Template $tpl, $properties, $ca
*/
public function __call($name, $args)
{
throw new SmartyException(get_class($args[ 0 ]) . "->{$name}() undefined method");
if (isset($this->class)) {
throw new SmartyException("undefined extension class '{$this->class}'");
} else {
throw new SmartyException(get_class($args[ 0 ]) . "->{$name}() undefined method");
}
}
}

0 comments on commit 1b6d2a9

Please sign in to comment.