http://www.mediawiki.org/wiki/Special:Code/MediaWiki/71837

Revision: 71837
Author:   reedy
Date:     2010-08-28 01:09:21 +0000 (Sat, 28 Aug 2010)

Log Message:
-----------
Bug 19195 - Make user IDs more readily available with the API

Rest of user props done

Modified Paths:
--------------
    trunk/phase3/includes/api/ApiQueryRecentChanges.php
    trunk/phase3/includes/api/ApiQueryUserContributions.php
    trunk/phase3/includes/api/ApiQueryWatchlist.php

Modified: trunk/phase3/includes/api/ApiQueryRecentChanges.php
===================================================================
--- trunk/phase3/includes/api/ApiQueryRecentChanges.php 2010-08-28 00:57:58 UTC 
(rev 71836)
+++ trunk/phase3/includes/api/ApiQueryRecentChanges.php 2010-08-28 01:09:21 UTC 
(rev 71837)
@@ -41,9 +41,9 @@
                parent::__construct( $query, $moduleName, 'rc' );
        }
 
-       private $fld_comment = false, $fld_parsedcomment = false, $fld_user = 
false, $fld_flags = false,
-                       $fld_timestamp = false, $fld_title = false, $fld_ids = 
false,
-                       $fld_sizes = false;
+       private $fld_comment = false, $fld_parsedcomment = false, $fld_user = 
false, $fld_userid = false,
+                       $fld_flags = false, $fld_timestamp = false, $fld_title 
= false, $fld_ids = false,
+                       $fld_sizes = false, $fld_redirect = false, 
$fld_patrolled = false, $fld_loginfo = false, $fld_tags = false;
        /**
         * Get an array mapping token names to their handler functions.
         * The prototype for a token function is func($pageid, $title, $rc)
@@ -94,6 +94,7 @@
                $this->fld_comment = isset( $prop['comment'] );
                $this->fld_parsedcomment = isset( $prop['parsedcomment'] );
                $this->fld_user = isset( $prop['user'] );
+               $this->fld_userid = isset( $prop['userid'] );
                $this->fld_flags = isset( $prop['flags'] );
                $this->fld_timestamp = isset( $prop['timestamp'] );
                $this->fld_title = isset( $prop['title'] );
@@ -208,7 +209,7 @@
                        $this->addFieldsIf( 'rc_last_oldid', $this->fld_ids );
                        $this->addFieldsIf( 'rc_comment', $this->fld_comment || 
$this->fld_parsedcomment );
                        $this->addFieldsIf( 'rc_user', $this->fld_user );
-                       $this->addFieldsIf( 'rc_user_text', $this->fld_user );
+                       $this->addFieldsIf( 'rc_user_text', $this->fld_user || 
$this->fld_userid );
                        $this->addFieldsIf( 'rc_minor', $this->fld_flags );
                        $this->addFieldsIf( 'rc_bot', $this->fld_flags );
                        $this->addFieldsIf( 'rc_new', $this->fld_flags );
@@ -335,8 +336,16 @@
                }
 
                /* Add user data and 'anon' flag, if use is anonymous. */
-               if ( $this->fld_user ) {
-                       $vals['user'] = $row->rc_user_text;
+               if ( $this->fld_user || $this->fld_userid ) {
+
+                       if ( $this->fld_user ) {
+                               $vals['user'] = $row->rc_user_text;
+                       }
+
+                       if ( $this->fld_userid ) {
+                               $vals['userid'] = $row->rc_user;
+                       }
+
                        if ( !$row->rc_user ) {
                                $vals['anon'] = '';
                        }
@@ -491,6 +500,7 @@
                                ApiBase::PARAM_DFLT => 'title|timestamp|ids',
                                ApiBase::PARAM_TYPE => array(
                                        'user',
+                                       'userid',
                                        'comment',
                                        'parsedcomment',
                                        'flags',
@@ -552,6 +562,7 @@
                        'prop' => array(
                                'Include additional pieces of information',
                                ' user           - Adds the user responsible 
for the edit and tags if they are an IP',
+                               ' userid         - Adds the user id responsible 
for the edit',
                                ' comment        - Adds the comment for the 
edit',
                                ' parsedcomment  - Adds the parsed comment for 
the edit',
                                ' flags          - Adds flags for the edit',

Modified: trunk/phase3/includes/api/ApiQueryUserContributions.php
===================================================================
--- trunk/phase3/includes/api/ApiQueryUserContributions.php     2010-08-28 
00:57:58 UTC (rev 71836)
+++ trunk/phase3/includes/api/ApiQueryUserContributions.php     2010-08-28 
01:09:21 UTC (rev 71837)
@@ -43,7 +43,7 @@
        private $params;
        private $fld_ids = false, $fld_title = false, $fld_timestamp = false,
                        $fld_comment = false, $fld_parsedcomment = false, 
$fld_flags = false,
-                       $fld_patrolled = false, $fld_tags = false;
+                       $fld_patrolled = false, $fld_tags = false, $fld_size = 
false;
 
        public function execute() {
                // Parse some parameters
@@ -206,6 +206,7 @@
                        'rev_timestamp',
                        'page_namespace',
                        'page_title',
+                       'rev_user',
                        'rev_user_text',
                        'rev_deleted'
                ) );
@@ -272,6 +273,7 @@
        private function extractRowInfo( $row ) {
                $vals = array();
 
+               $vals['userid'] = $row->rev_user;
                $vals['user'] = $row->rev_user_text;
                if ( $row->rev_deleted & Revision::DELETED_USER ) {
                        $vals['userhidden'] = '';

Modified: trunk/phase3/includes/api/ApiQueryWatchlist.php
===================================================================
--- trunk/phase3/includes/api/ApiQueryWatchlist.php     2010-08-28 00:57:58 UTC 
(rev 71836)
+++ trunk/phase3/includes/api/ApiQueryWatchlist.php     2010-08-28 01:09:21 UTC 
(rev 71837)
@@ -51,7 +51,7 @@
 
        private $fld_ids = false, $fld_title = false, $fld_patrol = false, 
$fld_flags = false,
                        $fld_timestamp = false, $fld_user = false, $fld_comment 
= false, $fld_parsedcomment = false, $fld_sizes = false,
-                       $fld_notificationtimestamp = false;
+                       $fld_notificationtimestamp = false, $fld_userid = false;
 
        private function run( $resultPageSet = null ) {
                $this->selectNamedDB( 'watchlist', DB_SLAVE, 'watchlist' );
@@ -67,6 +67,7 @@
                        $this->fld_title = isset( $prop['title'] );
                        $this->fld_flags = isset( $prop['flags'] );
                        $this->fld_user = isset( $prop['user'] );
+                       $this->fld_userid = isset( $prop['userid'] );
                        $this->fld_comment = isset( $prop['comment'] );
                        $this->fld_parsedcomment = isset ( 
$prop['parsedcomment'] );
                        $this->fld_timestamp = isset( $prop['timestamp'] );
@@ -96,7 +97,7 @@
                        $this->addFieldsIf( 'rc_new', $this->fld_flags );
                        $this->addFieldsIf( 'rc_minor', $this->fld_flags );
                        $this->addFieldsIf( 'rc_bot', $this->fld_flags );
-                       $this->addFieldsIf( 'rc_user', $this->fld_user );
+                       $this->addFieldsIf( 'rc_user', $this->fld_user || 
$this->fld_userid );
                        $this->addFieldsIf( 'rc_user_text', $this->fld_user );
                        $this->addFieldsIf( 'rc_comment', $this->fld_comment || 
$this->fld_parsedcomment );
                        $this->addFieldsIf( 'rc_patrolled', $this->fld_patrol );
@@ -228,8 +229,16 @@
                        ApiQueryBase::addTitleInfo( $vals, $title );
                }
 
-               if ( $this->fld_user ) {
-                       $vals['user'] = $row->rc_user_text;
+               if ( $this->fld_user || $this->fld_userid ) {
+
+                       if ( $this->fld_user ) {
+                               $vals['user'] = $row->rc_user_text;
+                       }
+
+                       if ( $this->fld_userid ) {
+                               $vals['user'] = $row->rc_user;  
+                       }
+
                        if ( !$row->rc_user ) {
                                $vals['anon'] = '';
                        }
@@ -319,6 +328,7 @@
                                        'title',
                                        'flags',
                                        'user',
+                                       'userid',
                                        'comment',
                                        'parsedcomment',
                                        'timestamp',
@@ -364,7 +374,8 @@
                                ' ids                    - Adds revision ids 
and page ids',
                                ' title                  - Adds title of the 
page',
                                ' flags                  - Adds flags for the 
edit',
-                               ' user                   - Adds user who made 
the edit',
+                               ' user                   - Adds the user who 
made the edit',
+                               ' userid                 - Adds user id of whom 
made the edit',
                                ' comment                - Adds comment of the 
edit',
                                ' parsedcomment          - Adds parsed comment 
of the edit',
                                ' timestamp              - Adds timestamp of 
the edit',



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to