Skip to content

Commit

Permalink
Fixes #16408: config_eval() fails on configs that reference array values
Browse files Browse the repository at this point in the history
The $g_update_bug_assign_threshold is set to '%handle_bug_threshold%'.
If the value of $g_handle_bug_threshold is set to an array instead of a string/int, a system notice is generated that array to string conversion is done in config_eval().

The fix is to detect the direct assignment case and not use a string replace,
but use normal assignment.  This will make it work for complex types like
arrays.

We still don't support $g_x = '%y%_aaa' where $g_y is not a string or int,
but that shouldn't be an issue.

Signed-off-by: Damien Regad <dregad@mantisbt.org>

Cherry-pick of 1ac581e; Victor's
original commit was amended to follow coding guidelines.
  • Loading branch information
vboctor authored and dregad committed Sep 26, 2013
1 parent cf72f3d commit 4bf9926
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/config_api.php
Expand Up @@ -604,6 +604,15 @@ function config_eval( $p_value, $p_global = false ) {
} else {
$t_repl = config_get( $t_matches[2][$i] );
}

# Handle the simple case where there is no need to do string replace.
# This will resolve the case where the $t_repl value is of non-string
# type, e.g. array of access levels.
if( $t_count == 1 && $p_value == '%' . $t_matches[2][$i] . '%' ) {
$t_value = $t_repl;
break;
}

$t_value = str_replace( $t_matches[1][$i], $t_repl, $t_value );
}
}
Expand Down

0 comments on commit 4bf9926

Please sign in to comment.