Page MenuHomePhabricator

User::__toString() can return a non-string, causing fatal errors
Closed, ResolvedPublic

Description

Initially reported and debugged at https://github.com/SimpleMachines/smf-mw-auth/issues/10

In User::doLogout():

			\MediaWiki\Logger\LoggerFactory::getInstance( 'session' )
				->warning( __METHOD__ .
					": Cannot log user \"$this\" out of a user \"{$session->getUser()}\"'s session"
				);

relying upon the implicit $this->__toString().

	public function __toString() {
		return $this->getName();
	}

okay looks fine,

getName() calls IP::sanitizeIP which can return null. Unsure why that is returning null, but we should at least make sure __toString() always returns a string, or throw an error earlier in the stack.

Details

Related Gerrit Patches:

Event Timeline

Legoktm created this task.Oct 18 2016, 1:17 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 18 2016, 1:17 AM

Change 316721 had a related patch set uploaded (by Gergő Tisza):
Force User::__toString() return value to be string

https://gerrit.wikimedia.org/r/316721

Change 316721 merged by jenkins-bot:
Force User::__toString() return value to be string

https://gerrit.wikimedia.org/r/316721

Tgr closed this task as Resolved.Oct 19 2016, 12:06 AM
Tgr claimed this task.

Should we backport to REL1_27?

Change 316729 had a related patch set uploaded (by Gergő Tisza):
Force User::__toString() return value to be string

https://gerrit.wikimedia.org/r/316729

Change 316729 merged by jenkins-bot:
Force User::__toString() return value to be string

https://gerrit.wikimedia.org/r/316729