diff --git a/classes/ActionScheduler_AdminView.php b/classes/ActionScheduler_AdminView.php index d87861e78..52fc1dba7 100644 --- a/classes/ActionScheduler_AdminView.php +++ b/classes/ActionScheduler_AdminView.php @@ -9,7 +9,7 @@ class ActionScheduler_AdminView extends ActionScheduler_AdminView_Deprecated { private static $admin_view = NULL; /** - * @return ActionScheduler_QueueRunner + * @return ActionScheduler_AdminView * @codeCoverageIgnore */ public static function instance() { diff --git a/classes/ActionScheduler_wcSystemStatus.php b/classes/ActionScheduler_wcSystemStatus.php index 3213d7cce..1fc7541da 100644 --- a/classes/ActionScheduler_wcSystemStatus.php +++ b/classes/ActionScheduler_wcSystemStatus.php @@ -129,8 +129,8 @@ protected function get_template( $status_labels, $action_counts, $oldest_and_new /** * is triggered when invoking inaccessible methods in an object context. * - * @param $name string - * @param $arguments array + * @param string $name + * @param array $arguments * * @return mixed * @link https://php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.methods diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index fdb1ada9d..c78706db2 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -204,13 +204,43 @@ public function has_pending_actions_due() { public function init() {} + /** + * Mark an action that failed to fetch correctly as failed. + * + * @since 2.2.6 + * + * @param int $action_id The ID of the action. + */ + public function mark_failed_fetch_action( $action_id ) { + self::$store->mark_failure( $action_id ); + } + + /** + * Add base hooks + * + * @since 2.2.6 + */ + protected static function hook() { + add_action( 'action_scheduler_failed_fetch_action', array( self::$store, 'mark_failed_fetch_action' ), 20 ); + } + + /** + * Remove base hooks + * + * @since 2.2.6 + */ + protected static function unhook() { + remove_action( 'action_scheduler_failed_fetch_action', array( self::$store, 'mark_failed_fetch_action' ), 20 ); + } + /** * @return ActionScheduler_Store */ public static function instance() { if ( empty(self::$store) ) { - $class = apply_filters('action_scheduler_store_class', 'ActionScheduler_wpPostStore'); + $class = apply_filters( 'action_scheduler_store_class', 'ActionScheduler_wpPostStore' ); self::$store = new $class(); + self::hook(); } return self::$store; } diff --git a/classes/data-stores/ActionScheduler_wpPostStore.php b/classes/data-stores/ActionScheduler_wpPostStore.php index 4d8234140..4162fb89c 100644 --- a/classes/data-stores/ActionScheduler_wpPostStore.php +++ b/classes/data-stores/ActionScheduler_wpPostStore.php @@ -49,7 +49,20 @@ protected function create_post_array( ActionScheduler_Action $action, DateTime $ protected function save_post_array( $post_array ) { add_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10, 1 ); add_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10, 5 ); + + $has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' ); + + if ( $has_kses ) { + // Prevent KSES from corrupting JSON in post_content. + kses_remove_filters(); + } + $post_id = wp_insert_post($post_array); + + if ( $has_kses ) { + kses_init_filters(); + } + remove_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10 ); remove_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10 ); diff --git a/docs/assets/css/style.scss b/docs/assets/css/style.scss index ee1434cec..a13de0d06 100644 --- a/docs/assets/css/style.scss +++ b/docs/assets/css/style.scss @@ -35,7 +35,7 @@ footer { animation:octocat-wave 560ms ease-in-out } -@keyframes octocat-wave{ +@keyframes octocat-wave { 0%,100%{ transform:rotate(0) } @@ -51,7 +51,7 @@ footer { .github-corner:hover .octo-arm { animation:none } - .github-corner .octo-arm{ + .github-corner .octo-arm { animation:octocat-wave 560ms ease-in-out } } \ No newline at end of file diff --git a/tests/phpunit/jobstore/ActionScheduler_wpPostStore_Test.php b/tests/phpunit/jobstore/ActionScheduler_wpPostStore_Test.php index 44c654fd8..cba33e935 100644 --- a/tests/phpunit/jobstore/ActionScheduler_wpPostStore_Test.php +++ b/tests/phpunit/jobstore/ActionScheduler_wpPostStore_Test.php @@ -246,7 +246,7 @@ public function test_get_run_date() { $now = as_get_datetime_object(); $store->mark_complete( $action_id ); - $this->assertEquals( $store->get_date($action_id)->getTimestamp(), $now->getTimestamp(), '', 1 ); // allow timestamp to be 1 second off for older versions of PHP + $this->assertEquals( $store->get_date( $action_id )->getTimestamp(), $now->getTimestamp(), '', 1 ); // allow timestamp to be 1 second off for older versions of PHP $next = $action->get_schedule()->next( $now ); $new_action_id = $store->save_action( $action, $next ); diff --git a/tests/phpunit/runner/ActionScheduler_QueueRunner_Test.php b/tests/phpunit/runner/ActionScheduler_QueueRunner_Test.php index 96915241e..0087b40c7 100644 --- a/tests/phpunit/runner/ActionScheduler_QueueRunner_Test.php +++ b/tests/phpunit/runner/ActionScheduler_QueueRunner_Test.php @@ -104,7 +104,7 @@ public function test_next_instance_of_action() { $this->assertEquals( $random, $new_action->get_hook() ); - $this->assertEquals( $schedule->next(as_get_datetime_object())->getTimestamp(), $new_action->get_schedule()->next(as_get_datetime_object())->getTimestamp() ); + $this->assertEquals( $schedule->next( as_get_datetime_object() )->getTimestamp(), $new_action->get_schedule()->next( as_get_datetime_object() )->getTimestamp(), '', 1 ); } public function test_hooked_into_wp_cron() {