Skip to content

Commit

Permalink
Fix gpc_get regression
Browse files Browse the repository at this point in the history
This fixes a regression introduced by commit
b53f7ca.

When loop is changed into 'foreach', null values produce error
if not checked.

Issue #20476

Signed-off-by: Damien Regad <dregad@mantisbt.org>
  • Loading branch information
cproensa authored and dregad committed Jan 6, 2016
1 parent bddd139 commit 2ed3c64
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions core/gpc_api.php
Expand Up @@ -288,9 +288,10 @@ function gpc_get_int_array( $p_var_name, array $p_default = null ) {
error_parameters( $p_var_name );
trigger_error( ERROR_GPC_ARRAY_EXPECTED, ERROR );
}

foreach( $t_result as $t_key => $t_value ) {
$t_result[$t_key] = (int)$t_value;
if( is_array( $t_result ) ) {
foreach( $t_result as $t_key => $t_value ) {
$t_result[$t_key] = (int)$t_value;
}
}

return $t_result;
Expand All @@ -315,8 +316,10 @@ function gpc_get_bool_array( $p_var_name, array $p_default = null ) {
trigger_error( ERROR_GPC_ARRAY_EXPECTED, ERROR );
}

foreach( $t_result as $t_key => $t_value ) {
$t_result[$t_key] = gpc_string_to_bool( $t_value );
if( is_array( $t_result ) ) {
foreach( $t_result as $t_key => $t_value ) {
$t_result[$t_key] = gpc_string_to_bool( $t_value );
}
}

return $t_result;
Expand Down

0 comments on commit 2ed3c64

Please sign in to comment.