From c8e6c02851b5b848e0ddf70a10039a49910cb6a8 Mon Sep 17 00:00:00 2001 From: Jan Jakes Date: Mon, 5 Aug 2024 13:06:53 +0200 Subject: [PATCH] Fix "Return value must be of type int, null returned" in Action Scheduler wrappers [MAILPOET-6179] --- mailpoet/lib/Automation/Engine/Control/ActionScheduler.php | 6 ++++-- mailpoet/lib/Cron/ActionScheduler/ActionScheduler.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mailpoet/lib/Automation/Engine/Control/ActionScheduler.php b/mailpoet/lib/Automation/Engine/Control/ActionScheduler.php index 0834dc0c9b..1390acaa84 100644 --- a/mailpoet/lib/Automation/Engine/Control/ActionScheduler.php +++ b/mailpoet/lib/Automation/Engine/Control/ActionScheduler.php @@ -8,11 +8,13 @@ class ActionScheduler { private const GROUP_ID = 'mailpoet-automation'; public function enqueue(string $hook, array $args = []): int { - return as_enqueue_async_action($hook, $args, self::GROUP_ID); + $result = as_enqueue_async_action($hook, $args, self::GROUP_ID); + return is_int($result) ? $result : 0; } public function schedule(int $timestamp, string $hook, array $args = []): int { - return as_schedule_single_action($timestamp, $hook, $args, self::GROUP_ID); + $result = as_schedule_single_action($timestamp, $hook, $args, self::GROUP_ID); + return is_int($result) ? $result : 0; } public function hasScheduledAction(string $hook, array $args = []): bool { diff --git a/mailpoet/lib/Cron/ActionScheduler/ActionScheduler.php b/mailpoet/lib/Cron/ActionScheduler/ActionScheduler.php index 73742135db..854db470f2 100644 --- a/mailpoet/lib/Cron/ActionScheduler/ActionScheduler.php +++ b/mailpoet/lib/Cron/ActionScheduler/ActionScheduler.php @@ -17,11 +17,13 @@ class ActionScheduler { } public function scheduleRecurringAction(int $timestamp, int $interval_in_seconds, string $hook, array $args = [], bool $unique = true): int { - return as_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args, self::GROUP_ID, $unique); + $result = as_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args, self::GROUP_ID, $unique); + return is_int($result) ? $result : 0; } public function scheduleImmediateSingleAction(string $hook, array $args = [], bool $unique = true): int { - return as_schedule_single_action($this->wp->currentTime('timestamp', true), $hook, $args, self::GROUP_ID, $unique); + $result = as_schedule_single_action($this->wp->currentTime('timestamp', true), $hook, $args, self::GROUP_ID, $unique); + return is_int($result) ? $result : 0; } public function unscheduleAction(string $hook, array $args = []): ?int {