const WL_UNREAD_LIMIT = 1000;
+ /** @var array */
private $params = [];
+ /** @var array */
private $prop = [];
public function __construct( ApiQuery $query, $moduleName ) {
}
if ( isset( $this->prop['rights'] ) ) {
- // User::getRights() may return duplicate values, strip them
- $vals['rights'] = array_values( array_unique( $user->getRights() ) );
+ $vals['rights'] = $this->getPermissionManager()->getUserPermissions( $user );
ApiResult::setArrayType( $vals['rights'], 'array' ); // even if empty
ApiResult::setIndexedTagName( $vals['rights'], 'r' ); // even if empty
}
if ( isset( $this->prop['preferencestoken'] ) &&
!$this->lacksSameOriginSecurity() &&
- $user->isAllowed( 'editmyoptions' )
+ $this->getPermissionManager()->userHasRight( $user, 'editmyoptions' )
) {
$vals['preferencestoken'] = $user->getEditToken( '', $this->getMain()->getRequest() );
}
$vals['realname'] = $user->getRealName();
}
- if ( $user->isAllowed( 'viewmyprivateinfo' ) && isset( $this->prop['email'] ) ) {
+ if ( $this->getPermissionManager()->userHasRight( $user, 'viewmyprivateinfo' ) &&
+ isset( $this->prop['email'] ) ) {
$vals['email'] = $user->getEmail();
$auth = $user->getEmailAuthenticationTimestamp();
if ( $auth !== null ) {
* @return string|null ISO 8601 timestamp of current user's last contribution or null if none
*/
protected function getLatestContributionTime() {
- global $wgActorTableSchemaMigrationStage;
-
$user = $this->getUser();
$dbr = $this->getDB();
- if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
- if ( $user->getActorId() === null ) {
- return null;
- }
- $res = $dbr->selectField( 'revision_actor_temp',
- 'MAX(revactor_timestamp)',
- [ 'revactor_actor' => $user->getActorId() ],
- __METHOD__
- );
- } else {
- if ( $user->isLoggedIn() ) {
- $conds = [ 'rev_user' => $user->getId() ];
- } else {
- $conds = [ 'rev_user_text' => $user->getName() ];
- }
- $res = $dbr->selectField( 'revision',
- 'MAX(rev_timestamp)',
- $conds,
- __METHOD__
- );
+ if ( $user->getActorId() === null ) {
+ return null;
}
+ $res = $dbr->selectField( 'revision_actor_temp',
+ 'MAX(revactor_timestamp)',
+ [ 'revactor_actor' => $user->getActorId() ],
+ __METHOD__
+ );
return $res ? wfTimestamp( TS_ISO_8601, $res ) : null;
}