From 4cc40ddaa4552b2be9b696dc7b74e5c5c64fa372 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 4 May 2025 20:23:39 +0300 Subject: [PATCH] scheduler - only register built-in purge_orphaned_scheduled_tasks if running as default name --- classes/Scheduler.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/classes/Scheduler.php b/classes/Scheduler.php index 77e858b56..b5df8f3fe 100644 --- a/classes/Scheduler.php +++ b/classes/Scheduler.php @@ -3,20 +3,23 @@ class Scheduler { private static ?Scheduler $instance = null; const TASK_RC_EXCEPTION = -100; + const DEFAULT_NAME = 'Default Scheduler'; /** @var array */ private array $scheduled_tasks = []; private string $name; - function __construct(string $name = 'Default Scheduler') { + function __construct(string $name = self::DEFAULT_NAME) { $this->set_name($name); - $this->add_scheduled_task('purge_orphaned_scheduled_tasks', '@weekly', - function() { - return $this->purge_orphaned_tasks(); - } - ); + if ($name === self::DEFAULT_NAME) { + $this->add_scheduled_task('purge_orphaned_scheduled_tasks', '@weekly', + function() { + return $this->purge_orphaned_tasks(); + } + ); + } } public static function getInstance(): Scheduler {