How to ignore E_DEPRECATED errors in PHP?

676 Views Asked by At

I have an old Wordpress plugin that I'm still using for legacy and have no intention to update it. This plugin creates a few minor deprecated errors that show up in my Wordpress dashboard, and I would like to remove them.

I added this line of code to the plugin code:

error_reporting( E_ALL & ~E_DEPRECATED );

This seems to work, meaning that I don't see the deprecated error messages in the dashboard anymore; however, the errors still show up in my error log file whenever I make a request to my Wordpress site, so I guess the errors are still reported?

I log errors hooking into Wordpress' default shutdown process:

add_action( "shutdown", "log_fatal_errors" );

function log_fatal_errors() {
   
   $e = error_get_last(); 
   
   if( ! empty($e) ) {
      $Logger = get_logger(); // This returns my logger class, which consists of a series of different Monolog loggers
      $Logger->app->critical( $e["message"] );
   }
   
}   
0

There are 0 best solutions below