Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 74dc549

Browse files
committedDec 15, 2011
Inconsistent config_eval behavior with global configs
When config_eval() is called from config_get_global() to resolve a recursive config definition, it should call config_get_global() in return. This caused incorrect highlighting of some settings as being overriden in the Workflow Thresholds page, more specifically those configs defined as having the same value as another one, e.g. $g_update_bug_assign_threshold = '%handle_bug_threshold%' The problem was fixed by adding an optional parameter to config_eval() to specify if it is called in a global context or not. Fixes #13683
1 parent 0f702d5 commit 74dc549

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed
 

‎core/config_api.php

+17-7
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function config_get_global( $p_option, $p_default = null ) {
178178
global $g_cache_config_eval;
179179
if( isset( $GLOBALS['g_' . $p_option] ) ) {
180180
if( !isset( $g_cache_config_eval['g_' . $p_option] ) ) {
181-
$t_value = config_eval( $GLOBALS['g_' . $p_option] );
181+
$t_value = config_eval( $GLOBALS['g_' . $p_option], true );
182182
$g_cache_config_eval['g_' . $p_option] = $t_value;
183183
} else {
184184
$t_value = $g_cache_config_eval['g_' . $p_option];
@@ -568,11 +568,17 @@ function config_obsolete( $p_var, $p_replace = '' ) {
568568
}
569569
}
570570

571-
# ------------------
572-
# check for recursion in defining config variables
573-
# If there is a %text% in the returned value, re-evaluate the "text" part and replace
574-
# the string
575-
function config_eval( $p_value ) {
571+
/**
572+
* check for recursion in defining config variables
573+
*
574+
* If there is a %text% in the returned value, re-evaluate the "text"
575+
* part and replace the string
576+
*
577+
* @param string $p_value config variable to evaluate
578+
* @param bool if true, gets %text% as a global config, defaults to false
579+
* @return string
580+
*/
581+
function config_eval( $p_value, $p_global = false ) {
576582
$t_value = $p_value;
577583
if( !empty( $t_value ) && is_string( $t_value ) && !is_numeric( $t_value ) ) {
578584
if( 0 < preg_match_all( '/(?:^|[^\\\\])(%([^%]+)%)/U', $t_value, $t_matches ) ) {
@@ -581,7 +587,11 @@ function config_eval( $p_value ) {
581587

582588
# $t_matches[0][$i] is the matched string including the delimiters
583589
# $t_matches[1][$i] is the target parameter string
584-
$t_repl = config_get( $t_matches[2][$i] );
590+
if( $p_global ) {
591+
$t_repl = config_get_global( $t_matches[2][$i] );
592+
} else {
593+
$t_repl = config_get( $t_matches[2][$i] );
594+
}
585595
$t_value = str_replace( $t_matches[1][$i], $t_repl, $t_value );
586596
}
587597
}

0 commit comments

Comments
 (0)
Please sign in to comment.