r65131 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65130‎ | r65131 | r65132 >
Date:15:56, 16 April 2010
Author:ialex
Status:ok
Tags:
Comment:
* part of bug 23119: removed WikiError stuff for Special:Userrights, also updated CentralAuth extension
* fixed E_NOTICE in Special:GlobalGroupMembership when the user cannot change global permissions
Modified paths:
  • /trunk/extensions/CentralAuth/SpecialGlobalGroupMembership.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUserrights.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserrights.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiUserrights.php
@@ -117,10 +117,12 @@
118118 }
119119
120120 $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;
125127 }
126128
127129 $this->mUser = $user;
Index: trunk/phase3/includes/specials/SpecialUserrights.php
@@ -141,10 +141,12 @@
142142 function saveUserGroups( $username, $reason = '' ) {
143143 global $wgRequest, $wgUser, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
144144
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() );
148148 return;
 149+ } else {
 150+ $user = $status->value;
149151 }
150152
151153 $allgroups = $this->getAllGroups();
@@ -247,10 +249,12 @@
248250 function editUserGroupsForm( $username ) {
249251 global $wgOut;
250252
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() );
254256 return;
 257+ } else {
 258+ $user = $status->value;
255259 }
256260
257261 $groups = $user->getGroups();
@@ -267,7 +271,7 @@
268272 * return a user (or proxy) object for manipulating it.
269273 *
270274 * Side effects: error output for invalid access
271 - * @return mixed User, UserRightsProxy, or WikiErrorMsg
 275+ * @return Status object
272276 */
273277 public function fetchUser( $username ) {
274278 global $wgUser, $wgUserrightsInterwikiDelimiter;
@@ -283,16 +287,16 @@
284288 $database = '';
285289 } else {
286290 if( !$wgUser->isAllowed( 'userrights-interwiki' ) ) {
287 - return new WikiErrorMsg( 'userrights-no-interwiki' );
 291+ return Status::newFatal( 'userrights-no-interwiki' );
288292 }
289293 if( !UserRightsProxy::validDatabase( $database ) ) {
290 - return new WikiErrorMsg( 'userrights-nodatabase', $database );
 294+ return Status::newFatal( 'userrights-nodatabase', $database );
291295 }
292296 }
293297 }
294298
295299 if( $name === '' ) {
296 - return new WikiErrorMsg( 'nouserspecified' );
 300+ return Status::newFatal( 'nouserspecified' );
297301 }
298302
299303 if( $name{0} == '#' ) {
@@ -307,13 +311,13 @@
308312 }
309313
310314 if( !$name ) {
311 - return new WikiErrorMsg( 'noname' );
 315+ return Status::newFatal( 'noname' );
312316 }
313317 } else {
314318 $name = User::getCanonicalName( $name );
315319 if( $name === false ) {
316320 // invalid name
317 - return new WikiErrorMsg( 'nosuchusershort', $username );
 321+ return Status::newFatal( 'nosuchusershort', $username );
318322 }
319323 }
320324
@@ -324,10 +328,10 @@
325329 }
326330
327331 if( !$user || $user->isAnon() ) {
328 - return new WikiErrorMsg( 'nosuchusershort', $username );
 332+ return Status::newFatal( 'nosuchusershort', $username );
329333 }
330334
331 - return $user;
 335+ return Status::newGood( $user );
332336 }
333337
334338 function makeGroupNameList( $ids ) {
Index: trunk/extensions/CentralAuth/SpecialGlobalGroupMembership.php
@@ -68,7 +68,7 @@
6969 #specify addself and removeself as empty arrays -- bug 16098
7070 return array( 'add' => $allGroups, 'remove' => $allGroups, 'add-self' => array(), 'remove-self' => array() );
7171 } else {
72 - return array();
 72+ return array( 'add' => array(), 'remove' => array(), 'add-self' => array(), 'remove-self' => array() );
7373 }
7474 }
7575
@@ -80,13 +80,13 @@
8181 $user = CentralAuthGroupMembershipProxy::newFromName( $username );
8282
8383 if( !$user ) {
84 - return new WikiErrorMsg( 'nosuchusershort', $username );
 84+ return Status::newFatal( 'nosuchusershort', $username );
8585 } elseif (!$wgRequest->getCheck( 'saveusergroups' ) && !$user->attachedOn($knownwiki)) {
86 - return new WikiErrorMsg( 'centralauth-globalgroupmembership-badknownwiki',
 86+ return Status::newFatal( 'centralauth-globalgroupmembership-badknownwiki',
8787 $username, $knownwiki );
8888 }
8989
90 - return $user;
 90+ return Status::newGood( $user );
9191 }
9292
9393 protected static function getAllGroups() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r77870* (bug 23119) WikiError class and subclasses are now marked as deprecated...ialex10:09, 6 December 2010

Status & tagging log