r71837 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71836‎ | r71837 | r71838 >
Date:01:09, 28 August 2010
Author:reedy
Status:ok
Tags:
Comment:
Bug 19195 - Make user IDs more readily available with the API

Rest of user props done
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryRecentChanges.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUserContributions.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php
@@ -41,9 +41,9 @@
4242 parent::__construct( $query, $moduleName, 'rc' );
4343 }
4444
45 - private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_flags = false,
46 - $fld_timestamp = false, $fld_title = false, $fld_ids = false,
47 - $fld_sizes = false;
 45+ private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
 46+ $fld_flags = false, $fld_timestamp = false, $fld_title = false, $fld_ids = false,
 47+ $fld_sizes = false, $fld_redirect = false, $fld_patrolled = false, $fld_loginfo = false, $fld_tags = false;
4848 /**
4949 * Get an array mapping token names to their handler functions.
5050 * The prototype for a token function is func($pageid, $title, $rc)
@@ -94,6 +94,7 @@
9595 $this->fld_comment = isset( $prop['comment'] );
9696 $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
9797 $this->fld_user = isset( $prop['user'] );
 98+ $this->fld_userid = isset( $prop['userid'] );
9899 $this->fld_flags = isset( $prop['flags'] );
99100 $this->fld_timestamp = isset( $prop['timestamp'] );
100101 $this->fld_title = isset( $prop['title'] );
@@ -208,7 +209,7 @@
209210 $this->addFieldsIf( 'rc_last_oldid', $this->fld_ids );
210211 $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
211212 $this->addFieldsIf( 'rc_user', $this->fld_user );
212 - $this->addFieldsIf( 'rc_user_text', $this->fld_user );
 213+ $this->addFieldsIf( 'rc_user_text', $this->fld_user || $this->fld_userid );
213214 $this->addFieldsIf( 'rc_minor', $this->fld_flags );
214215 $this->addFieldsIf( 'rc_bot', $this->fld_flags );
215216 $this->addFieldsIf( 'rc_new', $this->fld_flags );
@@ -335,8 +336,16 @@
336337 }
337338
338339 /* Add user data and 'anon' flag, if use is anonymous. */
339 - if ( $this->fld_user ) {
340 - $vals['user'] = $row->rc_user_text;
 340+ if ( $this->fld_user || $this->fld_userid ) {
 341+
 342+ if ( $this->fld_user ) {
 343+ $vals['user'] = $row->rc_user_text;
 344+ }
 345+
 346+ if ( $this->fld_userid ) {
 347+ $vals['userid'] = $row->rc_user;
 348+ }
 349+
341350 if ( !$row->rc_user ) {
342351 $vals['anon'] = '';
343352 }
@@ -491,6 +500,7 @@
492501 ApiBase::PARAM_DFLT => 'title|timestamp|ids',
493502 ApiBase::PARAM_TYPE => array(
494503 'user',
 504+ 'userid',
495505 'comment',
496506 'parsedcomment',
497507 'flags',
@@ -552,6 +562,7 @@
553563 'prop' => array(
554564 'Include additional pieces of information',
555565 ' user - Adds the user responsible for the edit and tags if they are an IP',
 566+ ' userid - Adds the user id responsible for the edit',
556567 ' comment - Adds the comment for the edit',
557568 ' parsedcomment - Adds the parsed comment for the edit',
558569 ' flags - Adds flags for the edit',
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php
@@ -51,7 +51,7 @@
5252
5353 private $fld_ids = false, $fld_title = false, $fld_patrol = false, $fld_flags = false,
5454 $fld_timestamp = false, $fld_user = false, $fld_comment = false, $fld_parsedcomment = false, $fld_sizes = false,
55 - $fld_notificationtimestamp = false;
 55+ $fld_notificationtimestamp = false, $fld_userid = false;
5656
5757 private function run( $resultPageSet = null ) {
5858 $this->selectNamedDB( 'watchlist', DB_SLAVE, 'watchlist' );
@@ -67,6 +67,7 @@
6868 $this->fld_title = isset( $prop['title'] );
6969 $this->fld_flags = isset( $prop['flags'] );
7070 $this->fld_user = isset( $prop['user'] );
 71+ $this->fld_userid = isset( $prop['userid'] );
7172 $this->fld_comment = isset( $prop['comment'] );
7273 $this->fld_parsedcomment = isset ( $prop['parsedcomment'] );
7374 $this->fld_timestamp = isset( $prop['timestamp'] );
@@ -96,7 +97,7 @@
9798 $this->addFieldsIf( 'rc_new', $this->fld_flags );
9899 $this->addFieldsIf( 'rc_minor', $this->fld_flags );
99100 $this->addFieldsIf( 'rc_bot', $this->fld_flags );
100 - $this->addFieldsIf( 'rc_user', $this->fld_user );
 101+ $this->addFieldsIf( 'rc_user', $this->fld_user || $this->fld_userid );
101102 $this->addFieldsIf( 'rc_user_text', $this->fld_user );
102103 $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
103104 $this->addFieldsIf( 'rc_patrolled', $this->fld_patrol );
@@ -228,8 +229,16 @@
229230 ApiQueryBase::addTitleInfo( $vals, $title );
230231 }
231232
232 - if ( $this->fld_user ) {
233 - $vals['user'] = $row->rc_user_text;
 233+ if ( $this->fld_user || $this->fld_userid ) {
 234+
 235+ if ( $this->fld_user ) {
 236+ $vals['user'] = $row->rc_user_text;
 237+ }
 238+
 239+ if ( $this->fld_userid ) {
 240+ $vals['user'] = $row->rc_user;
 241+ }
 242+
234243 if ( !$row->rc_user ) {
235244 $vals['anon'] = '';
236245 }
@@ -319,6 +328,7 @@
320329 'title',
321330 'flags',
322331 'user',
 332+ 'userid',
323333 'comment',
324334 'parsedcomment',
325335 'timestamp',
@@ -364,7 +374,8 @@
365375 ' ids - Adds revision ids and page ids',
366376 ' title - Adds title of the page',
367377 ' flags - Adds flags for the edit',
368 - ' user - Adds user who made the edit',
 378+ ' user - Adds the user who made the edit',
 379+ ' userid - Adds user id of whom made the edit',
369380 ' comment - Adds comment of the edit',
370381 ' parsedcomment - Adds parsed comment of the edit',
371382 ' timestamp - Adds timestamp of the edit',
Index: trunk/phase3/includes/api/ApiQueryUserContributions.php
@@ -43,7 +43,7 @@
4444 private $params;
4545 private $fld_ids = false, $fld_title = false, $fld_timestamp = false,
4646 $fld_comment = false, $fld_parsedcomment = false, $fld_flags = false,
47 - $fld_patrolled = false, $fld_tags = false;
 47+ $fld_patrolled = false, $fld_tags = false, $fld_size = false;
4848
4949 public function execute() {
5050 // Parse some parameters
@@ -206,6 +206,7 @@
207207 'rev_timestamp',
208208 'page_namespace',
209209 'page_title',
 210+ 'rev_user',
210211 'rev_user_text',
211212 'rev_deleted'
212213 ) );
@@ -272,6 +273,7 @@
273274 private function extractRowInfo( $row ) {
274275 $vals = array();
275276
 277+ $vals['userid'] = $row->rev_user;
276278 $vals['user'] = $row->rev_user_text;
277279 if ( $row->rev_deleted & Revision::DELETED_USER ) {
278280 $vals['userhidden'] = '';

Status & tagging log