From 3e7217bcb3c5ae7b1a2e2887ba8dfd0e8c975db5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 18 Mar 2021 14:22:16 +0100 Subject: [PATCH] Remove the `$type` parameter from the `IgnoredBy` methods in UserProfile The type of ignore is not relevant when checking whether one is ignored by another user. In fact it might leak information that the ignoror might not want to share with the ignoree. --- .../templates/userInformationButtons.tpl | 2 +- .../files/lib/data/user/UserProfile.class.php | 20 ++++--------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/com.woltlab.wcf/templates/userInformationButtons.tpl b/com.woltlab.wcf/templates/userInformationButtons.tpl index 41558108a6..63bdbfd205 100644 --- a/com.woltlab.wcf/templates/userInformationButtons.tpl +++ b/com.woltlab.wcf/templates/userInformationButtons.tpl @@ -13,7 +13,7 @@ {/if} {if $__wcf->user->userID && $user->userID != $__wcf->user->userID} - {if !$__wcf->getUserProfileHandler()->isIgnoredByUser($user->userID, 1)} + {if !$__wcf->getUserProfileHandler()->isIgnoredByUser($user->userID)} {if $__wcf->getUserProfileHandler()->isFollowing($user->userID)}
  • {else} diff --git a/wcfsetup/install/files/lib/data/user/UserProfile.class.php b/wcfsetup/install/files/lib/data/user/UserProfile.class.php index 05dbacd997..95db5a1b49 100644 --- a/wcfsetup/install/files/lib/data/user/UserProfile.class.php +++ b/wcfsetup/install/files/lib/data/user/UserProfile.class.php @@ -257,10 +257,9 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject /** * Returns a list of user ids that are ignoring this user. * - * @param ?int $type One of the UserIgnore::TYPE_* constants. * @return int[] */ - public function getIgnoredByUsers(?int $type = null) + public function getIgnoredByUsers() { if ($this->ignoredByUserIDs === null) { $this->ignoredByUserIDs = []; @@ -290,17 +289,7 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject } } - return \array_keys(\array_filter($this->ignoredByUserIDs, static function ($userType) use ($type) { - if ($type === null) { - return true; - } elseif ($type === UserIgnore::TYPE_BLOCK_DIRECT_CONTACT) { - return \in_array($userType, [UserIgnore::TYPE_BLOCK_DIRECT_CONTACT, UserIgnore::TYPE_HIDE_MESSAGES]); - } elseif ($type === UserIgnore::TYPE_HIDE_MESSAGES) { - return $userType === UserIgnore::TYPE_HIDE_MESSAGES; - } else { - return false; - } - })); + return \array_keys($this->ignoredByUserIDs); } /** @@ -341,12 +330,11 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject * Returns true if the given user ignores the current user. * * @param int $userID - * @param ?int $type One of the UserIgnore::TYPE_* constants. * @return bool */ - public function isIgnoredByUser($userID, ?int $type = null) + public function isIgnoredByUser($userID) { - return \in_array($userID, $this->getIgnoredByUsers($type)); + return \in_array($userID, $this->getIgnoredByUsers()); } /** -- 2.20.1