Page MenuHomePhabricator

Visiting the user page of an IP address causes fatal error
Closed, ResolvedPublic


On a wiki with latest SocialProfile extension, visiting user page of an IP address (for example [[User:]]) results in a PHP fatal error:

/wiki/User:   PHP Fatal Error from line 82 of .../extensions/SocialProfile/UserProfile/includes/UserProfile.php: Uncaught Error: Call to a member function getName() on bool in .../extensions/SocialProfile/UserProfile/includes/UserProfile.php:82
Stack trace:
#0 .../extensions/SocialProfile/UserProfile/includes/UserProfileHooks.php(35): UserProfile->__construct('')
#1 .../includes/Hooks.php(174): UserProfileHooks::onOutputPageBodyAttributes(Object(OutputPage), Object(SkinMonoBook), Array)
#2 .../includes/Hooks.php(202): Hooks::callHook('OutputPageBodyA...', Array, Array, NULL)
#3 .../includes/OutputPage.php(3092): Hooks::run('OutputPageBodyA...', Array)
#4 .../includes/skins/SkinTemplate.php(459): OutputPage->headElement(Object(SkinMonoBook))
#5 .../includes/skins/SkinTemplate.php(215): SkinTemplate->prepareQuickTemplate()

This is because User::newFromName returns false when the input is an invalid user...

	public function __construct( $username ) {
		if ( $username instanceof User ) {
			$this->user = $username;
		} else {
			$this->user = User::newFromName( $username );
		$this->user_name = $this->user->getName();
		$this->user_id = $this->user->getId();

Event Timeline

Restricted Application added a project: Social-Tools. · View Herald TranscriptMay 20 2020, 5:38 PM
Ciencia_Al_Poder moved this task from Backlog to Bugs on the SocialProfile board.May 20 2020, 5:41 PM
ashley added a subscriber: ashley.May 22 2020, 10:16 AM

Should be mitigated by 8e46a284bd7d80c3d2a09d2db1064144cb1767f0 (already merged a few days ago), but please check.

Ciencia_Al_Poder closed this task as Resolved.May 24 2020, 4:08 PM
Ciencia_Al_Poder assigned this task to ashley.

Cool thanks! Indeed it fixes the issue