From: Joshua Rüsweg Date: Sun, 21 Apr 2019 12:04:45 +0000 (+0200) Subject: Add method to improve signatures with embedded objects X-Git-Tag: 5.2.0_Alpha_1~125 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f4593a98e0728499da61fc895ba7fe2a9cd82f92;p=GitHub%2FWoltLab%2FWCF.git Add method to improve signatures with embedded objects See #2670 --- diff --git a/wcfsetup/install/files/lib/system/user/signature/SignatureCache.class.php b/wcfsetup/install/files/lib/system/user/signature/SignatureCache.class.php index ba549d0ba6..ce9e8080e4 100644 --- a/wcfsetup/install/files/lib/system/user/signature/SignatureCache.class.php +++ b/wcfsetup/install/files/lib/system/user/signature/SignatureCache.class.php @@ -25,6 +25,12 @@ class SignatureCache extends SingletonFactory { */ protected $signatures = []; + /** + * The userIDs which are cached by the message embedded object manager. + * @var integer[] + */ + protected $cachedUserIDs = []; + /** * Returns a parsed user signature. * @@ -37,7 +43,9 @@ class SignatureCache extends SingletonFactory { $this->htmlOutputProcessor = new HtmlOutputProcessor(); } - MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.user.signature', [$user->userID]); + if (!in_array($user->userID, $this->cachedUserIDs)) { + $this->cacheUserSignature([$user->userID]); + } $this->htmlOutputProcessor->setContext('com.woltlab.wcf.user.signature', $user->userID); $this->htmlOutputProcessor->process($user->signature, 'com.woltlab.wcf.user.signature', $user->userID); @@ -46,4 +54,16 @@ class SignatureCache extends SingletonFactory { return $this->signatures[$user->userID]; } + + /** + * Loads the embedded objects for the given users. + * + * @param integer[] $userIDs + * @since 5.2 + */ + public function cacheUserSignature(array $userIDs) { + $this->cachedUserIDs = array_merge($this->cachedUserIDs, $userIDs); + + MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.user.signature', $userIDs); + } }