View Issue Details

IDProjectCategoryView StatusLast Update
0025850mantisbtbugtrackerpublic2019-08-25 12:36
Reporterdregad Assigned Todregad  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Target Version2.22.0Fixed in Version2.22.0 
Summary0025850: PHP Notices in User API
Description

Noticed the following issues while working on PHPUnit tests:

  • user_pref_cache_array_rows() : DbQuery::fetch_all() can return false if the query execution fails. In that case, the foreach triggers a PHP "Invalid argument supplied for foreach()" warning.
  • user_cache_row() : If the function receives an invalid user ID, it will issue an Undefined offset notice, as it does not check for actual existence of the ID in the users' cache after calling user_cache_array_rows().
TagsNo tags attached.

Activities

There are no notes attached to this issue.

Related Changesets

MantisBT: master 0d2b817f

2019-06-10 10:08:05

dregad

Details Diff
Fix user_pref_cache_array_rows if fetch_all fails

DbQuery::fetch_all() can return false if the query execution fails. In
that case, the foreach triggers a PHP "Invalid argument supplied for
foreach()" warning.

Also, improve code readability by storing the user ID in a variable to
avoid repeated typecasts.

Fixes 0025850
Affected Issues
0025850
mod - core/user_pref_api.php Diff File

MantisBT: master 2cee661c

2019-06-10 10:11:40

dregad

Details Diff
Fix PHP Notice in user_cache_row()

If the function receives an invalid user ID, it will issue an Undefined
offset notice, as it does not check for actual existence of the ID in
the users' cache after calling user_cache_array_rows().

PHPDoc does state that a valid user ID is expected, but since the
function includes error handling code, it makes sense to account for
this case, unlikely as it may be.

Fixes 0025850
Affected Issues
0025850
mod - core/user_api.php Diff File

Issue History

Date Modified Username Field Change
2019-06-10 12:11 dregad New Issue
2019-06-10 12:11 dregad Status new => assigned
2019-06-10 12:11 dregad Assigned To => dregad
2019-06-10 13:26 dregad Changeset attached => MantisBT master 0d2b817f
2019-06-10 13:26 dregad Changeset attached => MantisBT master 2cee661c
2019-06-10 13:26 dregad Status assigned => resolved
2019-06-10 13:26 dregad Resolution open => fixed
2019-06-10 13:26 dregad Fixed in Version => 2.22.0
2019-08-25 12:36 vboctor Status resolved => closed