View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0032866||mantisbt||api rest||public||2023-08-27 12:08||2023-11-13 06:08|
|Target Version||2.26.0||Fixed in Version||2.26.0|
|Summary||0032866: 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:
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).
MantisBT: master 1859ed6c
|Travis: stop ignoring deprecated errors on PHP 8.1
|mod - .travis.yml||Diff File|
MantisBT: master 795ff02e
|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.
|mod - api/rest/index.php||Diff File|