Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various small fixes and tweaks #347

Merged
merged 4 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class ActionScheduler_Abstract_RecurringSchedule extends ActionSchedule
*
* @var int
*/
protected $first_timestamp = 0;
protected $first_timestamp = NULL;

/**
* The recurrance between each time an action is run using this schedule.
Expand Down
3 changes: 2 additions & 1 deletion classes/abstracts/ActionScheduler_Abstract_Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class ActionScheduler_Abstract_Schedule extends ActionScheduler_Schedul
*
* @var int
*/
protected $scheduled_timestamp = 0;
protected $scheduled_timestamp = NULL;

/**
* @param DateTime $date The date & time to run the action.
Expand Down Expand Up @@ -78,5 +78,6 @@ public function __sleep() {

public function __wakeup() {
$this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp );
unset( $this->scheduled_timestamp );
}
}
4 changes: 2 additions & 2 deletions classes/migration/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ public function unschedule_migration() {
/**
* Get migration batch schedule interval.
*
* @return int Seconds between migration runs. Defaults to two minutes.
* @return int Seconds between migration runs. Defaults to 30 seconds - the time allowed per batch.
*/
private function get_schedule_interval() {
return (int) apply_filters( 'action_scheduler/migration_interval', 2 * MINUTE_IN_SECONDS );
return (int) apply_filters( 'action_scheduler/migration_interval', 30 );
}

/**
Expand Down
27 changes: 26 additions & 1 deletion classes/schedules/ActionScheduler_SimpleSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@ public function is_recurring() {
return false;
}

/**
* Serialize schedule with data required prior to AS 3.0.0
*
* Prior to Action Scheduler 3.0.0, schedules used different property names to refer
* to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp
* was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0
* aligned properties and property names for better inheritance. To guard against the
* scheduled date for single actions always being seen as "now" if downgrading to
* Action Scheduler < 3.0.0, we need to also store the data with the old property names
* so if it's unserialized in AS < 3.0, the schedule doesn't end up with a null recurrence.
*
* @return array
*/
public function __sleep() {

$sleep_params = parent::__sleep();

$this->timestamp = $this->scheduled_timestamp;

return array_merge( $sleep_params, array(
'timestamp',
) );
}

/**
* Unserialize recurring schedules serialized/stored prior to AS 3.0.0
*
Expand All @@ -37,7 +61,8 @@ public function is_recurring() {
* map the old property names with matching visibility.
*/
public function __wakeup() {
if ( ! is_null( $this->timestamp ) ) {

if ( is_null( $this->scheduled_timestamp ) && ! is_null( $this->timestamp ) ) {
$this->scheduled_timestamp = $this->timestamp;
unset( $this->timestamp );
}
Expand Down