Fixed Undefined index: username when calling XF\Report\User::getContentTitle

Xon

Well-known member
Affected version
2.0.11
Code:
ErrorException: [E_NOTICE] Undefined index: username in src/XF/Report/User.php at line 44
XF::handlePhpError() in src/XF/Report/User.php at line 44
XF\Report\User->getContentTitle() in src/XF/Entity/Report.php at line 86
...

PHP:
public function getContentTitle(Report $report)
{
   $content = $report->content_info;

   if (isset($content['username']))
   {
      $name = $content['username'];
   }
   else if (isset($content['user']['username']))
   {
      $name = $content['user']['username'];
   }
   else
   {
      $name = '';
   }

   return \XF::phrase('member_x', [
      'username' => $report->content_info['username']
   ]);
}

$name is unused, making the previous checks broken. Probably should use "guest' rather than an empty string too

Note; this effects XF2.1.0
 
Back
Top Bottom