Schedule Overview

Action Scheduler schedules describe when an action should run and whether it recurs. Schedules implement ActionScheduler_Schedule and are attached to ActionScheduler_Action instances.

Interface

interface ActionScheduler_Schedule {
	public function next( ?DateTime $after = null );
	public function is_recurring();
}

next() is deprecated in favor of the concrete methods defined on the schedule classes:

  • get_date() returns the schedule’s stored run date/time.
  • get_next( DateTime $after ) returns the next run date/time after a given moment.

ActionScheduler_Schedule_Deprecated::next() dispatches to get_date() or get_next() and emits a deprecation notice.

Base classes

ActionScheduler_Abstract_Schedule

Defines shared behavior for all schedules:

abstract class ActionScheduler_Abstract_Schedule extends ActionScheduler_Schedule_Deprecated {
	public function __construct( DateTime $date );
	abstract public function is_recurring();
	abstract protected function calculate_next( DateTime $after );
	public function get_next( DateTime $after );
	public function get_date();
}

Next-run calculation

  • get_next() clones $after and compares it with the stored $scheduled_date.
  • If $after is later than the scheduled date, it delegates to calculate_next().
  • Otherwise it returns a clone of the stored scheduled date.

ActionScheduler_Abstract_RecurringSchedule

Adds recurrence metadata and behavior:

abstract class ActionScheduler_Abstract_RecurringSchedule extends ActionScheduler_Abstract_Schedule {
	public function __construct( DateTime $date, $recurrence, ?DateTime $first = null );
	public function is_recurring();
	public function get_first_date();
	public function get_recurrence();
}
  • is_recurring() always returns true.
  • get_first_date() records when the first instance of the series was scheduled.
  • get_recurrence() returns the recurrence metadata (interval seconds, cron expression, etc.).

Hierarchy

ActionScheduler_Schedule (interface)
└─ ActionScheduler_Schedule_Deprecated
   └─ ActionScheduler_Abstract_Schedule
      ├─ ActionScheduler_SimpleSchedule
      │  ├─ ActionScheduler_NullSchedule
      │  └─ ActionScheduler_CanceledSchedule
      └─ ActionScheduler_Abstract_RecurringSchedule
         ├─ ActionScheduler_IntervalSchedule
         └─ ActionScheduler_CronSchedule

Serialization compatibility

Schedules implement __sleep()/__wakeup() to preserve backwards compatibility with serialized schedules created before Action Scheduler 3.0.0. This includes mapping older property names to the newer unified property set.