We are using the Laravel job queue to run several jobs through the schedule:run cron. We have error reporting in our php.ini (for apache as well as for the command line) set to suppress PHP's deprecated errors, yet it seems the jobs are not completing successfully.
When I try to run the jobs manually at the command line through artisan I get deprecation errors, so I suspect this is what's causing them to fail.
If I add:
ini_set('error_reporting', 'E_ALL & ~E_DEPRECATED');
to the top of the job's php file it works successfully when called manually and when run on the job schedule.
Is Artisan resetting the error reporting level somehow or discarding the error level set by the php.ini file?
I've run
php -r "echo error_reporting();"
at the command line and it shows me the correct error reporting integer to indicate that deprecated errors should be suppressed.
We've found that Laravel is overriding the error_reporting setting in: vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php
public function bootstrap(Application $app)
{
$this->app = $app;
error_reporting(-1);
set_error_handler([$this, 'handleError']);
set_exception_handler([$this, 'handleException']);
register_shutdown_function([$this, 'handleShutdown']);
if (! $app->environment('testing')) {
ini_set('display_errors', 'Off');
}
}
By removing the error_reporting(-1); line here Laravel respects the system's error_reporting setting in php.ini. Obviously this prevents Laravel from capturing and reporting errors that are suppressed through system configuration - which may or may not be what you want.