When running cron event produces a fatal error, the shutdown function doesn't run
Bug Report
- [x] Yes, I reviewed the contribution guidelines.
- [x] Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
While running a regular cron command:
wp cron event run --due-now
once the event produces a fatal error, the shutdown action and custom register_shutdown_function isn't called.
Describe how other contributors can replicate this bug
- Register an example cron event.
- Use callback
add_action( 'example', function() {
undef_function_9j8yf8me();
} );
- Watch for log file
register_shutdown_function( function() {
file_put_contents( dirname( __FILE__ ) . '/log.log', print_r( 'Shutdown called correctly', true ) . "\r\n\r\n", FILE_APPEND );
} );
- Run event - the log is not saved.
- Comment the call to undefined function in the event callback.
- Run event - the log is saved.
Describe what you would expect as the correct outcome
The shutdown function, thus shutdown action executing with fatal errors.
I'll be looking at this today, during Contributor Day.
Per my PR at https://github.com/wp-cli/cron-command/pull/108, I believe this issue is not valid and can be closed as such.
@jakubmikita Are you still experiencing this issue? Can you take a look at the tests in #108 and confirm whether they accurately represent the issue you saw?
Thanks!