If the given title is bad, don't die horribly but return a null user
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 26 Apr 2004 07:32:52 +0000 (07:32 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 26 Apr 2004 07:32:52 +0000 (07:32 +0000)
includes/User.php

index 6b0632d..b0a5afc 100644 (file)
@@ -44,13 +44,19 @@ class User {
        /* static */ function idFromName( $name )
        {
                $nt = Title::newFromText( $name );
+               if( is_null( $nt ) ) {
+                       # Illegal name
+                       return null;
+               }
                $sql = "SELECT user_id FROM user WHERE user_name='" .
                  wfStrencode( $nt->getText() ) . "'";
                $res = wfQuery( $sql, DB_READ, "User::idFromName" );
 
-               if ( 0 == wfNumRows( $res ) ) { return 0; }
-               else {
+               if ( 0 == wfNumRows( $res ) ) {
+                       return 0;
+               } else {
                        $s = wfFetchObject( $res );
+                       wfFreeResult( $res );
                        return $s->user_id;
                }
        }