View Issue Details

IDProjectCategoryView StatusLast Update
0032866mantisbtapi restpublic2023-11-13 06:08
Reporterdregad Assigned Todregad  
Status closedResolutionfixed 
Target Version2.26.0Fixed in Version2.26.0 
Summary0032866: Allow REST API to run on PHP 8.1 without squelching E_DEPRECATED notices

In 0031678 it was identified that, while Slim 3.x is not officially supported under PHP 8.1+, the framework only triggers some harmless deprecation warnings. The suggested workaround was to set the following in php.ini:

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 
display_errors = Off 

While waiting for the opportunity and time to upgrade to Slim 4.x (0031699), it would be nice to be able to be able to use the API without suppressing deprecation notices. This would e.g. allow running the PHPUnit tests locally during development, without having continually change error_reporting settings.

The problem is that the API calls effectively fail, but report success (HTTP 200 status code) and the response body contains HTML with details about the errors.

One possible approach would be to maintain our own fork of the offending components, like we did for PHPUnit 6.5 in April 2022, but that's a pain.

Another potential solution would be to somehow catch the deprecation notices and make the REST API return an error status. Unfortunately, Slim's documented way of handling PHP errors is not able to catch these warnings, as some of them occur before the error handling container becomes active (while it's being initialized, in fact).

TagsPHP 8.1


related to 0031699 confirmed Upgrade Slim Framework to 4.x 
related to 0031678 closeddregad cannot fetch data with rest api after upgrade 
related to 0032027 closeddregad PHP 8.2 support 
related to 0033173 resolveddregad No endpoints working on Windows server with PHP 8.1+ 


Related Changesets

MantisBT: master 1859ed6c

2023-08-27 11:24


Details Diff
Travis: stop ignoring deprecated errors on PHP 8.1

Issue 0032866
Affected Issues
mod - .travis.yml Diff File

MantisBT: master 795ff02e

2023-08-27 12:10


Details Diff
Catch Slim 3.x deprecated warnings on PHP 8.1

Introduce a custom error handler to capture selected deprecation notices
and wrap the Slim initialization in a try/catch block.

If any exception occurs, an HTTP 500 will be triggered.

Fixes 0032866
Affected Issues
mod - api/rest/index.php Diff File