View Issue Details

IDProjectCategoryView StatusLast Update
0020476mantisbtcode cleanuppublic2016-06-12 00:43
ReportercproensaAssigned Tocproensa 
Status closedResolutionfixed 
Product Version 
Target Version1.3.0-rc.2Fixed in Version1.3.0-rc.2 
Summary0020476: gpc_get_int_array does not work for associative arrays

using "gpc_get_int_array()" over field named with explicit index does not return the correct array, as indexes are converted to numeric.

fields named: val[10], val[11]

gpc_get_int_array() returns:
[10] => (string)x,
[11] => (string)x,
[0] => (int)x,
[1] => (int)x

The same problem happens with "gpc_get_bool_array()"

TagsNo tags attached.




2016-01-04 19:58

developer   ~0052243




2016-01-04 20:36

manager   ~0052244

@cproensa, what is the bug that you are trying to fix here? Is there a functionality / feature that is broken that this change will fix? If so, we should lead with that and then explain the root cause being the issue with these functions. This way, users reading the changelog would understand the changes and how it affects them.

If it is purely a code cleanup change, then we should be using the code cleanup category.

I looked at the change, and it is fine otherwise. Thanks.



2016-01-04 20:52

developer   ~0052245

It's not a bug that affects the current core because all HTML forms uses array fields without a given index.
Example: input name="foo[]"

However, when using the pattern: input name="foo[N]"
those functions returns invalid data.
This naming pattern is not common, but is needed in some situations. I found while working on a plugin.

Please change category as needed. As you said, there's not a bug currently caused by this. Its a potential for future bugs and for plugin developers, though.



2016-01-05 09:43

developer   ~0052251

Changed category to 'code cleanup' as per vboctor's suggestion, also cleared product version as the 0-based logic has been there for ages.



2016-01-05 10:08

developer   ~0052253


Related Changesets

MantisBT: master b53f7caa

2016-01-04 19:31:59


Committer: dregad Details Diff
Fix gpc_get_xxx_array for associative arrays

- gpc_get_int_array(),
- gpc_get_bool_array()
dont work properly for html fields named with associative indexes
(numeric out or order, or strings), because it assumes indexes as
zero-based sequential numbers.

The code is changed to keep the original keys as defined in the field

This is not an issue in MantisBT core, but may affects plugins.

Fixes 0020476

Signed-off-by: Damien Regad <>
mod - core/gpc_api.php Diff File

MantisBT: master 2ed3c644

2016-01-06 08:04:49


Committer: dregad Details Diff
Fix gpc_get regression

This fixes a regression introduced by commit

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

Issue 0020476

Signed-off-by: Damien Regad <>
mod - core/gpc_api.php Diff File

Issue History

Date Modified Username Field Change
2016-01-04 19:48 cproensa New Issue
2016-01-04 19:58 cproensa Note Added: 0052243
2016-01-04 20:36 vboctor Note Added: 0052244
2016-01-04 20:52 cproensa Note Added: 0052245
2016-01-05 09:43 dregad Assigned To => community
2016-01-05 09:43 dregad Status new => assigned
2016-01-05 09:43 dregad Category bugtracker => code cleanup
2016-01-05 09:43 dregad Product Version 1.3.0-rc.1 =>
2016-01-05 09:43 dregad Target Version => 1.3.0-rc.2
2016-01-05 09:43 dregad Note Added: 0052251
2016-01-05 09:43 dregad Changeset attached => MantisBT master b53f7caa
2016-01-05 09:43 dregad Assigned To community => dregad
2016-01-05 09:43 dregad Status assigned => resolved
2016-01-05 09:43 dregad Resolution open => fixed
2016-01-05 09:43 dregad Fixed in Version => 1.3.0-rc.2
2016-01-05 09:44 dregad Assigned To dregad => community
2016-01-05 10:08 cproensa Note Added: 0052253
2016-01-06 10:48 dregad Changeset attached => MantisBT master 2ed3c644
2016-01-19 15:21 atrol Assigned To community => cproensa
2016-06-12 00:43 vboctor Status resolved => closed