From d87164e91ad5794b4b0fd7982c62b6b85f0d5ec3 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Mon, 31 Mar 2014 23:17:20 +0200 Subject: [PATCH] API: Add timestamp of block to blockinfo 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 | 2 ++ includes/api/ApiQueryAllUsers.php | 1 + includes/api/ApiQueryBase.php | 2 +- includes/api/ApiQueryUserInfo.php | 4 ++++ includes/api/ApiQueryUsers.php | 1 + 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index 33fe0d0091..fb19dd4432 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -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 diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 311921a1f8..d2413112ab 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -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; } diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 6b08fc5c87..65e10ab729 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -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 diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index 8b7831cb8e..fd5f47b4fe 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -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() ); } } diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index b62d6a83e0..2f5e4b4bf8 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -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; } -- 2.20.1