Skip to content

Commit

Permalink
- bugfix implement wrapper for removed method getConfigVariable() #286
Browse files Browse the repository at this point in the history
  • Loading branch information
uwetews committed Sep 8, 2016
1 parent bfc1ef8 commit 124b333
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 9 deletions.
3 changes: 3 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
===== 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
- 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
Expand Down
2 changes: 1 addition & 1 deletion libs/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.31-dev/12';
const SMARTY_VERSION = '3.1.31-dev/13';

/**
* define variable scopes
Expand Down
1 change: 1 addition & 0 deletions libs/sysplugins/smarty_internal_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* 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
*
* @method mixed getConfigVariable(string $varName, bool $errorEnable = true)
* @method mixed getConfigVars(string $varName = null, bool $searchParents = true)
* @method mixed getGlobal(string $varName = null)
* @method mixed getStreamVariable(string $variable)
Expand Down
16 changes: 8 additions & 8 deletions libs/sysplugins/smarty_internal_method_configload.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function _loadConfigVars(Smarty_Internal_Template $tpl, $new_config_vars)
/**
* Assign all config variables in given scope
*
* @param array $config_vars config variables in scope
* @param array $config_vars config variables in scope
* @param \Smarty_Internal_Template $tpl
* @param array $new_config_vars loaded config variables
*/
Expand Down Expand Up @@ -158,15 +158,15 @@ public function _updateVarStack(Smarty_Internal_Template $tpl, $config_vars)
/**
* gets a config variable value
*
* @param \Smarty_Internal_Template $tpl template object
* @param string $varName the name of the config variable
* @param bool $errorEnable
* @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
* @param string $varName the name of the config variable
* @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) {
if (isset($_ptr->config_vars[ $varName ])) {
// found it, return it
Expand All @@ -175,7 +175,7 @@ public function _getConfigVariable(Smarty_Internal_Template $tpl, $varName, $err
// not found, try at parent
$_ptr = $_ptr->parent;
}
if ($tpl->smarty->error_unassigned && $errorEnable) {
if ($data->smarty->error_unassigned && $errorEnable) {
// force a notice
$x = $$varName;
}
Expand Down
34 changes: 34 additions & 0 deletions libs/sysplugins/smarty_internal_method_getconfigvariable.php
Original file line number Diff line number Diff line change
@@ -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);
}
}
1 change: 1 addition & 0 deletions libs/sysplugins/smarty_internal_testinstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ public static function testInstall(Smarty $smarty, &$errors = null)
'smarty_internal_method_configload.php' => true,
'smarty_internal_method_createdata.php' => true,
'smarty_internal_method_getautoloadfilters.php' => true,
'smarty_internal_method_getconfigvariable.php' => true,
'smarty_internal_method_getconfigvars.php' => true,
'smarty_internal_method_getdebugtemplate.php' => true,
'smarty_internal_method_getdefaultmodifiers.php' => true,
Expand Down

0 comments on commit 124b333

Please sign in to comment.