View Issue Details

IDProjectCategoryView StatusLast Update
0010672mantisbtotherpublic2010-04-23 23:22
Reporterstappel Assigned Tovboctor  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Product Version1.2.0rc1 
Summary0010672: in_array() warining in core/access_api.php
Description

There are multiple warnings in core_access_api.php:
SYSTEM WARNING: in_array() [function.in-array]: Wrong datatype for second argument

This is due to a check with an empty array().
Lines 169 and 576

line 169:
if( !in_array( (int) $p_user_id, $g_cache_access_matrix_user_ids ) ) {
should be something like:
if( sizeof($g_cache_access_matrix_user_ids) == 0 || !in_array( (int) $p_user_id, $g_cache_access_matrix_user_ids ) ) {

Steps To Reproduce

Up the php error level reporting

TagsNo tags attached.

Activities

vboctor

vboctor

2009-07-04 00:14

manager   ~0022371

Last edited: 2009-07-06 05:50

Calling in_array() on an empty array should not cause a notice/warning. I've double checked to make sure. Looking at the latest code, I can see that the variable is initialized as an empty array and then from then on changed as an array. So it doesn't seem like it is ever set to non-array value which would cause an issue.

Would it be possible to provide us with the repro steps that causes you to see this error. Also once you reproduced, can you var_dump() the array to know what it is set to at the time.

stappel

stappel

2009-07-06 05:40

reporter   ~0022414

After some debugging it seems to be a problem with the pluginmanager from http://deboutv.free.fr/mantis/index.php and the new 1.2.0rc1.

But still the PHP in_array() function will give the "wrong datatype for second argument" warning if the array you are checking is empty or null. In that case, it appears that PHP doesn't know the type of data for the array argument, even if you define it as an array. So it is always wise to check with empty() before an in_array().

If you do not think this second part should be ammended in the source code, you can close this call.

vboctor

vboctor

2009-07-06 05:52

manager   ~0022415

@stappel, thanks for letting us know. Please note that deboutv's plugin manager is not supported. You should really use the new plugin systems with 1.2.x releases. Hopefully more plugins will be available since 1.2.0rc1 is now available.

Please mention in future issues if you have plugin manager or other customizations applied.