From 09d6ba877acdc17cc8076a4ecc7afbd32c15f9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Jou=C3=9Fen?= Date: Mon, 9 Nov 2026 12:15:15 +0100 Subject: [PATCH] BackgroundTasks: Fix PHP 8.5 Contains Calls See: https://mantis.ilias.de/view.php?id=48699 `SplObjectStorage::contains()` is deprecated since PHP 8.5 and is reported as an exception while the background-task popover resolves stored buckets. Lookups of buckets, tasks, and values now use `offsetExists()`, which keeps the same object-identity check. --- .../Implementation/Persistence/BasicPersistence.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/ILIAS/BackgroundTasks/src/Implementation/Persistence/BasicPersistence.php b/components/ILIAS/BackgroundTasks/src/Implementation/Persistence/BasicPersistence.php index 2f1251a7be0a..2729d4c7bef1 100755 --- a/components/ILIAS/BackgroundTasks/src/Implementation/Persistence/BasicPersistence.php +++ b/components/ILIAS/BackgroundTasks/src/Implementation/Persistence/BasicPersistence.php @@ -202,7 +202,7 @@ public function getBucketIdsByState(int $state): array protected function saveObserver(Bucket $bucket): void { // If the instance has a known container we use it, otherwise we create a new container. - if ($this->bucketHashToObserverContainerId->contains($bucket)) { + if ($this->bucketHashToObserverContainerId->offsetExists($bucket)) { $bucketContainer = new BucketContainer($this->bucketHashToObserverContainerId[$bucket], $this->connector); } else { $bucketContainer = new BucketContainer(0, $this->connector); @@ -243,7 +243,7 @@ protected function saveObserver(Bucket $bucket): void protected function saveTask(Task $task, int $bucketId): void { // If the instance has a known container we use it, otherwise we create a new container. - if ($this->taskHashToTaskContainerId->contains($task)) { + if ($this->taskHashToTaskContainerId->offsetExists($task)) { $taskContainer = new TaskContainer($this->taskHashToTaskContainerId[$task]); } else { $taskContainer = new TaskContainer(0); @@ -306,7 +306,7 @@ protected function saveValueToTask(Task $task, TaskContainer $taskContainer, int protected function saveValue(Value $value, int $bucketId, int $position): void { // If we have previous values to task associations we delete them. - if ($this->valueHashToValueContainerId->contains($value)) { + if ($this->valueHashToValueContainerId->offsetExists($value)) { $valueContainer = new ValueContainer($this->valueHashToValueContainerId[$value], $this->connector); } else { $valueContainer = new ValueContainer(0, $this->connector); @@ -339,7 +339,7 @@ protected function saveValue(Value $value, int $bucketId, int $position): void */ public function getBucketContainerId(Bucket $bucket): int { - if (!$this->bucketHashToObserverContainerId->contains($bucket)) { + if (!$this->bucketHashToObserverContainerId->offsetExists($bucket)) { throw new SerializationException("Could not resolve container id of task: " . print_r($bucket, true)); } @@ -353,7 +353,7 @@ public function getBucketContainerId(Bucket $bucket): int */ protected function getTaskContainerId(Task $task): int { - if (!$this->taskHashToTaskContainerId->contains($task)) { + if (!$this->taskHashToTaskContainerId->offsetExists($task)) { throw new SerializationException("Could not resolve container id of task: " . print_r($task, true)); } @@ -366,7 +366,7 @@ protected function getTaskContainerId(Task $task): int */ protected function getValueContainerId(Value $value): int { - if (!$this->valueHashToValueContainerId->contains($value)) { + if (!$this->valueHashToValueContainerId->offsetExists($value)) { throw new SerializationException("Could not resolve container id of value: " . print_r($value, true)); }