r64825 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64824‎ | r64825 | r64826 >
Date:20:02, 9 April 2010
Author:reedy
Status:reverted (Comments)
Tags:
Comment:
Reuse created instance of UserrightsPage
Modified paths:
  • /trunk/phase3/includes/api/ApiUserrights.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiUserrights.php
@@ -40,8 +40,7 @@
4141 $params = $this->extractRequestParams();
4242
4343 // User already validated in call to getTokenSalt from Main
44 - $form = new UserrightsPage;
45 - $user = $form->fetchUser( $params['user'] );
 44+ $user = $this->mForm->fetchUser( $params['user'] );
4645
4746 $r['user'] = $user->getName();
4847 list( $r['added'], $r['removed'] ) =
@@ -108,8 +107,8 @@
109108 $this->dieUsageMsg( array( 'missingparam', 'user' ) );
110109 }
111110
112 - $form = new UserrightsPage;
113 - $user = $form->fetchUser( $params['user'] );
 111+ $this->mForm = new UserrightsPage;
 112+ $user = $this->mForm->fetchUser( $params['user'] );
114113 if ( $user instanceof WikiErrorMsg ) {
115114 $this->dieUsageMsg( array_merge(
116115 (array)$user->getMessageKey(), $user->getMessageArgs() ) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r64873Revert r64825reedy12:29, 10 April 2010

Comments

#Comment by Catrope (talk | contribs)   12:01, 10 April 2010

I recommend reverting this. The overhead of creating a simple object such as UserrightsPage is small, and the assumptions about code flow needed to understand the code make it ugly.

Status & tagging log