From: Alexander Ebert Date: Fri, 12 Apr 2019 15:00:48 +0000 (+0200) Subject: Throw an error when trying to use the user storage for guests X-Git-Tag: 5.2.0_Alpha_1~152 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c4efe4eeaf591c57591815f4ceb9bedbfbd03d5f;p=GitHub%2FWoltLab%2FWCF.git Throw an error when trying to use the user storage for guests Closes #2888 --- diff --git a/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php b/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php index 2c8c2e7f02..b2e75606a2 100644 --- a/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php @@ -56,6 +56,8 @@ class UserStorageHandler extends SingletonFactory { * @param integer[] $userIDs */ public function loadStorage(array $userIDs) { + $this->validateUserIDs($userIDs); + if ($this->redis) return; $tmp = []; @@ -91,6 +93,8 @@ class UserStorageHandler extends SingletonFactory { * @return mixed[] */ public function getStorage(array $userIDs, $field) { + $this->validateUserIDs($userIDs); + $data = []; if ($this->redis) { @@ -161,6 +165,8 @@ class UserStorageHandler extends SingletonFactory { * @param string $fieldValue */ public function update($userID, $field, $fieldValue) { + $this->validateUserIDs([$userID]); + if ($this->redis) { $this->redis->hSet($this->getRedisFieldName($field), $userID, $fieldValue); $this->redis->expire($this->getRedisFieldName($field), 86400); @@ -182,6 +188,8 @@ class UserStorageHandler extends SingletonFactory { * @param string $field */ public function reset(array $userIDs, $field) { + $this->validateUserIDs($userIDs); + if ($this->redis) { foreach ($userIDs as $userID) { $this->redis->hDel($this->getRedisFieldName($field), $userID); @@ -352,4 +360,16 @@ class UserStorageHandler extends SingletonFactory { return 'ush:'.$flush.':'.$fieldName; } + + /** + * @param int[] $userIDs + * @since 5.2 + */ + protected function validateUserIDs(array $userIDs) { + foreach ($userIDs as $userID) { + if (!$userID) { + throw new \InvalidArgumentException('The user id can neither be null nor zero.'); + } + } + } }