Index: trunk/phase3/includes/api/ApiUserrights.php |
— | — | @@ -117,10 +117,12 @@ |
118 | 118 | } |
119 | 119 | |
120 | 120 | $form = new UserrightsPage; |
121 | | - $user = $form->fetchUser( $params['user'] ); |
122 | | - if ( $user instanceof WikiErrorMsg ) { |
123 | | - $this->dieUsageMsg( array_merge( |
124 | | - (array)$user->getMessageKey(), $user->getMessageArgs() ) ); |
| 121 | + $status = $form->fetchUser( $params['user'] ); |
| 122 | + if ( !$status->isOK() ) { |
| 123 | + $errors = $status->getErrorsArray(); |
| 124 | + $this->dieUsageMsg( $errors[0] ); |
| 125 | + } else { |
| 126 | + $user = $status->value; |
125 | 127 | } |
126 | 128 | |
127 | 129 | $this->mUser = $user; |
Index: trunk/phase3/includes/specials/SpecialUserrights.php |
— | — | @@ -141,10 +141,12 @@ |
142 | 142 | function saveUserGroups( $username, $reason = '' ) { |
143 | 143 | global $wgRequest, $wgUser, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf; |
144 | 144 | |
145 | | - $user = $this->fetchUser( $username ); |
146 | | - if( $user instanceof WikiErrorMsg ) { |
147 | | - $wgOut->addWikiMsgArray( $user->getMessageKey(), $user->getMessageArgs() ); |
| 145 | + $status = $this->fetchUser( $username ); |
| 146 | + if( !$status->isOK() ) { |
| 147 | + $wgOut->addWikiText( $status->getWikiText() ); |
148 | 148 | return; |
| 149 | + } else { |
| 150 | + $user = $status->value; |
149 | 151 | } |
150 | 152 | |
151 | 153 | $allgroups = $this->getAllGroups(); |
— | — | @@ -247,10 +249,12 @@ |
248 | 250 | function editUserGroupsForm( $username ) { |
249 | 251 | global $wgOut; |
250 | 252 | |
251 | | - $user = $this->fetchUser( $username ); |
252 | | - if( $user instanceof WikiErrorMsg ) { |
253 | | - $wgOut->addWikiMsgArray( $user->getMessageKey(), $user->getMessageArgs() ); |
| 253 | + $status = $this->fetchUser( $username ); |
| 254 | + if( !$status->isOK() ) { |
| 255 | + $wgOut->addWikiText( $status->getWikiText() ); |
254 | 256 | return; |
| 257 | + } else { |
| 258 | + $user = $status->value; |
255 | 259 | } |
256 | 260 | |
257 | 261 | $groups = $user->getGroups(); |
— | — | @@ -267,7 +271,7 @@ |
268 | 272 | * return a user (or proxy) object for manipulating it. |
269 | 273 | * |
270 | 274 | * Side effects: error output for invalid access |
271 | | - * @return mixed User, UserRightsProxy, or WikiErrorMsg |
| 275 | + * @return Status object |
272 | 276 | */ |
273 | 277 | public function fetchUser( $username ) { |
274 | 278 | global $wgUser, $wgUserrightsInterwikiDelimiter; |
— | — | @@ -283,16 +287,16 @@ |
284 | 288 | $database = ''; |
285 | 289 | } else { |
286 | 290 | if( !$wgUser->isAllowed( 'userrights-interwiki' ) ) { |
287 | | - return new WikiErrorMsg( 'userrights-no-interwiki' ); |
| 291 | + return Status::newFatal( 'userrights-no-interwiki' ); |
288 | 292 | } |
289 | 293 | if( !UserRightsProxy::validDatabase( $database ) ) { |
290 | | - return new WikiErrorMsg( 'userrights-nodatabase', $database ); |
| 294 | + return Status::newFatal( 'userrights-nodatabase', $database ); |
291 | 295 | } |
292 | 296 | } |
293 | 297 | } |
294 | 298 | |
295 | 299 | if( $name === '' ) { |
296 | | - return new WikiErrorMsg( 'nouserspecified' ); |
| 300 | + return Status::newFatal( 'nouserspecified' ); |
297 | 301 | } |
298 | 302 | |
299 | 303 | if( $name{0} == '#' ) { |
— | — | @@ -307,13 +311,13 @@ |
308 | 312 | } |
309 | 313 | |
310 | 314 | if( !$name ) { |
311 | | - return new WikiErrorMsg( 'noname' ); |
| 315 | + return Status::newFatal( 'noname' ); |
312 | 316 | } |
313 | 317 | } else { |
314 | 318 | $name = User::getCanonicalName( $name ); |
315 | 319 | if( $name === false ) { |
316 | 320 | // invalid name |
317 | | - return new WikiErrorMsg( 'nosuchusershort', $username ); |
| 321 | + return Status::newFatal( 'nosuchusershort', $username ); |
318 | 322 | } |
319 | 323 | } |
320 | 324 | |
— | — | @@ -324,10 +328,10 @@ |
325 | 329 | } |
326 | 330 | |
327 | 331 | if( !$user || $user->isAnon() ) { |
328 | | - return new WikiErrorMsg( 'nosuchusershort', $username ); |
| 332 | + return Status::newFatal( 'nosuchusershort', $username ); |
329 | 333 | } |
330 | 334 | |
331 | | - return $user; |
| 335 | + return Status::newGood( $user ); |
332 | 336 | } |
333 | 337 | |
334 | 338 | function makeGroupNameList( $ids ) { |
Index: trunk/extensions/CentralAuth/SpecialGlobalGroupMembership.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | #specify addself and removeself as empty arrays -- bug 16098 |
70 | 70 | return array( 'add' => $allGroups, 'remove' => $allGroups, 'add-self' => array(), 'remove-self' => array() ); |
71 | 71 | } else { |
72 | | - return array(); |
| 72 | + return array( 'add' => array(), 'remove' => array(), 'add-self' => array(), 'remove-self' => array() ); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
— | — | @@ -80,13 +80,13 @@ |
81 | 81 | $user = CentralAuthGroupMembershipProxy::newFromName( $username ); |
82 | 82 | |
83 | 83 | if( !$user ) { |
84 | | - return new WikiErrorMsg( 'nosuchusershort', $username ); |
| 84 | + return Status::newFatal( 'nosuchusershort', $username ); |
85 | 85 | } elseif (!$wgRequest->getCheck( 'saveusergroups' ) && !$user->attachedOn($knownwiki)) { |
86 | | - return new WikiErrorMsg( 'centralauth-globalgroupmembership-badknownwiki', |
| 86 | + return Status::newFatal( 'centralauth-globalgroupmembership-badknownwiki', |
87 | 87 | $username, $knownwiki ); |
88 | 88 | } |
89 | 89 | |
90 | | - return $user; |
| 90 | + return Status::newGood( $user ); |
91 | 91 | } |
92 | 92 | |
93 | 93 | protected static function getAllGroups() { |