const WL_UNREAD_LIMIT = 1000;
- private $params = array();
- private $prop = array();
+ private $params = [];
+ private $prop = [];
public function __construct( ApiQuery $query, $moduleName ) {
parent::__construct( $query, $moduleName, 'ui' );
*/
public static function getBlockInfo( Block $block ) {
global $wgContLang;
- $vals = array();
+ $vals = [];
$vals['blockid'] = $block->getId();
$vals['blockedby'] = $block->getByName();
$vals['blockedbyid'] = $block->getBy();
public static function getCentralUserInfo( Config $config, User $user, $attachedWiki = null ) {
$providerIds = array_keys( $config->get( 'CentralIdLookupProviders' ) );
- $ret = array(
- 'centralids' => array(),
- 'attachedlocal' => array(),
- );
+ $ret = [
+ 'centralids' => [],
+ 'attachedlocal' => [],
+ ];
ApiResult::setArrayType( $ret['centralids'], 'assoc' );
ApiResult::setArrayType( $ret['attachedlocal'], 'assoc' );
if ( $attachedWiki ) {
- $ret['attachedwiki'] = array();
+ $ret['attachedwiki'] = [];
ApiResult::setArrayType( $ret['attachedwiki'], 'assoc' );
}
protected function getCurrentUserInfo() {
$user = $this->getUser();
- $vals = array();
+ $vals = [];
$vals['id'] = intval( $user->getId() );
$vals['name'] = $user->getName();
if ( isset( $this->prop['acceptlang'] ) ) {
$langs = $this->getRequest()->getAcceptLang();
- $acceptLang = array();
+ $acceptLang = [];
foreach ( $langs as $lang => $val ) {
- $r = array( 'q' => $val );
+ $r = [ 'q' => $val ];
ApiResult::setContentValue( $r, 'code', $lang );
$acceptLang[] = $r;
}
}
if ( isset( $this->prop['unreadcount'] ) ) {
- $dbr = $this->getQuery()->getNamedDB( 'watchlist', DB_SLAVE, 'watchlist' );
-
- $count = $dbr->selectRowCount(
- 'watchlist',
- '1',
- array(
- 'wl_user' => $user->getId(),
- 'wl_notificationtimestamp IS NOT NULL',
- ),
- __METHOD__,
- array( 'LIMIT' => self::WL_UNREAD_LIMIT )
+ $unreadNotifications = WatchedItemStore::getDefaultInstance()->countUnreadNotifications(
+ $user,
+ self::WL_UNREAD_LIMIT
);
- if ( $count >= self::WL_UNREAD_LIMIT ) {
+ if ( $unreadNotifications === true ) {
$vals['unreadcount'] = self::WL_UNREAD_LIMIT . '+';
} else {
- $vals['unreadcount'] = $count;
+ $vals['unreadcount'] = $unreadNotifications;
}
}
}
protected function getRateLimits() {
- $retval = array(
+ $retval = [
ApiResult::META_TYPE => 'assoc',
- );
+ ];
$user = $this->getUser();
if ( !$user->isPingLimitable() ) {
}
// Find out which categories we belong to
- $categories = array();
+ $categories = [];
if ( $user->isAnon() ) {
$categories[] = 'anon';
} else {
}
public function getAllowedParams() {
- return array(
- 'prop' => array(
+ return [
+ 'prop' => [
ApiBase::PARAM_ISMULTI => true,
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'blockinfo',
'hasmsg',
'groups',
'registrationdate',
'unreadcount',
'centralids',
- ),
- ApiBase::PARAM_HELP_MSG_PER_VALUE => array(
- 'unreadcount' => array(
+ ],
+ ApiBase::PARAM_HELP_MSG_PER_VALUE => [
+ 'unreadcount' => [
'apihelp-query+userinfo-paramvalue-prop-unreadcount',
self::WL_UNREAD_LIMIT - 1,
self::WL_UNREAD_LIMIT . '+',
- ),
- ),
- ),
+ ],
+ ],
+ ],
'attachedwiki' => null,
- );
+ ];
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=query&meta=userinfo'
=> 'apihelp-query+userinfo-example-simple',
'action=query&meta=userinfo&uiprop=blockinfo|groups|rights|hasmsg'
=> 'apihelp-query+userinfo-example-data',
- );
+ ];
}
public function getHelpUrls() {