Fixed Error phrases fail to bubble for profile posts

Affected version
2.1.10 Patch 2

PaulB

Active member
XF\Pub\Controller\ProfilePost#assertViewableProfilePost:
PHP:
protected function assertViewableProfilePost($profilePostId, array $extraWith = [])
{
    // ...
    
    if (!$profilePost->canView($error))
    {
        throw $this->exception($this->noPermission($error));
    }

    // ...
}

XF\Entity\ProfilePost#canView:
PHP:
public function canView(&$error = null)
{
    // ...

    if (!$this->ProfileUser->canViewPostsOnProfile())  // Missing reference to $error
    {
        return false;
    }

    // ...
}

XF\Entity\User#canViewPostsOnProfile:
PHP:
public function canViewPostsOnProfile(&$error = null)
{
    return $this->canViewFullProfile() && /* ... */;  // Missing reference to $error
}

XF\Entity\User#canViewFullProfile:
PHP:
public function canViewFullProfile(&$error = null)
{
    // ...

    if (/* ... */)
    {
        $error = \XF::phraseDeferred('member_limits_viewing_profile');
        return false;
    }

    // ...

    if (/* ... */)
    {
        $error = \XF::phraseDeferred('this_users_profile_is_not_available');
        return false;
    }

    // ...
}

The phrases in canViewFullProfile won't bubble to the controller because the reference to $error isn't passed along.
 

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.0 Beta 3).

Change log:
Bubble up profile post error phrases
There may be a delay before changes are rolled out to the XenForo Community.
 
Top