Make list=logevents display log entries by anonymous users
authorAlex Monk <krenair@gmail.com>
Sat, 29 Jun 2013 19:18:38 +0000 (20:18 +0100)
committerAlex Monk <krenair@gmail.com>
Sat, 29 Jun 2013 19:51:56 +0000 (20:51 +0100)
Also fix warnings being shown and "anon" property being given to non-anon entries
when "userid" leprop was used but no "user".

Bug: 50315
Change-Id: I4df1c8c1040fb39d75ead5851d42b02d9de87a5a

RELEASE-NOTES-1.22
includes/api/ApiQueryLogEvents.php

index ca653ef..8074db7 100644 (file)
@@ -156,6 +156,7 @@ production.
   requested.
 * Special:Recentchangeslinked will now include upload log entries
 * (bug 41281) Fixed ugly output if file size could not be extracted for multi-page media.
+* (bug 50315) list=logevents API module will now output log entries by anonymous users.
 
 === API changes in 1.22 ===
 * (bug 25553) The JSON output formatter now leaves forward slashes unescaped
index 2aa5c28..96d02da 100644 (file)
@@ -67,7 +67,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                $this->addTables( array( 'logging', 'user', 'page' ) );
                $this->addOption( 'STRAIGHT_JOIN' );
                $this->addJoinConds( array(
-                       'user' => array( 'JOIN',
+                       'user' => array( 'LEFT JOIN',
                                'user_id=log_user' ),
                        'page' => array( 'LEFT JOIN',
                                array( 'log_namespace=page_namespace',
@@ -82,8 +82,8 @@ class ApiQueryLogEvents extends ApiQueryBase {
                ) );
 
                $this->addFieldsIf( array( 'log_id', 'page_id' ), $this->fld_ids );
-               $this->addFieldsIf( array( 'log_user', 'user_name' ), $this->fld_user );
-               $this->addFieldsIf( 'user_id', $this->fld_userid );
+               $this->addFieldsIf( array( 'log_user', 'log_user_text', 'user_name' ), $this->fld_user );
+               $this->addFieldsIf( 'log_user', $this->fld_userid );
                $this->addFieldsIf( array( 'log_namespace', 'log_title' ), $this->fld_title || $this->fld_parsedcomment );
                $this->addFieldsIf( 'log_comment', $this->fld_comment || $this->fld_parsedcomment );
                $this->addFieldsIf( 'log_params', $this->fld_details );
@@ -336,10 +336,10 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                $vals['userhidden'] = '';
                        } else {
                                if ( $this->fld_user ) {
-                                       $vals['user'] = $row->user_name;
+                                       $vals['user'] = $row->user_name === null ? $row->log_user_text : $row->user_name;
                                }
                                if ( $this->fld_userid ) {
-                                       $vals['userid'] = $row->user_id;
+                                       $vals['userid'] = $row->log_user;
                                }
 
                                if ( !$row->log_user ) {