[wp-trac] [WordPress Trac] #57271: Cron unschedule / reschedule event errors
WordPress Trac
noreply at wordpress.org
Wed Jan 31 10:27:55 UTC 2024
#57271: Cron unschedule / reschedule event errors
----------------------------------------+------------------------------
Reporter: domainsupport | Owner: audrasjb
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: Cron API | Version: 6.0
Severity: normal | Resolution:
Keywords: has-patch needs-unit-tests | Focuses:
----------------------------------------+------------------------------
Comment (by domainsupport):
@galbaras @tonygao It may be that
[https://developer.wordpress.org/reference/classes/wpdb/print_error/
`wpdb::print_error `] hooked onto the `update_option_cron` hook would be
sufficient to find out what's going on but I seem to remember that this
wasn't enough when I was trying to get to the bottom of the issue and that
a disconnected database, a query timeout or other database issue didn't
result in an error when `update_option( 'cron', $cron );` failed. If so,
this would require more detailed error logging from `$wpdb` which is a
larger ask of WordPress Core ... ?
@galbaras As for regenerating cron, in theory, if you were to completely
delete the `cron` setting from the `wp_options` table then WordPress would
just rebuild it so long as everyone uses the
[https://developer.wordpress.org/plugins/cron/scheduling-wp-cron-events/
recommended method] to add cron schedules ...
{{{#!php
<?php
if ( ! wp_next_scheduled( 'bl_cron_hook' ) ) {
wp_schedule_event( time(), 'five_seconds', 'bl_cron_hook' );
}
}}}
... and does so whenever they are relying on using an existing schedule!
For example, I never assume that a cron schedule exists just because (for
example) I added it in a plugin activation hook so I make sure it's still
there when I need it when developing a plugin. But I would imagine that
just as plugin developers don't clean up after themselves with a
deactivation hook, they may not check to make sure their schedules exist
either.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57271#comment:48>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list