Rename Authority::getActor to Authority::getPerformer
Bug: T274947 Change-Id: I8f652816af00bf9fa413ba4b1fa7ac4c27290dc2
This commit is contained in:
parent
dba477cf4a
commit
375e9f0a68
15 changed files with 23 additions and 23 deletions
|
|
@ -30,14 +30,14 @@ use MediaWiki\User\UserIdentity;
|
|||
interface Authority {
|
||||
|
||||
/**
|
||||
* Returns the actor associated with this authority.
|
||||
* Returns the performer of the actions associated with this authority.
|
||||
*
|
||||
* Actions performed under this authority should generally be attributed
|
||||
* to the actor returned by this method.
|
||||
* to the user identity returned by this method.
|
||||
*
|
||||
* @return UserIdentity
|
||||
*/
|
||||
public function getActor(): UserIdentity;
|
||||
public function getPerformer(): UserIdentity;
|
||||
|
||||
/**
|
||||
* Checks whether this authority has the given permission in general.
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class SimpleAuthority implements Authority {
|
|||
*
|
||||
* @return UserIdentity
|
||||
*/
|
||||
public function getActor(): UserIdentity {
|
||||
public function getPerformer(): UserIdentity {
|
||||
return $this->actor;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class UltimateAuthority implements Authority {
|
|||
*
|
||||
* @return UserIdentity
|
||||
*/
|
||||
public function getActor(): UserIdentity {
|
||||
public function getPerformer(): UserIdentity {
|
||||
return $this->actor;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class UserAuthority implements Authority {
|
|||
*
|
||||
* @return UserIdentity
|
||||
*/
|
||||
public function getActor(): UserIdentity {
|
||||
public function getPerformer(): UserIdentity {
|
||||
return $this->actor;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ abstract class AbstractContributionHandler extends Handler {
|
|||
*/
|
||||
protected function getTargetUser() {
|
||||
if ( $this->me ) {
|
||||
$user = $this->getAuthority()->getActor();
|
||||
$user = $this->getAuthority()->getPerformer();
|
||||
if ( !$user->isRegistered() ) {
|
||||
throw new LocalizedHttpException(
|
||||
new MessageValue( 'rest-permission-denied-anon' ), 401
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class MediaFileHandler extends SimpleHandler {
|
|||
if ( $this->file === null ) {
|
||||
$title = $this->getTitle();
|
||||
// TODO: make RepoGroup::findFile take Authority
|
||||
$user = User::newFromIdentity( $this->getAuthority()->getActor() );
|
||||
$user = User::newFromIdentity( $this->getAuthority()->getPerformer() );
|
||||
$this->file =
|
||||
$this->repoGroup->findFile( $title, [ 'private' => $user ] ) ?? false;
|
||||
}
|
||||
|
|
@ -112,10 +112,10 @@ class MediaFileHandler extends SimpleHandler {
|
|||
*/
|
||||
private function getResponse( File $file ) : array {
|
||||
list( $maxWidth, $maxHeight ) = self::getImageLimitsFromOption(
|
||||
$this->getAuthority()->getActor(), 'imagesize'
|
||||
$this->getAuthority()->getPerformer(), 'imagesize'
|
||||
);
|
||||
list( $maxThumbWidth, $maxThumbHeight ) = self::getImageLimitsFromOption(
|
||||
$this->getAuthority()->getActor(), 'thumbsize'
|
||||
$this->getAuthority()->getPerformer(), 'thumbsize'
|
||||
);
|
||||
$transforms = [
|
||||
'preferred' => [
|
||||
|
|
@ -129,7 +129,7 @@ class MediaFileHandler extends SimpleHandler {
|
|||
];
|
||||
|
||||
// TODO: make MediaFileTrait::getFileInfo take Authority
|
||||
$user = User::newFromIdentity( $this->getAuthority()->getActor() );
|
||||
$user = User::newFromIdentity( $this->getAuthority()->getPerformer() );
|
||||
return $this->getFileInfo( $file, $user, $transforms );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class MediaLinksHandler extends SimpleHandler {
|
|||
// Using "private" here means an equivalent of the Action API's "anon-public-user-private"
|
||||
// caching model would be necessary, if caching is ever added to this endpoint.
|
||||
// TODO: make RepoGroup::findFiles take Authority
|
||||
$user = User::newFromIdentity( $this->getAuthority()->getActor() );
|
||||
$user = User::newFromIdentity( $this->getAuthority()->getPerformer() );
|
||||
$findTitles = array_map( static function ( $title ) use ( $user ) {
|
||||
return [
|
||||
'title' => $title,
|
||||
|
|
@ -126,7 +126,7 @@ class MediaLinksHandler extends SimpleHandler {
|
|||
|
||||
$files = $this->repoGroup->findFiles( $findTitles );
|
||||
list( $maxWidth, $maxHeight ) = self::getImageLimitsFromOption(
|
||||
$this->getAuthority()->getActor(),
|
||||
$this->getAuthority()->getPerformer(),
|
||||
'imagesize'
|
||||
);
|
||||
$transforms = [
|
||||
|
|
|
|||
|
|
@ -4504,7 +4504,7 @@ class User implements Authority, IDBAccessObject, UserIdentity {
|
|||
* @unstable this is a part of the Authority experiment and should not be used yet.
|
||||
* @return UserIdentity
|
||||
*/
|
||||
public function getActor(): UserIdentity {
|
||||
public function getPerformer(): UserIdentity {
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ class UserFactory implements IDBAccessObject, UserRigorOptions {
|
|||
if ( $authority instanceof User ) {
|
||||
return $authority;
|
||||
}
|
||||
return $this->newFromUserIdentity( $authority->getActor() );
|
||||
return $this->newFromUserIdentity( $authority->getPerformer() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class RequestContextTest extends MediaWikiIntegrationTestCase {
|
|||
$user = $this->getTestUser()->getUser();
|
||||
|
||||
$context->setUser( $user );
|
||||
$this->assertTrue( $user->equals( $context->getAuthority()->getActor() ) );
|
||||
$this->assertTrue( $user->equals( $context->getAuthority()->getPerformer() ) );
|
||||
$this->assertTrue( $user->equals( $context->getUser() ) );
|
||||
|
||||
$authorityActor = new UserIdentityValue( 42, 'Test', 24 );
|
||||
|
|
@ -137,6 +137,6 @@ class RequestContextTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$context->setAuthority( $authority );
|
||||
$this->assertTrue( $context->getUser()->equals( $authorityActor ) );
|
||||
$this->assertTrue( $context->getAuthority()->getActor()->equals( $authorityActor ) );
|
||||
$this->assertTrue( $context->getAuthority()->getPerformer()->equals( $authorityActor ) );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ trait MockAuthorityTrait {
|
|||
*/
|
||||
private function mockAuthority( UserIdentity $performer, callable $permissionCallback ): Authority {
|
||||
$mock = $this->createMock( Authority::class );
|
||||
$mock->method( 'getActor' )->willReturn( $performer );
|
||||
$mock->method( 'getPerformer' )->willReturn( $performer );
|
||||
$methods = [ 'isAllowed', 'probablyCan', 'definitelyCan', 'authorizeRead', 'authorizeWrite' ];
|
||||
foreach ( $methods as $method ) {
|
||||
$mock->method( $method )->willReturnCallback( $permissionCallback );
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class SimpleAuthorityTest extends MediaWikiUnitTestCase {
|
|||
$actor = new UserIdentityValue( 12, 'Test', 17 );
|
||||
$authority = new SimpleAuthority( $actor, [] );
|
||||
|
||||
$this->assertSame( $actor, $authority->getActor() );
|
||||
$this->assertSame( $actor, $authority->getPerformer() );
|
||||
}
|
||||
|
||||
public function testPermissions() {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class UltimateAuthorityTest extends MediaWikiUnitTestCase {
|
|||
$actor = new UserIdentityValue( 12, 'Test', 17 );
|
||||
$authority = new UltimateAuthority( $actor );
|
||||
|
||||
$this->assertSame( $actor, $authority->getActor() );
|
||||
$this->assertSame( $actor, $authority->getPerformer() );
|
||||
}
|
||||
|
||||
public function testPermissions() {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class UserAuthorityTest extends MediaWikiUnitTestCase {
|
|||
$actor = $this->newUser();
|
||||
$authority = $this->newAuthority( $actor, [] );
|
||||
|
||||
$this->assertSame( $actor, $authority->getActor() );
|
||||
$this->assertSame( $actor, $authority->getPerformer() );
|
||||
}
|
||||
|
||||
public function testPermissions() {
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class UserContributionsHandlerTest extends \MediaWikiUnitTestCase {
|
|||
$this->assertSame( $target->getName(), $actualTarget->getName() );
|
||||
$this->assertSame( $limit, $actualLimit );
|
||||
$this->assertTrue(
|
||||
$performer->getActor()->equals( $actualPerformer->getActor() )
|
||||
$performer->getPerformer()->equals( $actualPerformer->getPerformer() )
|
||||
);
|
||||
$this->assertSame( $segment, $actualSegment );
|
||||
$this->assertSame( $tag, $actualTag );
|
||||
|
|
@ -170,7 +170,7 @@ class UserContributionsHandlerTest extends \MediaWikiUnitTestCase {
|
|||
public function testThatParametersAreHandledCorrectlyForMeEndpoint( $queryParams ) {
|
||||
$request = new RequestData( [ 'queryParams' => $queryParams ] );
|
||||
$performer = $this->mockRegisteredUltimateAuthority();
|
||||
$performingUser = $performer->getActor();
|
||||
$performingUser = $performer->getPerformer();
|
||||
$validatedParams = [
|
||||
'user' => null,
|
||||
'limit' => $queryParams['limit'] ?? self::DEFAULT_LIMIT,
|
||||
|
|
|
|||
Loading…
Reference in a new issue