r79549 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79548‎ | r79549 | r79550 >
Date:02:06, 4 January 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Rest of * (bug 25767) Add userrights properties to allusers and users query lists

Add missing parameter from r79545
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllUsers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -3131,14 +3131,18 @@
31323132 * non-existent/anonymous user accounts.
31333133 */
31343134 public function getFirstEditTimestamp() {
3135 - if( $this->getId() == 0 ) return false; // anons
 3135+ if( $this->getId() == 0 ) {
 3136+ return false; // anons
 3137+ }
31363138 $dbr = wfGetDB( DB_SLAVE );
31373139 $time = $dbr->selectField( 'revision', 'rev_timestamp',
31383140 array( 'rev_user' => $this->getId() ),
31393141 __METHOD__,
31403142 array( 'ORDER BY' => 'rev_timestamp ASC' )
31413143 );
3142 - if( !$time ) return false; // no edits
 3144+ if( !$time ) {
 3145+ return false; // no edits
 3146+ }
31433147 return wfTimestamp( TS_MW, $time );
31443148 }
31453149
Index: trunk/phase3/includes/api/ApiQueryAllUsers.php
@@ -71,6 +71,21 @@
7272 $this->addWhere( 'u1.user_name' . $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) );
7373 }
7474
 75+ if ( !is_null( $params['rights'] ) ) {
 76+ $groups = array();
 77+ foreach( $params['rights'] as $r ) {
 78+ $groups = array_merge( $groups, User::getGroupsWithPermission( $r ) );
 79+ }
 80+
 81+ $groups = array_diff( array_unique( $groups ), User::getImplicitGroups() );
 82+
 83+ if ( is_null( $params['group'] ) ) {
 84+ $params['group'] = $groups;
 85+ } else {
 86+ $params['group'] = array_unique( array_merge( $params['group'], $groups ) );
 87+ }
 88+ }
 89+
7590 if ( !is_null( $params['group'] ) ) {
7691 $useIndex = false;
7792 // Filter only users that belong to a given group
@@ -222,8 +237,13 @@
223238 'to' => null,
224239 'prefix' => null,
225240 'group' => array(
226 - ApiBase::PARAM_TYPE => User::getAllGroups()
 241+ ApiBase::PARAM_TYPE => User::getAllGroups(),
 242+ ApiBase::PARAM_ISMULTI => true,
227243 ),
 244+ 'rights' => array(
 245+ ApiBase::PARAM_TYPE => User::getAllRights(),
 246+ ApiBase::PARAM_ISMULTI => true,
 247+ ),
228248 'prop' => array(
229249 ApiBase::PARAM_ISMULTI => true,
230250 ApiBase::PARAM_TYPE => array(
@@ -249,12 +269,13 @@
250270 'from' => 'The user name to start enumerating from',
251271 'to' => 'The user name to stop enumerating at',
252272 'prefix' => 'Search for all users that begin with this value',
253 - 'group' => 'Limit users to a given group name',
 273+ 'group' => 'Limit users to given group name(s)',
 274+ 'rights' => 'Limit users to given right(s)',
254275 'prop' => array(
255276 'What pieces of information to include.',
256277 ' blockinfo - Adds the information about a current block on the user',
257278 ' groups - Lists groups that the user is in. This uses more server resources and may return fewer results than the limit',
258 - ' rights - Lists groups that the user has',
 279+ ' rights - Lists rights that the user has',
259280 ' editcount - Adds the edit count of the user',
260281 ' registration - Adds the timestamp of when the user registered',
261282 ),
Index: trunk/phase3/RELEASE-NOTES
@@ -66,6 +66,7 @@
6767 * Add a &watchuser option to ApiBlock
6868 * (bug 26541) Generator-ise ApiQueryRecentChanges
6969 * action=parse now correctly returns an error for nonexistent pages
 70+* (bug 25767) Add userrights properties to allusers and users query lists
7071
7172 === Languages updated in 1.18 ===
7273

Follow-up revisions

RevisionCommit summaryAuthorDate
r79550Crappy spaces from r79549reedy02:08, 4 January 2011
r84703Followup r79549, only try and filter by group (or right) if there are some gr...reedy20:27, 24 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79545* (bug 25767) Add userrights properties to allusers and users query lists...reedy01:39, 4 January 2011

Comments

#Comment by Duplicatebug (talk | contribs)   20:17, 24 March 2011
Exception Caught: DatabaseBase::makeList: empty input

$params['rights'] can be empty, but set. Same for $params['group']

Status & tagging log