Hide warnings in REST API issue
-
Hello SiteGround,
I had a very hard time to debug an issue in form entries export feature from the NinjaForms plugin. The Ninja Forms plugin uses a custom WordPress REST API endpoint to allow users to export form entries. By default WordPress will never display errors for REST API reqeusts:
ini_set( 'display_errors', 0 );That’s ok, if we enable debug log errors should be written to a log file:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false );However the SiteGround Optimizer plugin seems to disable error reporting for some error types:
/** * Hide warnings in rest api. * * @since 1.0.0 */ public function hide_warnings_in_rest_api() { if ( self::is_rest() ) { error_reporting( E_ERROR | E_PARSE ); } }Probably for a specific reason, but I don’t think this has been thought through or tested well enough. It’s not up to the SiteGround Optimizer plugin to determine which PHP errors to report, right?
By
error_reporting( E_ERROR | E_PARSE );it took me hours to find the following error:[16-Jun-2022 10:21:43 UTC] PHP Fatal error: Declaration of NinjaForms\Includes\Handlers\Field::update_setting($key, $value): NinjaForms\Includes\Handlers\Field must be compatible with NinjaForms\Includes\Contracts\Field::update_setting($key, $value): NinjaForms\Includes\Contracts\Field in public_html/wp-content/plugins/ninja-forms/includes/Handlers/Field.php on line 15Plese note that the website was still runing on PHP 7.3, i believe this error is changed to a ‘Fatal error’ in PHP 8 or higher:
https://3v4l.org/1C17BBut that doesn’t change the fact that
hide_warnings_in_rest_api()doesn’t belong in the SiteGround Optimizer plugin in my opinion. I’m curious if you think the same with this information, we’d love to hear it.Pronamic
Remco Tolsma
The topic ‘Hide warnings in REST API issue’ is closed to new replies.