-
Notifications
You must be signed in to change notification settings - Fork 354
Open
Description
Summary
When running the application on PHP 8.5, a notice is triggered regarding the deprecation of SplObjectStorage::contains().
Error Message
Method SplObjectStorage::contains() is deprecated since 8.5, use method SplObjectStorage::offsetExists() instead
Affected File
library/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php at line 88 (inside handleEnd).
Analysis
The SplObjectStorage class usage has changed in newer PHP versions. The contains method is being deprecated in favor of offsetExists.
Proposed Fix
Update the handleEnd method to use offsetExists.
Current Code (implied by error):
public function handleEnd(&$token)
{
if ($this->markForDeletion->contains($token)) {
$this->markForDeletion->detach($token);
$token = false;
}
}Suggested Change:
public function handleEnd(&$token)
{
if ($this->markForDeletion->offsetExists($token)) {
$this->markForDeletion->offsetUnset($token);
$token = false;
}
}Note: offsetUnset should also be used as detach is similarly affected, or for consistency with offsetExists.
And the same for line 77, markForDeletion->attach should be markForDeletion->offsetSet.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels