• Oliver Campion

    (@domainsupport)


    Is anyone else seeing errors like this in v6.1 (I think since v6.0.2 and v6.0.3) … ?

    [09-Nov-2022 11:28:28 UTC] Cron unschedule event error for hook: do_pings, Error code: could_not_set, Error message: The cron event list could not be saved., Data: {“schedule”:false,”args”:[]}
    [09-Nov-2022 18:05:03 UTC] Cron unschedule event error for hook: wordfence_processAttackData, Error code: could_not_set, Error message: The cron event list could not be saved., Data: {“schedule”:false,”args”:[]}

    Thank you,

    Oliver

Viewing 15 replies - 1 through 15 (of 50 total)
  • !Benni

    (@benniledl)

    Hi, maybe an update was incomplete fix the wp files like this:

    upload and overwrite folders from a functioning wordpress installation
    /wp-admin/
    /wp-includes/

    and .php files in the site root (make sure to keep wp-config.php!!)

    Thread Starter Oliver Campion

    (@domainsupport)

    That’s unlikely. A missing php file would cause a fatal error and an incomplete update would almost certainly white screen the site.

    Oliver

    !Benni

    (@benniledl)

    Missing or incomplete php files don’t have to result in fatal errors or white screens.

    Thread Starter Oliver Campion

    (@domainsupport)

    No. But it is extremely unlikely in this scenario. The debug.log is scrutinised daily on this particular site, there are no other errors at all and as I mentioned, this has been noticed in v6.03 and possibly v6.02.

    Thank you for your suggestion, however. Whilst I appreciate this input, I notice it is a stock reply that you have made a few times to threads in this forum.

    Oliver

    !Benni

    (@benniledl)

    I wrote this reply for the 2nd time and I just send it when it comes to things like, didnt work anymore after the update, or when I just get nothing obvious out of the error message

    • This reply was modified 2 years ago by !Benni.
    Thread Starter Oliver Campion

    (@domainsupport)

    Understood.

    So this error happens when wp_unschedule_event() fails.

    could_not_set error is presented by _set_cron_array() which is the return function for wp_unschedule_event().

    could_not_set error is returned by _set_cron_array() when the updating of the cron table fails with update_option( 'cron', $cron );.

    update_option() fails when …

    1. The $option parameter is empty
      This should never happen
    2. The old option value is the same as the new option value
      This suggests the cron job is running more than once
    3. The database insert query $wpdb->update() fails
      This is extremely worrying but shouldn’t be the case otherwise there should be an accompanying database error

    So … as per my original post … is anyone else seeing similar errors?

    Thank you,

    Oliver

    Thread Starter Oliver Campion

    (@domainsupport)

    We are still seeing these errors in v6.1.1 …

    [21-Nov-2022 07:53:04 UTC] Cron reschedule event error for hook: wf_scan_monitor, Error code: could_not_set, Error message: The cron event list could not be saved., Data: {“schedule”:”wf_scan_monitor_interval”,”args”:[],”interval”:60}
    [21-Nov-2022 07:53:04 UTC] Cron unschedule event error for hook: wf_scan_monitor, Error code: could_not_set, Error message: The cron event list could not be saved., Data: {“schedule”:”wf_scan_monitor_interval”,”args”:[],”interval”:60}

    Notice the CRON schedule hook is different so it’s not limited to a particular hook.

    Oliver

    Thread Starter Oliver Campion

    (@domainsupport)

    “failed to run” will be a different issue to this. These errors are occurring after schedules have run.

    Thread Starter Oliver Campion

    (@domainsupport)

    Oh, that’s interesting!

    We keep an eye on CRON hooks and delete ones that don’t have any associated actions (usually these appear when plugins don’t remove the hook) but didn’t think it would be possible to have duplicate CRON hooks! Will bear this in mind and monitor further.

    Using WP Control plugin none of the CRON hooks I’ve mentioned previously seem to exist currently on our site in question. The plot thickens …

    Thanks.

    @domainsupport I’d say it’s totally your call. This is a tough one because it’s not as simple as “activate/deactivate this plugin. trigger this event, etc.” There is clearly something going on somewhere in the code that is causing this issue and since there are many people with the same issue it’s doesn’t seem to be intermittent.

    Thread Starter Oliver Campion

    (@domainsupport)

    @chargeup OK, I’ll take another look at wp-cron.php over the weekend to see if I can locate the problem and then I’ll submit a ticket on trac. I agree, it’s definitely a bug.

    @domainsupport Thanks for much for taking control on this. Much appreciation.

    @domainsupport The following code looks to have been added to wp-cron.php in the 6.1 update. It’s line 126-177. I’m not sure what is causing the issue outside of this, but this seems to be the code throwing all the errors.

    ———————-

    $result = wp_reschedule_event( $timestamp, $schedule, $hook, $v['args'], true );	
    				if ( is_wp_error( $result ) ) {	
    					error_log(	
    						sprintf(	
    							/* translators: 1: Hook name, 2: Error code, 3: Error message, 4: Event data. */	
    							__( 'Cron reschedule event error for hook: %1$s, Error code: %2$s, Error message: %3$s, Data: %4$s' ),	
    							$hook,	
    							$result->get_error_code(),	
    							$result->get_error_message(),	
    							wp_json_encode( $v )	
    						)	
    					);	
    					/**	
    					 * Fires when an error happens rescheduling a cron event.	
    					 *	
    					 * @since 6.1.0	
    					 *	
    					 * @param WP_Error $result The WP_Error object.	
    					 * @param string   $hook   Action hook to execute when the event is run.	
    					 * @param array    $v      Event data.	
    					 */	
    					do_action( 'cron_reschedule_event_error', $result, $hook, $v );	
    				}	
    			}	
    			$result = wp_unschedule_event( $timestamp, $hook, $v['args'], true );	
    			if ( is_wp_error( $result ) ) {	
    				error_log(	
    					sprintf(	
    						/* translators: 1: Hook name, 2: Error code, 3: Error message, 4: Event data. */	
    						__( 'Cron unschedule event error for hook: %1$s, Error code: %2$s, Error message: %3$s, Data: %4$s' ),	
    						$hook,	
    						$result->get_error_code(),	
    						$result->get_error_message(),	
    						wp_json_encode( $v )	
    					)	
    				);	
    				/**	
    				 * Fires when an error happens unscheduling a cron event.	
    				 *	
    				 * @since 6.1.0	
    				 *	
    				 * @param WP_Error $result The WP_Error object.	
    				 * @param string   $hook   Action hook to execute when the event is run.	
    				 * @param array    $v      Event data.	
    				 */	
    				do_action( 'cron_unschedule_event_error', $result, $hook, $v );	
    			}
    Thread Starter Oliver Campion

    (@domainsupport)

    I have a new theory as to what this is. The commit on 20th September added the error logging. Before that time wp_reschedule_event() would fail silently. I think that rather than be the cause of this error, the update has highlighted an existing bug or bugs.

    Going back to my original analysis …

    So this error happens when wp_unschedule_event() fails.

    could_not_set error is presented by _set_cron_array() which is the return function for wp_unschedule_event().

    could_not_set error is returned by _set_cron_array() when the updating of the cron table fails with update_option( 'cron', $cron );.

    update_option() fails when …

    1. The $option parameter is empty
      This should never happen
    2. The old option value is the same as the new option value
      This suggests the cron job is running more than once
    3. The database insert query $wpdb->update() fails
      This is extremely worrying but shouldn’t be the case otherwise there should be an accompanying database error

    We can rule out (1) seeing as the $option parameter is never empty.

    We can probably rule out (2) because this happens on high traffic sites as well as low traffic sites and on sites using the default wp-cron firing as well as cron fired by the system … ?

    The leaves (3) being the most likely cause of the “bug” … and I’m starting to wonder if this isn’t a bug at all but instead a bit of over-zealous error logging (bearing in mind that so far there’s no evidence that the issue has caused an actual probablem other than the irritation of the log entry itself).

    Thoughts?

    @domainsupport judging from other comments it doesn’t seem like anyone if actual having problems with their sites. Health check is also saying cron are running properly for most people.

    It might be a bug but at least I think we are close now. I think we should submit the bug with the information from your last comment.

    2 scenarios.

    1) They find an actual bug that may be happening when trying to save to the database.
    2) They get rid of a very bad error reporting system that constantly throws phantom errors. That’s gonna fill up these error logs pretty bad over time.

    I’d put a link to the support thread so they can read through all the comments.

Viewing 15 replies - 1 through 15 (of 50 total)
  • The topic ‘Cron unschedule event error for hook’ is closed to new replies.