* Sensible error messages when illegal title chars given in username
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 11 Sep 2004 06:58:47 +0000 (06:58 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 11 Sep 2004 06:58:47 +0000 (06:58 +0000)
* Don't double the login form when asked to send pass for no email user
Fixes bug 448: failure message on "mail password" is shown twice
http://bugzilla.wikipedia.org/show_bug.cgi?id=448

includes/SpecialUserlogin.php
includes/User.php

index 32e88b5..bd78387 100644 (file)
@@ -162,7 +162,8 @@ class LoginForm {
                
                $name = trim( $this->mName );
                $u = User::newFromName( $name );
-               if ( ( "" == $name ) ||
+               if ( is_null( $u ) ||
+                 ( "" == $name ) ||
                  preg_match( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/", $name ) ||
                  (strpos( $name, "/" ) !== false) ||
                  (strlen( $name ) > $wgMaxNameChars) ||
@@ -217,6 +218,10 @@ class LoginForm {
                        return;
                }
                $u = User::newFromName( $this->mName );
+               if( is_null( $u ) ) {
+                       $this->mainLoginForm( wfMsg( "noname" ) );
+                       return;
+               }
                $id = $u->idForName();
                if ( 0 == $id ) {
                        $this->mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) );
@@ -264,6 +269,10 @@ class LoginForm {
                        return;
                }
                $u = User::newFromName( $this->mName );
+               if( is_null( $u ) ) {
+                       $this->mainLoginForm( wfMsg( "noname" ) );
+                       return;
+               }
                $id = $u->idForName();
                if ( 0 == $id ) {
                        $this->mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) );
@@ -291,8 +300,7 @@ class LoginForm {
                global $wgCookiePath, $wgCookieDomain;
 
                if ( "" == $u->getEmail() ) {
-                       $this->mainLoginForm( wfMsg( "noemail", $u->getName() ) );
-                       return;
+                       return wfMsg( "noemail", $u->getName() );
                }
                $np = User::randomPassword();
                $u->setNewpassword( $np );
@@ -355,7 +363,7 @@ class LoginForm {
                $ca = wfMsg( "createaccount" );
                $cam = wfMsg( "createaccountmail" );
                $ye = wfMsg( "youremail" );
-               if ($wgAllowRealName) {
+               if( $wgAllowRealName ) {
                    $yrn = wfMsg( "yourrealname" );
                } else {
                    $yrn = '';
index 6c8c9ca..19b51a5 100644 (file)
@@ -45,8 +45,12 @@ class User {
                # Clean up name according to title rules
 
                $t = Title::newFromText( $name );
-               $u->setName( $t->getText() );
-               return $u;
+               if( is_null( $t ) ) {
+                       return NULL;
+               } else {
+                       $u->setName( $t->getText() );
+                       return $u;
+               }
        }
 
        /**