- cleanup convert cache resource file method clear into runtime extension

This commit is contained in:
uwetews
2016-09-19 16:39:19 +02:00
parent a9e7e8881e
commit d9a6938473
6 changed files with 41 additions and 33 deletions

View File

@@ -1,6 +1,7 @@
===== 3.1.31-dev ===== (xx.xx.xx)
19.09.2016
- optimization clear compiled and cached folder completely on detected version change
- cleanup convert cache resource file method clear into runtime extension
15.09.2016
- bugfix assigning a variable in if condition by function like {if $value = array_shift($array)} the function got called twice https://github.com/smarty-php/smarty/issues/291

View File

@@ -114,7 +114,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.31-dev/24';
const SMARTY_VERSION = '3.1.31-dev/25';
/**
* define variable scopes

View File

@@ -148,7 +148,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function clearAll(Smarty $smarty, $exp_time = null)
{
return Smarty_Internal_Extension_Clear::clear($smarty, null, null, null, $exp_time);
return $smarty->ext->_cacheResourceFile->clear($smarty, null, null, null, $exp_time);
}
/**
@@ -164,7 +164,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
return Smarty_Internal_Extension_Clear::clear($smarty, $resource_name, $cache_id, $compile_id, $exp_time);
return $smarty->ext->_cacheResourceFile->clear($smarty, $resource_name, $cache_id, $compile_id, $exp_time);
}
/**

View File

@@ -11,29 +11,30 @@
* @author Uwe Tews
*
* 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_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
* @property Smarty_Internal_Runtime_CacheModify $_cacheModify
* @property Smarty_Internal_Runtime_CacheResourceFile $_cacheResourceFile
* @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_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
* @property Smarty_Internal_Method_AssignGlobal $assignGlobal
* @property Smarty_Internal_Method_AssignByRef $assignByRef
* @property Smarty_Internal_Method_LoadFilter $loadFilter
* @property Smarty_Internal_Method_LoadPlugin $loadPlugin
* @property Smarty_Internal_Method_RegisterFilter $registerFilter
* @property Smarty_Internal_Method_RegisterObject $registerObject
* @property Smarty_Internal_Method_RegisterPlugin $registerPlugin
* @property Smarty_Internal_Method_GetTemplateVars $getTemplateVars
* @property Smarty_Internal_Method_Append $append
* @property Smarty_Internal_Method_AppendByRef $appendByRef
* @property Smarty_Internal_Method_AssignGlobal $assignGlobal
* @property Smarty_Internal_Method_AssignByRef $assignByRef
* @property Smarty_Internal_Method_LoadFilter $loadFilter
* @property Smarty_Internal_Method_LoadPlugin $loadPlugin
* @property Smarty_Internal_Method_RegisterFilter $registerFilter
* @property Smarty_Internal_Method_RegisterObject $registerObject
* @property Smarty_Internal_Method_RegisterPlugin $registerPlugin
*/
class Smarty_Internal_Extension_Handler
{
@@ -76,8 +77,8 @@ class Smarty_Internal_Extension_Handler
preg_split('/([A-Z][^A-Z]*)/', $prop,
- 1, PREG_SPLIT_NO_EMPTY |
PREG_SPLIT_DELIM_CAPTURE)));
$this->_property_info[ $prop ] = property_exists($data, $pn) ? 1 :
($data->_isTplObj() && property_exists($smarty, $pn) ? 2 : 0);
$this->_property_info[ $prop ] =
property_exists($data, $pn) ? 1 : ($data->_isTplObj() && property_exists($smarty, $pn) ? 2 : 0);
}
if ($this->_property_info[ $prop ]) {
$pn = $this->resolvedProperties[ $prop ];
@@ -111,7 +112,8 @@ class Smarty_Internal_Extension_Handler
*
* @return string
*/
public function upperCase($name) {
public function upperCase($name)
{
$_name = explode('_', $name);
$_name = array_map('ucfirst', $_name);
return implode('_', $_name);

View File

@@ -1,15 +1,20 @@
<?php
/**
* Smarty Extension Clear
*
* $smarty->clear() method file cache file resource
* Smarty cache resource file clear method
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
class Smarty_Internal_Extension_Clear
/**
* Smarty Internal Runtime Cache Resource File Class
*
* @package Smarty
* @subpackage PluginsInternal
*/
class Smarty_Internal_Runtime_CacheResourceFile
{
/**
* Empty cache for a specific template
@@ -22,7 +27,7 @@ class Smarty_Internal_Extension_Clear
*
* @return integer number of cache files deleted
*/
public static function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
$_compile_id = isset($compile_id) ? preg_replace('![^\w]+!', '_', $compile_id) : null;

View File

@@ -406,7 +406,6 @@ class Smarty_Internal_TestInstall
'smarty_internal_configfileparser.php' => true,
'smarty_internal_config_file_compiler.php' => true,
'smarty_internal_data.php' => true, 'smarty_internal_debug.php' => true,
'smarty_internal_extension_clear.php' => true,
'smarty_internal_extension_handler.php' => true,
'smarty_internal_method_addautoloadfilters.php' => true,
'smarty_internal_method_adddefaultmodifiers.php' => true,
@@ -471,6 +470,7 @@ class Smarty_Internal_TestInstall
'smarty_internal_resource_stream.php' => true,
'smarty_internal_resource_string.php' => true,
'smarty_internal_runtime_cachemodify.php' => true,
'smarty_internal_runtime_cacheresourcefile.php' => true,
'smarty_internal_runtime_capture.php' => true,
'smarty_internal_runtime_codeframe.php' => true,
'smarty_internal_runtime_filterhandler.php' => true,