0032866: Allow REST API to run on PHP 8.1 without squelching E_DEPRECATED notices - MantisBT

View Issue Details

IDProjectCategoryView StatusDate SubmittedLast Update
0032866mantisbtapi restpublic2023年08月27日 12:082026年07月06日 13:08
Reporterdregad Assigned Todregad  
PrioritynormalSeveritymajorReproducibilityalways
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
Description

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

Relationships

related to  0031699 confirmed   Upgrade Slim Framework to 4.x 
related to  0031678 closed dregad   cannot fetch data with rest api after upgrade 
related to  0032027 closed dregad   PHP 8.2 support 
related to  0033173 closed dregad   No endpoints working on Windows server with PHP 8.1+ 
related to  0035284 closed dregad   Allow REST API to run on PHP 8.4 ignoring E_DEPRECATED notices 
related to  0037288 resolved dregad   Upgrade Slim Framework to 3.13.0 

Activities

Related Changesets

MantisBT: master 1859ed6c

2023年08月27日 11:24

dregad


Details Diff Travis: stop ignoring deprecated errors on PHP 8.1

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

MantisBT: master 795ff02e

2023年08月27日 12:10

dregad


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
0032866
mod - api/rest/index.php Diff File
Powered by MantisBT 2.29.0-dev-master-e4ff7ef87
Copyright © 2000 - 2026 MantisBT Team
Contact administrator for assistance
Page execution time: 0.2849 seconds    

AltStyle によって変換されたページ (->オリジナル) /