API: Add timestamp of block to blockinfo
authorDerk-Jan Hartman <hartman.wiki@gmail.com>
Mon, 31 Mar 2014 21:17:20 +0000 (23:17 +0200)
committerBrian Wolff <bawolff+wn@gmail.com>
Sun, 14 Sep 2014 23:02:04 +0000 (20:02 -0300)
This change affects list=allusers, list=users
and meta=userinfo.

Note: This change also add block expiry to meta=userinfo.
Unlike this field in other modules, it formats the timestamp
properly, instead of just dumping db contents.

Resurrecting from abandoned change Ifdeac5c5f547

Bug: 63326
Change-Id: I4b3e55fe2d07271e1ded89d36d0b98de0e643177

RELEASE-NOTES-1.24
includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryUserInfo.php
includes/api/ApiQueryUsers.php

index 33fe0d0..fb19dd4 100644 (file)
@@ -256,6 +256,8 @@ production.
 * New action ClearHasMsg that can be used to clear HasMsg flag.
 * The cmstartsortkey and cmendsortkey parameters to list=categorymembers are
   deprecated in favor of cmstarthexsortkey and cmendhexsortkey.
+* (bug 63326) Add blockedtimestamp field to output of blockinfo property for
+  the list=allusers and list=users modules.
 
 === Action API internal changes in 1.24 ===
 * Methods for handling continuation are added to ApiResult, so actions other
index 311921a..d241311 100644 (file)
@@ -239,6 +239,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                                        $lastUserData['blockid'] = $row->ipb_id;
                                        $lastUserData['blockedby'] = $row->ipb_by_text;
                                        $lastUserData['blockedbyid'] = $row->ipb_by;
+                                       $lastUserData['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $row->ipb_timestamp );
                                        $lastUserData['blockreason'] = $row->ipb_reason;
                                        $lastUserData['blockexpiry'] = $row->ipb_expiry;
                                }
index 6b08fc5..65e10ab 100644 (file)
@@ -414,7 +414,7 @@ abstract class ApiQueryBase extends ApiBase {
                $this->addFields( 'ipb_deleted' );
 
                if ( $showBlockInfo ) {
-                       $this->addFields( array( 'ipb_id', 'ipb_by', 'ipb_by_text', 'ipb_reason', 'ipb_expiry' ) );
+                       $this->addFields( array( 'ipb_id', 'ipb_by', 'ipb_by_text', 'ipb_reason', 'ipb_expiry', 'ipb_timestamp' ) );
                }
 
                // Don't show hidden names
index 8b7831c..fd5f47b 100644 (file)
@@ -69,6 +69,10 @@ class ApiQueryUserInfo extends ApiQueryBase {
                                $vals['blockedby'] = $block->getByName();
                                $vals['blockedbyid'] = $block->getBy();
                                $vals['blockreason'] = $user->blockedFor();
+                               $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->mTimestamp );
+                               $vals['blockexpiry'] = $block->getExpiry() === 'infinity'
+                                       ? 'infinite'
+                                       : wfTimestamp( TS_ISO_8601, $block->getExpiry() );
                        }
                }
 
index b62d6a8..2f5e4b4 100644 (file)
@@ -195,6 +195,7 @@ class ApiQueryUsers extends ApiQueryBase {
                                        $data[$name]['blockid'] = $row->ipb_id;
                                        $data[$name]['blockedby'] = $row->ipb_by_text;
                                        $data[$name]['blockedbyid'] = $row->ipb_by;
+                                       $data[$name]['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $row->ipb_timestamp );
                                        $data[$name]['blockreason'] = $row->ipb_reason;
                                        $data[$name]['blockexpiry'] = $row->ipb_expiry;
                                }