From: Alexander Ebert Date: Mon, 21 Jun 2021 14:47:42 +0000 (+0200) Subject: Embedded object ids are now explicitly casted to int X-Git-Tag: 5.4.0_RC_1~27 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=685a8699fdc7cb76da76f36dba999fd20c43daa8;p=GitHub%2FWoltLab%2FWCF.git Embedded object ids are now explicitly casted to int https://wiki.php.net/rfc/string_to_number_comparison changed the behavior of PHP when comparing strings to numbers. `123 == "123foo"` is true in PHP <8.0, but false starting with PHP 8.0. --- diff --git a/wcfsetup/install/files/lib/system/message/embedded/object/MessageEmbeddedObjectManager.class.php b/wcfsetup/install/files/lib/system/message/embedded/object/MessageEmbeddedObjectManager.class.php index 1319449ab3..5f17806adf 100644 --- a/wcfsetup/install/files/lib/system/message/embedded/object/MessageEmbeddedObjectManager.class.php +++ b/wcfsetup/install/files/lib/system/message/embedded/object/MessageEmbeddedObjectManager.class.php @@ -382,6 +382,17 @@ class MessageEmbeddedObjectManager extends SingletonFactory */ public function getObject($embeddedObjectType, $objectID) { + // `$objectID` might contain non integer values containing a comment, such + // as `123#This is a comment`. PHP <8.0 would silently truncate the value + // similar to what `intval()` does, making the below comparison work. + // + // However, in PHP 8.0 it was decided that this behavior is intransparent + // and somewhat violates the implicit casting rules, such a comparison + // now yields `false` where it was previously true. + // + // See https://wiki.php.net/rfc/string_to_number_comparison + $objectID = \intval($objectID); + $embeddedObjectTypeID = ObjectTypeCache::getInstance() ->getObjectTypeIDByName('com.woltlab.wcf.message.embeddedObject', $embeddedObjectType); if (!empty($this->messageEmbeddedObjects[$this->activeMessageObjectTypeID][$this->activeMessageID][$embeddedObjectTypeID])) {