namespace.
* action=expandtemplates has a new parameter, prop, and a new output format.
The old format is still used if prop isn't provided, but this is deprecated.
+* meta=userinfo can now return the count of unread pages on the watchlist.
=== Languages updated in 1.24 ===
*/
class ApiQueryUserInfo extends ApiQueryBase {
+ const WL_UNREAD_LIMIT = 1000;
+
private $prop = array();
public function __construct( ApiQuery $query, $moduleName ) {
}
protected function getCurrentUserInfo() {
- global $wgHiddenPrefs;
+ global $wgHiddenPrefs, $wgRCMaxAge;
$user = $this->getUser();
$result = $this->getResult();
$vals = array();
$vals['acceptlang'] = $acceptLang;
}
+ if ( isset( $this->prop['unreadcount'] ) ) {
+ $dbr = $this->getQuery()->getNamedDB( 'watchlist', DB_SLAVE, 'watchlist' );
+
+ $sql = $dbr->selectSQLText(
+ 'watchlist',
+ array( 'dummy' => 1 ),
+ array(
+ 'wl_user' => $user->getId(),
+ 'wl_notificationtimestamp IS NOT NULL',
+ ),
+ __METHOD__,
+ array( 'LIMIT' => self::WL_UNREAD_LIMIT )
+ );
+ $count = $dbr->selectField( array( 'c' => "($sql)" ), 'COUNT(*)' );
+
+ if ( $count >= self::WL_UNREAD_LIMIT ) {
+ $vals['unreadcount'] = self::WL_UNREAD_LIMIT . '+';
+ } else {
+ $vals['unreadcount'] = (int)$count;
+ }
+ }
+
return $vals;
}
'email',
'realname',
'acceptlang',
- 'registrationdate'
+ 'registrationdate',
+ 'unreadcount',
)
)
);
' acceptlang - Echoes the Accept-Language header sent by ' .
'the client in a structured format',
' registrationdate - Adds the user\'s registration date',
+ ' unreadcount - Adds the count of unread pages on the user\'s watchlist ' .
+ '(maximum ' . ( self::WL_UNREAD_LIMIT - 1 ) . '; returns "' .
+ self::WL_UNREAD_LIMIT . '+" if more)',
)
);
}