View Issue Details

IDProjectCategoryView StatusLast Update
0007627mantisbtotherpublic2006-12-07 09:01
Reporteranselm Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
Product Version1.1.0a1 
Summary0007627: bug in gpcget*_array error testing
Description

in core/gpc_api.php, all the gpcget*_array functions use this piece of code :

If we the result isn't the default we were given or an array, error

if ( !( ( ( 1 < func_num_args() ) && ( $t_result === $p_default ) ) ||
is_array( $t_result ) ) ) {
error_parameters( $p_var_name );
trigger_error( ERROR_GPC_ARRAY_EXPECTED, ERROR);
}

However the 'if' statement does not work as expected ! If you expand the '!' into the brackets , you will see that it is equivalent to :
if ( ( !( ( 1 < func_num_args() ) && ( $t_result === $p_default ) ) &&
!is_array( $t_result ) ) ) {

If you do it one more time you get :

if ((( !( 1 < func_num_args() ) || !( $t_result === $p_default ) ) &&
!is_array( $t_result ) ) ) {

One final time, and you get :
if ((( ( 1 >= func_num_args() ) || ( $t_result !== $p_default ) ) &&
!is_array( $t_result ) ) ) {

As (1 >= func_num_args()) is always true, this is equivalent to :

if ($t_result !== $p_default && !is_array($t_result))

Which will only generate an error if the result is not an array and it is not the same as the default. Howver if no default was passed in, and $t_result is null this will not generate an error.

TagsNo tags attached.

Activities

There are no notes attached to this issue.