summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2025-05-04 20:23:39 +0300
committerAndrew Dolgov <fox@fakecake.org>2025-05-04 20:25:29 +0300
commit4cc40ddaa4552b2be9b696dc7b74e5c5c64fa372 (patch)
tree71619a17b544390cc675fbae6fbcdfbae5006e18
parent5263a07f61698eb26e0482129d66c5ab4be1c9c5 (diff)
scheduler - only register built-in purge_orphaned_scheduled_tasks if running as default name
-rw-r--r--classes/Scheduler.php15
1 files 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<string, mixed> */
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 {