Jake B.
Well-known member
- Affected version
- 2.2.4
Looks like a check is missing because it's not something you can encounter under normal usage
to
PHP:
protected function getUserFromContext(array $context)
{
$em = \XF::em();
if (!empty($context['profile_post_id']))
{
/** @var \XF\Entity\ProfilePost $profilePost */
$profilePost = $em->find('XF:ProfilePost', intval($context['profile_post_id']), ['ProfileUser']);
if (!$profilePost || !$profilePost->canView() || !$profilePost->canEdit())
{
return null;
}
$user = $profilePost->ProfileUser;
}
else if (!empty($context['profile_user_id']))
{
/** @var \XF\Entity\User $user */
$user = $em->find('XF:User', intval($context['profile_user_id']));
if (!$user)
{
return null;
}
}
return $user;
}
to
PHP:
protected function getUserFromContext(array $context)
{
$em = \XF::em();
if (!empty($context['profile_post_id']))
{
/** @var \XF\Entity\ProfilePost $profilePost */
$profilePost = $em->find('XF:ProfilePost', intval($context['profile_post_id']), ['ProfileUser']);
if (!$profilePost || !$profilePost->canView() || !$profilePost->canEdit())
{
return null;
}
$user = $profilePost->ProfileUser;
if (!$user)
{
return null;
}
}
else if (!empty($context['profile_user_id']))
{
/** @var \XF\Entity\User $user */
$user = $em->find('XF:User', intval($context['profile_user_id']));
if (!$user)
{
return null;
}
}
return $user;
}