r63490 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63489‎ | r63490 | r63491 >
Date:19:27, 9 March 2010
Author:simetrical
Status:ok
Tags:
Comment:
Avoid fatal on login if username is invalid title

Steps to reproduce: Try logging in with a 256-character username.

Expected result: Friendly error message saying the name is invalid.

Actual result: Fatal error: Call to a member function getName() on a
non-object in /var/www/git-trunk/phase3/includes/specials/SpecialUserlogin.php
on line 433

Fix: If you want to check whether something is a User object, check
whether it's a User object. There are things other than null that don't
behave like User objects.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -430,7 +430,7 @@
431431 # TODO: Allow some magic here for invalid external names, e.g., let the
432432 # user choose a different wiki name.
433433 $u = User::newFromName( $this->mName );
434 - if( is_null( $u ) || !User::isUsableName( $u->getName() ) ) {
 434+ if( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) {
435435 return self::ILLEGAL;
436436 }
437437

Follow-up revisions

RevisionCommit summaryAuthorDate
r647831.16wmf4: MFT r63490catrope10:39, 9 April 2010
r65360MFT r63490, r64837, r64860, r64862: bug fixes for callers of User::newFromNam...tstarling09:30, 21 April 2010

Status & tagging log