joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.77k stars 3.65k forks source link

[4][PHP8] Directive track_errors which caused $php_errormsg to be available has been removed. #33185

Closed PhilETaylor closed 2 years ago

PhilETaylor commented 3 years ago

170 uses in Joomla 4 - mainly in libraries, 63 in upstream packages

https://www.php.net/manual/en/reserved.variables.phperrormsg.php

Version Description
PHP 8.0.0 Directive track_errors which caused $php_errormsg to be available has been removed.
PHP 7.2.0 Directive track_errors which caused $php_errormsg to be available has been deprecated.
Screenshot 2021-04-18 at 15 58 15
richard67 commented 3 years ago

So we should use error_get_last() and get the 'message' element where we now use $php_errormsg, right?

PhilETaylor commented 3 years ago

docs comments also say:

If an error handler (see set_error_handler ) successfully handles an error then that error will not be reported by this function.

so that will need testing too,

Maybe something like this which we use for deprecated errors in libraries/bootstrap.php might work for Notice/Warnings - no idea - not tested - looks like a nicerway to handle warnings and errors and would allow us to remove all @ suppression in Joomla 4?

set_error_handler(['Joomla\CMS\Exception\ExceptionHandler', 'handleUserDeprecatedErrors'], E_USER_DEPRECATED);