X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryUserInfo.php;h=28dea3b9e428aaf8429e558f965e47a52e4ceccf;hb=2c306b5fdf66ec223afd1f3b984e3693942e33fe;hp=ba7280da105c0be0c589664dfe644e3194801619;hpb=6b2f7b1eb04503f0e69e3eef240321d41d87fac6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index ba7280da10..28dea3b9e4 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -34,7 +34,9 @@ class ApiQueryUserInfo extends ApiQueryBase { const WL_UNREAD_LIMIT = 1000; + /** @var array */ private $params = []; + /** @var array */ private $prop = []; public function __construct( ApiQuery $query, $moduleName ) { @@ -159,8 +161,7 @@ class ApiQueryUserInfo extends ApiQueryBase { } 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 } @@ -180,7 +181,7 @@ class ApiQueryUserInfo extends ApiQueryBase { if ( isset( $this->prop['preferencestoken'] ) && !$this->lacksSameOriginSecurity() && - $user->isAllowed( 'editmyoptions' ) + $this->getPermissionManager()->userHasRight( $user, 'editmyoptions' ) ) { $vals['preferencestoken'] = $user->getEditToken( '', $this->getMain()->getRequest() ); } @@ -201,7 +202,8 @@ class ApiQueryUserInfo extends ApiQueryBase { $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 ) { @@ -301,32 +303,17 @@ class ApiQueryUserInfo extends ApiQueryBase { * @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; }