Merge "Revert "ApiSandbox: Display params as JSON on request page""
[lhc/web/wiklou.git] / includes / api / ApiQueryUserInfo.php
index 0fc443a..7bc00cb 100644 (file)
@@ -24,6 +24,8 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Query module to get information about the currently logged-in user
  *
@@ -62,18 +64,19 @@ class ApiQueryUserInfo extends ApiQueryBase {
         *  - blockreason - reason provided for the block
         *  - blockedtimestamp - timestamp for when the block was placed/modified
         *  - blockexpiry - expiry time of the block
+        *  - systemblocktype - system block type, if any
         */
        public static function getBlockInfo( Block $block ) {
-               global $wgContLang;
                $vals = [];
                $vals['blockid'] = $block->getId();
                $vals['blockedby'] = $block->getByName();
                $vals['blockedbyid'] = $block->getBy();
                $vals['blockreason'] = $block->mReason;
                $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->mTimestamp );
-               $vals['blockexpiry'] = $wgContLang->formatExpiry(
-                       $block->getExpiry(), TS_ISO_8601, 'infinite'
-               );
+               $vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
+               if ( $block->getSystemBlockType() !== null ) {
+                       $vals['systemblocktype'] = $block->getSystemBlockType();
+               }
                return $vals;
        }
 
@@ -168,8 +171,13 @@ class ApiQueryUserInfo extends ApiQueryBase {
 
                if ( isset( $this->prop['preferencestoken'] ) ) {
                        $p = $this->getModulePrefix();
-                       $this->setWarning(
-                               "{$p}prop=preferencestoken has been deprecated. Please use action=query&meta=tokens instead."
+                       $this->addDeprecation(
+                               [
+                                       'apiwarn-deprecation-withreplacement',
+                                       "{$p}prop=preferencestoken",
+                                       'action=query&meta=tokens',
+                               ],
+                               "meta=userinfo&{$p}prop=preferencestoken"
                        );
                }
                if ( isset( $this->prop['preferencestoken'] ) &&
@@ -225,7 +233,8 @@ class ApiQueryUserInfo extends ApiQueryBase {
                }
 
                if ( isset( $this->prop['unreadcount'] ) ) {
-                       $unreadNotifications = WatchedItemStore::getDefaultInstance()->countUnreadNotifications(
+                       $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+                       $unreadNotifications = $store->countUnreadNotifications(
                                $user,
                                self::WL_UNREAD_LIMIT
                        );