View Issue Details

IDProjectCategoryView StatusLast Update
0026439mantisbtuipublic2019-12-16 09:19
Reporterxandros_darkstorm Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Target Version2.24.0Fixed in Version2.24.0 
Summary0026439: Issue list throws warning on every issue without bug notes.
Description

When user opens issue list, the following warnings appear for each issue without bug notes:
"SYSTEM NOTICE: 'Trying to access array offset on value of type bool' in: <filepath_to_mantis>\core\columns_api.php' line 1236"
"SYSTEM NOTICE: 'Trying to access array offset on value of type bool' in: <filepath_to_mantis>\core\columns_api.php' line 1237"

If issue gets a comment (bug note) two warnings disappear.
It was a fresh installation and no additional plugins installed, when this bug was noticed.

Steps To Reproduce
  1. Install Mantis. Create a project.
  2. Create an issue.
  3. Go back to the issue list.
  4. Receive 2 "SYSTEM NOTICE" warnings.
  5. Open newly created issue.
  6. Add a comment on it.
  7. Go back to the issue list.
  8. No warnings anymore; number 1 appears in a bug notes column for the issue.
Additional Information

Server configuration:
PHP 7.4.0
MySQL 8.0.18
Nginx 1.17.6
Windows Server 2008 R2 Datacenter

I have done some research and found that function "print_column_bugnotes_count" in "columns_api.php" causes the problem -- first if condition checks if "$t_bugnote_stats" is null, but never checks if it is "false". $t_bugnote_stats receives boolean value "false" from "bug_api.php" on line 1687 in foreach loop, which assigns that value for all issues without bug notes.
By modifying line 1235 to "if( null !== $t_bugnote_stats && $t_bugnote_stats !== false)" in file "columns_api.php" i resolved the problem.

Tagsphp 7.4

Activities

xandros_darkstorm

xandros_darkstorm

2019-12-08 20:52

reporter  

warnings.png (74,693 bytes)   
warnings.png (74,693 bytes)   
dregad

dregad

2019-12-09 08:22

developer   ~0063203

Thanks for the detailed bug report.

This problem is specific to PHP 7.4, due to implementation of https://wiki.php.net/rfc/notice-for-non-valid-array-container.

In earlier versions, Array dereferencing a scalar value which is not a string silently yields NULL, i.e. without issuing an error message. (source: PHP manual, see note under example 7).

dregad

dregad

2019-12-09 10:52

developer   ~0063214

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

Related Changesets

MantisBT: master 8dc5ead4

2019-12-09 10:48:05

dregad

Details Diff
bug_get_bugnote_stats() returns array|false, not NULL

In PHP 7.3 and earlier, dereferencing a non-array variable simply
returns NULL; starting with 7.4, a SYSTEM NOTICE is triggered.

Adjusting the code to make sure the stats have indeed been returned
(i.e. we got an array) instead of relying on a `!== null` check, which
in any case wrong since bug_get_bugnote_stats() returns false, not NULL.

Also update PHPDoc for bug_get_bugnote_stats() to reflect that.

Fixes 0026439
Affected Issues
0026439
mod - core/bug_api.php Diff File
mod - core/columns_api.php Diff File

Issue History

Date Modified Username Field Change
2019-12-08 20:52 xandros_darkstorm New Issue
2019-12-08 20:52 xandros_darkstorm File Added: warnings.png
2019-12-09 08:22 dregad Status new => confirmed
2019-12-09 08:22 dregad Note Added: 0063203
2019-12-09 08:23 dregad Tag Attached: php 7.4
2019-12-09 10:52 dregad Assigned To => dregad
2019-12-09 10:52 dregad Status confirmed => assigned
2019-12-09 10:52 dregad Note Added: 0063214
2019-12-16 09:10 dregad Changeset attached => MantisBT master 8dc5ead4
2019-12-16 09:10 dregad Status assigned => resolved
2019-12-16 09:10 dregad Resolution open => fixed
2019-12-16 09:10 dregad Fixed in Version => 2.24.0
2019-12-16 09:19 dregad Product Version 2.22.1 =>
2019-12-16 09:19 dregad Target Version => 2.24.0