View Issue Details

IDProjectCategoryView StatusLast Update
0025850mantisbtbugtrackerpublic2021-01-17 09:07
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 16a46b50

2019-01-01 09:55

cproensa

Committer: dregad


Details Diff
Refactor user_pref_api db queries

Refactor db queries that still use hardcoded parameters.
Affected Issues
0025850, 0027113
mod - core/user_pref_api.php Diff File

MantisBT: master 0d2b817f

2019-06-10 06:08

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 06:11

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