From: Alexander Ebert Date: Thu, 15 Aug 2024 11:03:48 +0000 (+0200) Subject: Fix the handling of multiple images X-Git-Tag: 6.1.0_Alpha_2~14 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c8cae9bb02b91801331bc6342fea8c7a7501bdd5;p=GitHub%2FWoltLab%2FWCF.git Fix the handling of multiple images `getElementsByTagName()` is a live collection, removing items mutates the underlying data structure hence the iterator will no longer work as expected. --- diff --git a/wcfsetup/install/files/lib/system/background/job/ServiceWorkerDeliveryBackgroundJob.class.php b/wcfsetup/install/files/lib/system/background/job/ServiceWorkerDeliveryBackgroundJob.class.php index 3cdd7da3a3..cdc51a228c 100644 --- a/wcfsetup/install/files/lib/system/background/job/ServiceWorkerDeliveryBackgroundJob.class.php +++ b/wcfsetup/install/files/lib/system/background/job/ServiceWorkerDeliveryBackgroundJob.class.php @@ -141,7 +141,10 @@ final class ServiceWorkerDeliveryBackgroundJob extends AbstractUniqueBackgroundJ \libxml_clear_errors(); \libxml_use_internal_errors($useInternalErrors); - foreach ($document->getElementsByTagName('img') as $image) { + $images = $document->getElementsByTagName('img'); + while ($images->length > 0) { + $image = $images->item(0); + \assert($image instanceof \DOMElement); $image->replaceWith($image->getAttribute('alt')); }