Index: trunk/phase3/maintenance/protect.php |
— | — | @@ -47,6 +47,10 @@ |
48 | 48 | } |
49 | 49 | |
50 | 50 | $wgUser = User::newFromName( $userName ); |
| 51 | + if ( !$wgUser ) { |
| 52 | + $this->error( "Invalid username", true ); |
| 53 | + } |
| 54 | + |
51 | 55 | $restrictions = array( 'edit' => $protection, 'move' => $protection ); |
52 | 56 | |
53 | 57 | $t = Title::newFromText( $this->getArg() ); |
Index: trunk/phase3/maintenance/undelete.php |
— | — | @@ -44,6 +44,9 @@ |
45 | 45 | $this->error( "Invalid title", true ); |
46 | 46 | } |
47 | 47 | $wgUser = User::newFromName( $user ); |
| 48 | + if ( !$wgUser ) { |
| 49 | + $this->error( "Invalid username", true ); |
| 50 | + } |
48 | 51 | $archive = new PageArchive( $title ); |
49 | 52 | $this->output( "Undeleting " . $title->getPrefixedDBkey() . '...' ); |
50 | 53 | $archive->undelete( array(), $reason ); |
Index: trunk/phase3/maintenance/moveBatch.php |
— | — | @@ -67,6 +67,9 @@ |
68 | 68 | $this->error( "Unable to read file, exiting", true ); |
69 | 69 | } |
70 | 70 | $wgUser = User::newFromName( $user ); |
| 71 | + if ( !$wgUser ) { |
| 72 | + $this->error( "Invalid username", true ); |
| 73 | + } |
71 | 74 | |
72 | 75 | # Setup complete, now start |
73 | 76 | $dbw = wfGetDB( DB_MASTER ); |
Index: trunk/phase3/maintenance/changePassword.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | } else { |
45 | 45 | $this->error( "A \"user\" or \"userid\" must be set to change the password for" , true ); |
46 | 46 | } |
47 | | - if ( !$user->getId() ) { |
| 47 | + if ( !$user || !$user->getId() ) { |
48 | 48 | $this->error( "No such user: " . $this->getOption( 'user' ), true ); |
49 | 49 | } |
50 | 50 | try { |
Index: trunk/phase3/maintenance/deleteBatch.php |
— | — | @@ -63,6 +63,9 @@ |
64 | 64 | $this->error( "Unable to read file, exiting", true ); |
65 | 65 | } |
66 | 66 | $wgUser = User::newFromName( $user ); |
| 67 | + if ( !$wgUser ) { |
| 68 | + $this->error( "Invalid username", true ); |
| 69 | + } |
67 | 70 | $dbw = wfGetDB( DB_MASTER ); |
68 | 71 | |
69 | 72 | # Handle each entry |
Index: trunk/phase3/maintenance/deleteDefaultMessages.php |
— | — | @@ -56,6 +56,9 @@ |
57 | 57 | # in order to hide it in RecentChanges. |
58 | 58 | global $wgUser; |
59 | 59 | $wgUser = User::newFromName( $user ); |
| 60 | + if ( !$wgUser ) { |
| 61 | + $this->error( "Invalid username", true ); |
| 62 | + } |
60 | 63 | $wgUser->addGroup( 'bot' ); |
61 | 64 | |
62 | 65 | # Handle deletion |
Index: trunk/phase3/maintenance/reassignEdits.php |
— | — | @@ -160,6 +160,9 @@ |
161 | 161 | $user->setName( $username ); |
162 | 162 | } else { |
163 | 163 | $user = User::newFromName( $username ); |
| 164 | + if ( !$user ) { |
| 165 | + $this->error( "Invalid username", true ); |
| 166 | + } |
164 | 167 | } |
165 | 168 | $user->load(); |
166 | 169 | return $user; |
Index: trunk/phase3/maintenance/cleanupSpam.php |
— | — | @@ -36,6 +36,9 @@ |
37 | 37 | |
38 | 38 | $username = wfMsg( 'spambot_username' ); |
39 | 39 | $wgUser = User::newFromName( $username ); |
| 40 | + if ( !$wgUser ) { |
| 41 | + $this->error( "Invalid username", true ); |
| 42 | + } |
40 | 43 | // Create the user if necessary |
41 | 44 | if ( !$wgUser->getId() ) { |
42 | 45 | $wgUser->addToDatabase(); |
Index: trunk/phase3/CREDITS |
— | — | @@ -163,6 +163,7 @@ |
164 | 164 | * Scott Colcord |
165 | 165 | * Simon Walker |
166 | 166 | * Solitarius |
| 167 | +* Søren Løvborg |
167 | 168 | * Stefano Codari |
168 | 169 | * Str4nd |
169 | 170 | * svip |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -928,7 +928,7 @@ |
929 | 929 | $user = User::newFromName( $rootPart, false /* allow IP users*/ ); |
930 | 930 | $ip = User::isIP( $rootPart ); |
931 | 931 | |
932 | | - if ( !$user->isLoggedIn() && !$ip ) { # User does not exist |
| 932 | + if ( !($user && $user->isLoggedIn()) && !$ip ) { # User does not exist |
933 | 933 | $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>", |
934 | 934 | array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) ); |
935 | 935 | } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -1475,7 +1475,7 @@ |
1476 | 1476 | $username = $parts[0]; |
1477 | 1477 | $user = User::newFromName( $username, false /* allow IP users*/ ); |
1478 | 1478 | $ip = User::isIP( $username ); |
1479 | | - if ( !$user->isLoggedIn() && !$ip ) { # User does not exist |
| 1479 | + if ( !($user && $user->isLoggedIn()) && !$ip ) { # User does not exist |
1480 | 1480 | $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>", |
1481 | 1481 | array( 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ) ); |
1482 | 1482 | } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -1301,7 +1301,7 @@ |
1302 | 1302 | public function getWatchlistUser( $params ) { |
1303 | 1303 | if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) { |
1304 | 1304 | $user = User::newFromName( $params['owner'], false ); |
1305 | | - if ( !$user->getId() ) { |
| 1305 | + if ( !($user && $user->getId()) ) { |
1306 | 1306 | $this->dieUsage( 'Specified user does not exist', 'bad_wlowner' ); |
1307 | 1307 | } |
1308 | 1308 | $token = $user->getOption( 'watchlisttoken' ); |
Index: trunk/phase3/includes/job/DoubleRedirectJob.php |
— | — | @@ -180,6 +180,7 @@ |
181 | 181 | function getUser() { |
182 | 182 | if ( !self::$user ) { |
183 | 183 | self::$user = User::newFromName( wfMsgForContent( 'double-redirect-fixer' ), false ); |
| 184 | + # FIXME: newFromName could return false on a badly configured wiki. |
184 | 185 | if ( !self::$user->isLoggedIn() ) { |
185 | 186 | self::$user->addToDatabase(); |
186 | 187 | } |
Index: trunk/phase3/includes/job/EnotifNotifyJob.php |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | $editor = User::newFromId( $this->params['editorID'] ); |
26 | 26 | // B/C, only the name might be given. |
27 | 27 | } else { |
| 28 | + # FIXME: newFromName could return false on a badly configured wiki. |
28 | 29 | $editor = User::newFromName( $this->params['editor'], false ); |
29 | 30 | } |
30 | 31 | $enotif->actuallyNotifyOnPageChange( |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -2322,7 +2322,9 @@ |
2323 | 2323 | # User talk pages |
2324 | 2324 | if ( $title->getNamespace() == NS_USER_TALK ) { |
2325 | 2325 | $user = User::newFromName( $title->getText(), false ); |
2326 | | - $user->setNewtalk( false ); |
| 2326 | + if ( $user ) { |
| 2327 | + $user->setNewtalk( false ); |
| 2328 | + } |
2327 | 2329 | } |
2328 | 2330 | |
2329 | 2331 | # Image redirects |
Index: trunk/phase3/includes/specials/SpecialBlockme.php |
— | — | @@ -45,6 +45,7 @@ |
46 | 46 | } |
47 | 47 | |
48 | 48 | $user = User::newFromName( wfMsgForContent( 'proxyblocker' ) ); |
| 49 | + # FIXME: newFromName could return false on a badly configured wiki. |
49 | 50 | if ( !$user->isLoggedIn() ) { |
50 | 51 | $user->addToDatabase(); |
51 | 52 | } |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -269,7 +269,7 @@ |
270 | 270 | $this->mRelevantUser = User::newFromName( $rootUser, false ); |
271 | 271 | } else { |
272 | 272 | $user = User::newFromName( $rootUser, false ); |
273 | | - if ( $user->isLoggedIn() ) { |
| 273 | + if ( $user && $user->isLoggedIn() ) { |
274 | 274 | $this->mRelevantUser = $user; |
275 | 275 | } |
276 | 276 | } |