From 4fce2be3fbe3991e69c3150bca5200bb0f88476a Mon Sep 17 00:00:00 2001 From: gosixl <88280816+gosixl@users.noreply.github.com> Date: Sat, 28 Sep 2024 01:41:58 +0100 Subject: [PATCH 1/3] Added $claim_id and $hooks as params to action_scheduler_claim_actions_order_by filter Allows toggling order by statement on the basis of the specific action. Allows skipping where not needed and benefiting from performance --- classes/data-stores/ActionScheduler_DBStore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 3554d2c9e..bd1c39737 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -932,7 +932,7 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu * * @param string $order_by_sql */ - $order = apply_filters( 'action_scheduler_claim_actions_order_by', 'ORDER BY priority ASC, attempts ASC, scheduled_date_gmt ASC, action_id ASC' ); + $order = apply_filters( 'action_scheduler_claim_actions_order_by', 'ORDER BY priority ASC, attempts ASC, scheduled_date_gmt ASC, action_id ASC', $claim_id, $hooks ); $params[] = $limit; $sql = $wpdb->prepare( "{$update} {$where} {$order} LIMIT %d", $params ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders From b2656d4743b8a4247b3c4417c6f5d28daac62f92 Mon Sep 17 00:00:00 2001 From: gosixl <88280816+gosixl@users.noreply.github.com> Date: Tue, 1 Oct 2024 20:14:55 +0000 Subject: [PATCH 2/3] Updated docsbocks for new filter paramets for action_scheduler_claim_actions_order_by --- classes/data-stores/ActionScheduler_DBStore.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index bd1c39737..9f5127bd4 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -931,6 +931,8 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu * @since 3.4.0 * * @param string $order_by_sql + * @param string $claim_id Claim Id. + * @param array $hooks Hooks to filter for. */ $order = apply_filters( 'action_scheduler_claim_actions_order_by', 'ORDER BY priority ASC, attempts ASC, scheduled_date_gmt ASC, action_id ASC', $claim_id, $hooks ); $params[] = $limit; From 76a5df91582be66ec05f997271aeb13864910421 Mon Sep 17 00:00:00 2001 From: gosixl <88280816+gosixl@users.noreply.github.com> Date: Wed, 2 Oct 2024 03:43:33 +0000 Subject: [PATCH 3/3] Added @since tag for update to action_scheduler_claim_actions_order_by hook to allow passing of claim_id and hooks --- classes/data-stores/ActionScheduler_DBStore.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 9f5127bd4..b07ccfecf 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -929,6 +929,7 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu * Sets the order-by clause used in the action claim query. * * @since 3.4.0 + * @since 3.8.3 Made $claim_id and $hooks available. * * @param string $order_by_sql * @param string $claim_id Claim Id.