View Issue Details

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

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

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

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

The same problem happens with "gpc_get_bool_array()"

TagsNo tags attached.

Activities

cproensa

cproensa

2016-01-04 19:58

developer   ~0052243

PR: https://github.com/mantisbt/mantisbt/pull/701

vboctor

vboctor

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.

cproensa

cproensa

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: <i> input name="foo[]" </i>

However, when using the pattern: <i> input name="foo[N]" </i>
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.

dregad

dregad

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.

cproensa

cproensa

2016-01-05 10:08

developer   ~0052253

thanks!

Related Changesets

MantisBT: master b53f7caa

2016-01-04 14:31

cproensa

Committer: dregad


Details Diff
Fix gpc_get_xxx_array for associative arrays

Functions:
- 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
names.

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

Fixes 0020476

Signed-off-by: Damien Regad <dregad@mantisbt.org>
Affected Issues
0020476
mod - core/gpc_api.php Diff File

MantisBT: master 2ed3c644

2016-01-06 03:04

cproensa

Committer: dregad


Details Diff
Fix gpc_get regression

This fixes a regression introduced by commit
b53f7caace3513d544149a18beb8f1e422e9a96e.

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

Issue 0020476

Signed-off-by: Damien Regad <dregad@mantisbt.org>
Affected Issues
0020476
mod - core/gpc_api.php Diff File