View Issue Details

IDProjectCategoryView StatusLast Update
0030777mantisbtupgradepublic2023-02-22 19:21
Reporterpbeaumadier Assigned Todregad  
PriorityhighSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product Version2.25.3 
Target Version2.25.6Fixed in Version2.25.6 
Summary0030777: Scalar typehint is not supported in PHP 5.x
Description

I upgraded my MantisBT installation from 2.25.2 to 2.25.5.

I followed the usual procedure described in the documentation.

In /admin/install.php everything was green (GOOD) as you can see.

But then when I want to login to the new version, I get an error 500.

Additional Information

OS is Linux RHEL 7.9 with PHP/MariaDB.

The message in the Apache error log file is :

[Wed Jul 13 19:22:58.959808 2022] [:error] [pid 96189] [client 91.178.165.235:34226] PHP Fatal error: Default value for parameters with a class type hint can only be NULL in /mnt/data/apps/mantisbt-2.25.5/core/summary_api.php on line 678

TagsNo tags attached.
Attached Files
Screenshot_Mantis_install.png (52,899 bytes)   
Screenshot_Mantis_install.png (52,899 bytes)   

Relationships

related to 0029846 closeddregad Passing null to parameter of type XXX is deprecated 

Activities

atrol

atrol

2022-07-13 13:58

developer   ~0066806

Which PHP version do you use?

atrol

atrol

2022-07-13 14:02

developer   ~0066807

@dregad your changes in 0029846 broke PHP 5.5 compatibility. Scalar type hints are supported starting from PHP 7.0

pbeaumadier

pbeaumadier

2022-07-13 14:05

reporter   ~0066808

I am using PHP Version 5.6.25

atrol

atrol

2022-07-13 14:28

developer   ~0066809

@pbeaumadier as a quick workaround, changing line 678 in file core/summary_api.php
from

 function summary_print_by_project( array $p_projects = array(), int $p_level = 0, array $p_cache = null, array $p_filter = null ) {

to

 function summary_print_by_project( array $p_projects = array(), $p_level = 0, array $p_cache = null, array $p_filter = null ) {

should fix the issue. (didn't try)

pbeaumadier

pbeaumadier

2022-07-13 14:31

reporter   ~0066810

Thanks, I will try it right now and let you know

pbeaumadier

pbeaumadier

2022-07-13 14:47

reporter   ~0066811

Last edited: 2022-07-13 14:48

So I can confirm it fixes this issue.
No more error 500, no more error in the logs, the application works fine now.

Thanks a lot.

dregad

dregad

2022-07-15 05:46

developer   ~0066812

@dregad your changes in 0029846 broke PHP 5.5 compatibility. Scalar type hints are supported starting from PHP 7.0

Sorry about that, will fix.

lekankou

lekankou

2022-07-22 10:11

reporter   ~0066820

Hello,
I am upgrading my Mantis from 1.2.19 to 2.25.4 and I had another problem due to the same reason.
My PHP version is 5.6.25.
My Mantis seems to work even if my upgrade is not still finished (some of my plugins have to be upgraded), so the tests are in progress.
The problem occurs when I wanted to load the summary page and I got a blank page, without error.
In /XXX/log/php-error.log, I found "PHP Fatal error: Default value for parameters with a class type hint can only be NULL in /XXX/core/summary_api.php on line 678.
Applying the modification fixed the problem.
Thank you.

Related Changesets

MantisBT: master-2.25 9ee6f08e

2022-07-15 12:31

dregad


Details Diff
Remove scalar typehint

Partial revert of 0b814f0f8665b19bb1eeb831803085d46de2ab9f.

This feature is not unsupported in PHP 5.x, and causes a Fatal error:
Default value for parameters with a class type hint can only be NULL
in summary_api.php on line 678.

Fixes 0030777
Affected Issues
0030777
mod - core/summary_api.php Diff File

MantisBT: master acf59c4b

2022-07-15 12:39

dregad


Details Diff
Merge branch 'master-2.25'

We are actually NOT merging the change from commit
9ee6f08e75f6c2824263417103f4624ae67cf92e, as issue 0030777 only exists
with PHP 5.x, and on master we require 7.0 or later.
Affected Issues
0030777