Skip to content

Commit f310ad9

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 297c793 commit f310ad9

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
@@ -189,7 +189,7 @@ function config_get_global( $p_option, $p_default = null ) {
189189
global $g_cache_config_eval;
190190
if( isset( $GLOBALS['g_' . $p_option] ) ) {
191191
if( !isset( $g_cache_config_eval['g_' . $p_option] ) ) {
192-
$t_value = config_eval( $GLOBALS['g_' . $p_option] );
192+
$t_value = config_eval( $GLOBALS['g_' . $p_option], true );
193193
$g_cache_config_eval['g_' . $p_option] = $t_value;
194194
} else {
195195
$t_value = $g_cache_config_eval['g_' . $p_option];
@@ -579,11 +579,17 @@ function config_obsolete( $p_var, $p_replace = '' ) {
579579
}
580580
}
581581

582-
# ------------------
583-
# check for recursion in defining config variables
584-
# If there is a %text% in the returned value, re-evaluate the "text" part and replace
585-
# the string
586-
function config_eval( $p_value ) {
582+
/**
583+
* check for recursion in defining config variables
584+
*
585+
* If there is a %text% in the returned value, re-evaluate the "text"
586+
* part and replace the string
587+
*
588+
* @param string $p_value config variable to evaluate
589+
* @param bool if true, gets %text% as a global config, defaults to false
590+
* @return string
591+
*/
592+
function config_eval( $p_value, $p_global = false ) {
587593
$t_value = $p_value;
588594
if( !empty( $t_value ) && is_string( $t_value ) && !is_numeric( $t_value ) ) {
589595
if( 0 < preg_match_all( '/(?:^|[^\\\\])(%([^%]+)%)/U', $t_value, $t_matches ) ) {
@@ -592,7 +598,11 @@ function config_eval( $p_value ) {
592598

593599
# $t_matches[0][$i] is the matched string including the delimiters
594600
# $t_matches[1][$i] is the target parameter string
595-
$t_repl = config_get( $t_matches[2][$i] );
601+
if( $p_global ) {
602+
$t_repl = config_get_global( $t_matches[2][$i] );
603+
} else {
604+
$t_repl = config_get( $t_matches[2][$i] );
605+
}
596606
$t_value = str_replace( $t_matches[1][$i], $t_repl, $t_value );
597607
}
598608
}

0 commit comments

Comments
 (0)
Please sign in to comment.