Now it is straightforward to fix bug 89, subst: template parameters.
[lhc/web/wiklou.git] / includes / SpecialUserlogin.php
index 8a14b64..bd78387 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 /**
  *
+ * @package MediaWiki
+ * @subpackage SpecialPage
  */
 
 /**
@@ -24,6 +26,8 @@ function wfSpecialUserlogin() {
 
 /**
  *
+ * @package MediaWiki
+ * @subpackage SpecialPage
  */
 class LoginForm {
        var $mName, $mPassword, $mRetype, $mReturnto, $mCookieCheck, $mPosted;
@@ -158,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) ||
@@ -213,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() ) );
@@ -260,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() ) );
@@ -287,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 );
@@ -351,7 +363,7 @@ class LoginForm {
                $ca = wfMsg( "createaccount" );
                $cam = wfMsg( "createaccountmail" );
                $ye = wfMsg( "youremail" );
-               if ($wgAllowRealName) {
+               if( $wgAllowRealName ) {
                    $yrn = wfMsg( "yourrealname" );
                } else {
                    $yrn = '';