WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #28213, comment 2


Ignore:
Timestamp:
06/05/2014 10:21:11 AM (7 years ago)
Author:
lkraav
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28213, comment 2

    initial v1  
    22
    33Result is that my cronjob arbitrarily simply disappears from the list. I can still see my custom 1 minute schedule in Cron Debug Bar, so I know my uber-simple cron plugin is setting things up right. But unless I re-cycle plugin activation, my cron job will never run again.
     4
     5Uber-simple plugin for reference:
     6
     7{{{
     8register_activation_hook( __FILE__, array( "MyClass", "cron_setup" ) );
     9register_deactivation_hook( __FILE__, array( "MyClass", "cron_remove" ) );
     10
     11MyClass::on_load();
     12
     13class MyClass {
     14    static function on_load() {
     15        add_filter( "cron_schedules", array( __CLASS__, "ny_minute" ) );
     16        add_action( "myclass_resend_failed", array( __CLASS__, "resend_failed" ) );
     17    }
     18
     19    static function cron_setup() {
     20        wp_schedule_event( time(), "minutes_1", "myclass_resend_failed" );
     21    }
     22
     23    static function cron_remove() {
     24        wp_clear_scheduled_hook( "myclass_resend_failed" );
     25    }
     26
     27    static function ny_minute( $schedules ) {
     28        $schedules[ "minutes_1" ] = array( "interval" => 60, "display" => "Once every NY minute" )
     29
     30        return $schedules;
     31    }
     32
     33    static function resend_failed() {
     34        # do magic, but occasionally timeouting network stuff here
     35    }
     36}}}