Last modified: 2014-05-06 15:24:49 UTC
The User class propose several factory methods. Most of them will always return a User object but two of them would not: User::newFromName() can return false User::newFromConfirmationCode() can return null I would prefer having factories return null if no object have been made. This way we will avoid fatal errors when passing the result to a function explicitly expecting a User object. Example <?php function delete( User $user ) { // do something } delete( User::newFromName( '127.0.0.1' ) ); ?> That code will throw a catchable fatal error since the delete function expect either a User object or the null value.
So basically, User::newFromName() should return null :-)
Updated summary to say so :)
We'll need to do a quick scan for code that may use === false explicitly, but if we don't find any of that, then I see no problem with this change.
Lines 192 and 193 in maintenance/importImages.php: $wgUser = User::newFromName( $real_user ); if ( $wgUser === false ) {
This has too many possible back compatibility issues and there is no good way to deprecate the old values. So lets keep the code dirty. Maybe one day we will refactor the User class entirely. Meanwhile there is no point in keeping this bug around.