From: Brion Vibber Date: Mon, 26 Apr 2004 07:32:52 +0000 (+0000) Subject: If the given title is bad, don't die horribly but return a null user X-Git-Tag: 1.3.0beta1~275 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=e0f7ccce1992008da7079f67e89d15ae4b8f823f;p=lhc%2Fweb%2Fwiklou.git If the given title is bad, don't die horribly but return a null user --- diff --git a/includes/User.php b/includes/User.php index 6b0632db03..b0a5afc85d 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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; } }