View Issue Details

IDProjectCategoryView StatusLast Update
0032086mantisbtbugtrackerpublic2023-04-13 15:42
Reportertk Assigned Todregad  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version2.25.6 
Target Version2.25.7Fixed in Version2.25.7 
Summary0032086: IssueViewPageCommand.php line 135: 'Undefined array key "version" with php 8.1.16
Description

I need to switch from php7 to php 8.1+. To this end I upgraded from mantis 2.25.2 to 2.25.6

With 2.25.6/php 8.1.16 I see the system warning (errors enabled):
SYSTEM WARNING
'Undefined array key "version"' in '<base_path>/core/commands/IssueViewPageCommand.php' line 135

This warning is not shown up with mantis 2.25.6 on my older php 7.4.21 .

Steps To Reproduce

<pre>
$g_display_errors = array(
E_RECOVERABLE_ERROR => DISPLAY_ERROR_HALT,
E_WARNING => DISPLAY_ERROR_HALT,
E_ALL => DISPLAY_ERROR_INLINE,
);
</pre>

Additional Information

PHP Version 8.1.16
Apache/2.4.55 (Unix)
mysqli: mysqlnd 8.1.16

TagsNo tags attached.

Relationships

related to 0031889 closeddregad Product Version / Target Version - Date missing 
has duplicate 0032391 closedatrol Depois de criar tarefa lista mas não abre 
related to 0032098 closeddregad Long initial delay with mantis 2.25.6 and php 8.1.16 
related to 0032353 closedatrol Getting Undefined index: target_version when viewing bug 

Activities

atrol

atrol

2023-03-01 03:13

developer   ~0067430

@dregad looks like a regression caused by 0031889

atrol

atrol

2023-03-01 03:20

developer   ~0067431

@tk be aware that PHP 8.1 is not officially supported, see this note 0031928:0067317

dregad

dregad

2023-03-01 06:17

developer   ~0067432

Thanks for the bug report @tk. After analysis, the regression is actually much worse than a simple PHP warning...

Without $g_display_errors[E_WARNING] = DISPLAY_ERROR_HALT, what we actually get (also on PHP 7.4 and 8.0) is:

APPLICATION ERROR 1601
Version "" not found.

For the record, on PHP 7.4, this is preceded by

SYSTEM NOTICE: 'Undefined index: version' in '...\commands\IssueViewPageCommand.php' line 135
SYSTEM NOTICE: 'Trying to access array offset on value of type null' in '...\core\commands\IssueViewPageCommand.php' line 135

I failed to consider that the mci_issue_data_as_array() API function actually removes null keys and empty arrays from the returned Issue data, so the newly introduced prepared_version_string() should check for array key existence.

I'm not sure how this could have escaped me while testing... Sorry about that.

dregad

dregad

2023-03-01 08:54

developer   ~0067433

I was puzzled that the regression couldn't be reproduced on this tracker, and embarrassingly it took me a while to realize that it's due to display of version dates being disabled here ($g_show_version_dates_threshold = NOBODY;).

dregad

dregad

2023-03-01 11:55

developer   ~0067434

This warning is not shown up with mantis 2.25.6 on my older php 7.4.21 .

@tk this is surprising, as I'm getting the error on PHP 7.4 too...

Anyway, fix in PR https://github.com/mantisbt/mantisbt/pull/1869, testing and feedback welcome.

tk

tk

2023-03-02 04:14

reporter   ~0067436

@dregad
Maybe I had some cached data in my php7.4 test.

I've tested your patch successfully with 8.0.28. Test with php 8.1 will follow as soon as my environment is reconfigured for that again.

As an additional observation, setup of initial mantis window as well as initial login to 2.25.6 with php8.0 takes considerably longer than same installation with php7.4., at least in my scenario with LDAP authentication against MS AD service. Should I open another ticket?

dregad

dregad

2023-03-02 04:23

developer   ~0067437

setup of initial mantis window as well as initial login to 2.25.6 with php8.0 takes considerably longer than same installation with php7.4., at least in my scenario with LDAP authentication against MS AD service. Should I open another ticket?

Not really sure what you mean exactly by setup of initial mantis window and initial login .
On principle every distinct problem should be a separate ticket, but please only open one after performing detailed analysis on your end, demonstrating that the performance degradation is indeed caused by MantisBT code, and not by something environment-specific.

tk

tk

2023-03-03 07:25

reporter   ~0067440

@dregad:
Performed initial tests of the patch with php 8.1.16, looks good!

Regarding performance I've seen rather exactly 60sec delay from call of mantis page in browser until display of login page. After clearance of all browser caches the problem appears to be gone, so this is hard to reproduce (but complicated to explain to my users). I'll see...

dregad

dregad

2023-03-03 10:02

developer   ~0067441

If it's exactly 60s, then maybe there's a timeout somewhere... If you're somehow able to reproduce the problem, maybe you can try to identify the offending request using the browser's network monitor (e.g. ctrl+shift+E on Firefox)

tk

tk

2023-03-03 11:03

reporter   ~0067442

opened 0032098 for delay problem

Related Changesets

MantisBT: master-2.25 6671bc5c

2023-03-01 11:41

dregad


Details Diff
Fix error when displaying Issue without Version

Commit d9464fe8132f6cfd694625c8d050575aed95d5ba introduced a regression
when displaying an Issue without Product, Target or Fixed In Version:

APPLICATION ERROR 1601 - Version "" not found
PHP Notice (or Warning on 8.1+): Undefined array key "version"

This is because mci_issue_data_as_array() removes null keys and empty
arrays from the Issue data, so the IssueViewPageCommand needs to check
for array key existence before calling prepared_version_string().

Fixes 0032086, 0031889
Affected Issues
0031889, 0032086
mod - core/commands/IssueViewPageCommand.php Diff File