Merge pull request #23489 from woocommerce/fix/23414

update action scheduler to version 2.2.5
This commit is contained in:
Mike Jolley 2019-04-24 15:48:58 +01:00 committed by GitHub
commit 087f490b10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 13 deletions

View File

@ -4,8 +4,8 @@
* Plugin URI: https://actionscheduler.org
* Description: A robust scheduling library for use in WordPress plugins.
* Author: Prospress
* Author URI: http://prospress.com/
* Version: 2.2.4
* Author URI: https://prospress.com/
* Version: 2.2.5
* License: GPLv3
*
* Copyright 2019 Prospress, Inc. (email : freedoms@prospress.com)
@ -25,21 +25,21 @@
*
*/
if ( ! function_exists( 'action_scheduler_register_2_dot_2_dot_4' ) ) {
if ( ! function_exists( 'action_scheduler_register_2_dot_2_dot_5' ) ) {
if ( ! class_exists( 'ActionScheduler_Versions' ) ) {
require_once( 'classes/ActionScheduler_Versions.php' );
add_action( 'plugins_loaded', array( 'ActionScheduler_Versions', 'initialize_latest_version' ), 1, 0 );
}
add_action( 'plugins_loaded', 'action_scheduler_register_2_dot_2_dot_4', 0, 0 );
add_action( 'plugins_loaded', 'action_scheduler_register_2_dot_2_dot_5', 0, 0 );
function action_scheduler_register_2_dot_2_dot_4() {
function action_scheduler_register_2_dot_2_dot_5() {
$versions = ActionScheduler_Versions::instance();
$versions->register( '2.2.4', 'action_scheduler_initialize_2_dot_2_dot_4' );
$versions->register( '2.2.5', 'action_scheduler_initialize_2_dot_2_dot_5' );
}
function action_scheduler_initialize_2_dot_2_dot_4() {
function action_scheduler_initialize_2_dot_2_dot_5() {
require_once( 'classes/ActionScheduler.php' );
ActionScheduler::init( __FILE__ );
}

View File

@ -55,6 +55,7 @@ abstract class ActionScheduler_Logger {
add_action( 'action_scheduler_unexpected_shutdown', array( $this, 'log_unexpected_shutdown' ), 10, 2 );
add_action( 'action_scheduler_reset_action', array( $this, 'log_reset_action' ), 10, 1 );
add_action( 'action_scheduler_execution_ignored', array( $this, 'log_ignored_action' ), 10, 1 );
add_action( 'action_scheduler_failed_fetch_action', array( $this, 'log_failed_fetch_action' ), 10, 1 );
}
public function log_stored_action( $action_id ) {
@ -94,5 +95,8 @@ abstract class ActionScheduler_Logger {
public function log_ignored_action( $action_id ) {
$this->log( $action_id, __( 'action ignored', 'action-scheduler' ) );
}
public function log_failed_fetch_action( $action_id ) {
$this->log( $action_id, __( 'There was a failure fetching this action', 'action-scheduler' ) );
}
}

View File

@ -19,7 +19,13 @@ class ActionScheduler_wpPostStore extends ActionScheduler_Store {
$this->validate_action( $action );
$post_array = $this->create_post_array( $action, $scheduled_date );
$post_id = $this->save_post_array( $post_array );
$this->save_post_schedule( $post_id, $action->get_schedule() );
$schedule = $action->get_schedule();
if ( ! is_null( $scheduled_date ) && $schedule->is_recurring() ) {
$schedule = new ActionScheduler_IntervalSchedule( $scheduled_date, $schedule->interval_in_seconds() );
}
$this->save_post_schedule( $post_id, $schedule );
$this->save_action_group( $post_id, $action->get_group() );
do_action( 'action_scheduler_stored_action', $post_id );
return $post_id;
@ -131,13 +137,21 @@ class ActionScheduler_wpPostStore extends ActionScheduler_Store {
protected function make_action_from_post( $post ) {
$hook = $post->post_title;
$args = json_decode( $post->post_content, true );
$this->validate_args( $args, $post->ID );
$schedule = get_post_meta( $post->ID, self::SCHEDULE_META_KEY, true );
if ( empty( $schedule ) || ! is_a( $schedule, 'ActionScheduler_Schedule' ) ) {
try {
$args = json_decode( $post->post_content, true );
$this->validate_args( $args, $post->ID );
$schedule = get_post_meta( $post->ID, self::SCHEDULE_META_KEY, true );
if ( empty( $schedule ) || ! is_a( $schedule, 'ActionScheduler_Schedule' ) ) {
throw ActionScheduler_InvalidActionException::from_decoding_args( $post->ID );
}
} catch ( ActionScheduler_InvalidActionException $exception ) {
$schedule = new ActionScheduler_NullSchedule();
$args = array();
do_action( 'action_scheduler_failed_fetch_action', $post->ID );
}
$group = wp_get_object_terms( $post->ID, self::GROUP_TAXONOMY, array('fields' => 'names') );
$group = empty( $group ) ? '' : reset($group);