From: tenma Date: Mon, 12 Aug 2019 03:53:43 +0000 (+0100) Subject: [CORE] Fix subscription-related functions from the Profile class X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=357296baebfe63e1b41efac448951c029609cfb0;p=quix0rs-gnu-social.git [CORE] Fix subscription-related functions from the Profile class The undifined variable $private_stream, from the User class, was causing undifined behavior from calling requiresSubscriptionApproval. The is_null test was added to fix this problem. --- diff --git a/classes/Profile.php b/classes/Profile.php index 266883664a..4b5badc663 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -793,7 +793,7 @@ class Profile extends Managed_DataObject return is_null($other) ? false : $other->isSubscribed($this); } - function requiresSubscriptionApproval(Profile $other=null) + function requiresSubscriptionApproval(Profile $other=null): bool { if (!$this->isLocal()) { // We don't know for remote users, and we'll always be able to send @@ -809,7 +809,7 @@ class Profile extends Managed_DataObject // If the local user either has a private stream (implies the following) // or user has a moderation policy for new subscriptions, return true. - return $this->getUser()->private_stream || $this->getUser()->subscribe_policy === User::SUBSCRIBE_POLICY_MODERATE; + return $this->isPrivateStream() || $this->getUser()->subscribe_policy === User::SUBSCRIBE_POLICY_MODERATE; } /** @@ -1792,13 +1792,14 @@ class Profile extends Managed_DataObject return $this->getUser()->shortenLinks($text, $always); } - public function isPrivateStream() + public function isPrivateStream(): bool { // We only know of public remote users as of yet... if (!$this->isLocal()) { return false; } - return $this->getUser()->private_stream ? true : false; + $private_stream = $this->getUser()->private_stream; + return !is_null($private_stream) && $private_stream; } public function delPref($namespace, $topic) {