From 2bab2f147d67891830dd38dad45f4dd39a8c8bb6 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Tue, 24 Nov 2009 20:33:40 +0000 Subject: [PATCH] - bugfix for $smarty->config_overwrite = false --- change_log.txt | 3 +++ libs/sysplugins/smarty_internal_config.php | 14 +++++++++++--- .../smarty_internal_configfileparser.php | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/change_log.txt b/change_log.txt index f5a5c4b5..3c44c365 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +11/24/2009 +- bugfix for $smarty->config_overwrite = false + 11/23/2009 - suppress warnings on unlink caused by race conditions - correct line number on unknown tag error message diff --git a/libs/sysplugins/smarty_internal_config.php b/libs/sysplugins/smarty_internal_config.php index 8e188ded..d3daeac1 100644 --- a/libs/sysplugins/smarty_internal_config.php +++ b/libs/sysplugins/smarty_internal_config.php @@ -228,18 +228,26 @@ class Smarty_Internal_Config { $this->template->properties['file_dependency']['F' . abs(crc32($this->getConfigFilepath()))] = array($this->getConfigFilepath(), $this->getTimestamp()); } else { $this->smarty->properties['file_dependency']['F' . abs(crc32($this->getConfigFilepath()))] = array($this->getConfigFilepath(), $this->getTimestamp()); - } + } $config_data = unserialize($this->getCompiledConfig()); // var_dump($config_data); // copy global config vars foreach ($config_data['vars'] as $variable => $value) { - $scope->config_vars[$variable] = $value; + if ($this->smarty->config_overwrite || !isset($scope->config_vars[$variable])) { + $scope->config_vars[$variable] = $value; + } else { + $scope->config_vars[$variable] = array_merge((array)$scope->config_vars[$variable], (array)$value); + } } // scan sections foreach ($config_data['sections'] as $this_section => $dummy) { if ($sections == null || in_array($this_section, (array)$sections)) { foreach ($config_data['sections'][$this_section]['vars'] as $variable => $value) { - $scope->config_vars[$variable] = $value; + if ($this->smarty->config_overwrite || !isset($scope->config_vars[$variable])) { + $scope->config_vars[$variable] = $value; + } else { + $scope->config_vars[$variable] = array_merge((array)$scope->config_vars[$variable], (array)$value); + } } } } diff --git a/libs/sysplugins/smarty_internal_configfileparser.php b/libs/sysplugins/smarty_internal_configfileparser.php index 97683f8b..0a47ee48 100644 --- a/libs/sysplugins/smarty_internal_configfileparser.php +++ b/libs/sysplugins/smarty_internal_configfileparser.php @@ -856,14 +856,14 @@ static public $yy_action = array( $value = false; } if ($this->current_section == null) { - if ($this->smarty->config_overwrite) { + if ($this->smarty->config_overwrite || !isset($this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor])) { $this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor]=$value; } else { settype($this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor], 'array'); $this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor][]=$value; } } else { - if ($this->smarty->config_overwrite) { + if ($this->smarty->config_overwrite || !isset($this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor])) { $this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor]=$value; } else { settype($this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor], 'array');