wp-cli / cron-command

Tests, runs, and deletes WP-Cron events; manages WP-Cron schedules.
MIT License
31 stars 27 forks source link

When running cron event produces a fatal error, the shutdown function doesn't run #70

Open jakubmikita opened 3 years ago

jakubmikita commented 3 years ago

Bug Report

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

  1. Register an example cron event.
  2. Use callback
    add_action( 'example', function() {
    undef_function_9j8yf8me();
    } );
  3. 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 );
    } );
  4. Run event - the log is not saved.
  5. Comment the call to undefined function in the event callback.
  6. 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.

justinmaurerdotdev commented 1 month ago

I'll be looking at this today, during Contributor Day.

justinmaurerdotdev commented 1 month ago

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.

johnbillion commented 1 month ago

@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!