- bugfix implement wrapper for removed method getConfigVariable() https://github.com/smarty-php/smarty/issues/286

This commit is contained in:
uwetews
2016-09-08 22:28:06 +02:00
parent bfc1ef8885
commit 124b333da2
6 changed files with 48 additions and 9 deletions

View File

@@ -1,4 +1,7 @@
===== 3.1.31-dev ===== (xx.xx.xx) ===== 3.1.31-dev ===== (xx.xx.xx)
08.09.2016
- bugfix implement wrapper for removed method getConfigVariable() https://github.com/smarty-php/smarty/issues/286
07.09.2016 07.09.2016
- bugfix using nocache like attribute with value true like {plugin nocache=true} did not work https://github.com/smarty-php/smarty/issues/285 - bugfix using nocache like attribute with value true like {plugin nocache=true} did not work https://github.com/smarty-php/smarty/issues/285
- bugfix uppercase TRUE, FALSE and NULL did not work when security was enabled https://github.com/smarty-php/smarty/issues/282 - bugfix uppercase TRUE, FALSE and NULL did not work when security was enabled https://github.com/smarty-php/smarty/issues/282

View File

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

View File

@@ -18,6 +18,7 @@
* The following methods will be dynamically loaded by the extension handler when they are called. * The following methods will be dynamically loaded by the extension handler when they are called.
* They are located in a corresponding Smarty_Internal_Method_xxxx class * They are located in a corresponding Smarty_Internal_Method_xxxx class
* *
* @method mixed getConfigVariable(string $varName, bool $errorEnable = true)
* @method mixed getConfigVars(string $varName = null, bool $searchParents = true) * @method mixed getConfigVars(string $varName = null, bool $searchParents = true)
* @method mixed getGlobal(string $varName = null) * @method mixed getGlobal(string $varName = null)
* @method mixed getStreamVariable(string $variable) * @method mixed getStreamVariable(string $variable)

View File

@@ -158,15 +158,15 @@ class Smarty_Internal_Method_ConfigLoad
/** /**
* gets a config variable value * gets a config variable value
* *
* @param \Smarty_Internal_Template $tpl template object * @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
* @param string $varName the name of the config variable * @param string $varName the name of the config variable
* @param bool $errorEnable * @param bool $errorEnable
* *
* @return mixed the value of the config variable * @return null|string the value of the config variable
*/ */
public function _getConfigVariable(Smarty_Internal_Template $tpl, $varName, $errorEnable = true) public function _getConfigVariable(Smarty_Internal_Data $data, $varName, $errorEnable = true)
{ {
$_ptr = $tpl; $_ptr = $data;
while ($_ptr !== null) { while ($_ptr !== null) {
if (isset($_ptr->config_vars[ $varName ])) { if (isset($_ptr->config_vars[ $varName ])) {
// found it, return it // found it, return it
@@ -175,7 +175,7 @@ class Smarty_Internal_Method_ConfigLoad
// not found, try at parent // not found, try at parent
$_ptr = $_ptr->parent; $_ptr = $_ptr->parent;
} }
if ($tpl->smarty->error_unassigned && $errorEnable) { if ($data->smarty->error_unassigned && $errorEnable) {
// force a notice // force a notice
$x = $$varName; $x = $$varName;
} }

View File

@@ -0,0 +1,34 @@
<?php
/**
* Smarty Method GetConfigVariable
*
* Smarty::getConfigVariable() method
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
class Smarty_Internal_Method_GetConfigVariable
{
/**
* Valid for all objects
*
* @var int
*/
public $objMap = 7;
/**
* gets a config variable value
*
* @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
* @param string $varName the name of the config variable
* @param bool $errorEnable
*
* @return null|string the value of the config variable
*/
public function getConfigVariable(Smarty_Internal_Data $data, $varName = null, $errorEnable = true)
{
return $data->ext->configLoad->_getConfigVariable($data, $varName, $errorEnable);
}
}

View File

@@ -425,6 +425,7 @@ class Smarty_Internal_TestInstall
'smarty_internal_method_configload.php' => true, 'smarty_internal_method_configload.php' => true,
'smarty_internal_method_createdata.php' => true, 'smarty_internal_method_createdata.php' => true,
'smarty_internal_method_getautoloadfilters.php' => true, 'smarty_internal_method_getautoloadfilters.php' => true,
'smarty_internal_method_getconfigvariable.php' => true,
'smarty_internal_method_getconfigvars.php' => true, 'smarty_internal_method_getconfigvars.php' => true,
'smarty_internal_method_getdebugtemplate.php' => true, 'smarty_internal_method_getdebugtemplate.php' => true,
'smarty_internal_method_getdefaultmodifiers.php' => true, 'smarty_internal_method_getdefaultmodifiers.php' => true,