From e0f7ccce1992008da7079f67e89d15ae4b8f823f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 26 Apr 2004 07:32:52 +0000 Subject: [PATCH] If the given title is bad, don't die horribly but return a null user --- includes/User.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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; } } -- 2.20.1