Skip to content

Commit

Permalink
Merge "Replace use of deprecated ChangeTags::getTags(), defineTag(), …
Browse files Browse the repository at this point in the history
…and listExplicitlyDefinedTags()"
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Oct 16, 2024
2 parents ec57a14 + c05a8a6 commit f2ca64c
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/includes/Store/EntityStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function assignFreshId( EntityDocument $entity );
* $baseRevId is no longer the current revision.
* @param string[] $tags Change tags to add to the edit.
* Callers are responsible for permission checks
* (typically using {@link ChangeTags::canAddTagsAccompanyingChange}).
* (typically using {@link ChangeTagsStore::canAddTagsAccompanyingChange}).
*
* @see WikiPage::doEditContent
*
Expand All @@ -78,7 +78,7 @@ public function saveEntity( EntityDocument $entity, $summary, User $user, $flags
* $baseRevId is no longer the current revision.
* @param string[] $tags Change tags to add to the edit.
* Callers are responsible for permission checks
* (typically using {@link ChangeTags::canAddTagsAccompanyingChange}).
* (typically using {@link ChangeTagsStore::canAddTagsAccompanyingChange}).
*
* @see WikiPage::doEditContent
*
Expand Down
2 changes: 1 addition & 1 deletion repo/includes/EditEntity/EditEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function isTokenOK( $token );
* Set to null to apply default according to getWatchDefault().
* @param string[] $tags Change tags to add to the edit.
* Callers are responsible for checking that the user is permitted to add these tags
* (typically using {@link ChangeTags::canAddTagsAccompanyingChange}).
* (typically using {@link ChangeTagsStore::canAddTagsAccompanyingChange}).
*
* @return EditEntityStatus
*
Expand Down
2 changes: 1 addition & 1 deletion repo/includes/Interactors/ItemMergeInteractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private function checkPermissions( EntityId $entityId, User $user ): void {
* @param bool $bot Mark the edit as bot edit
* @param string[] $tags Change tags to add to the edit.
* Callers are responsible for permission checks
* (typically using {@link ChangeTags::canAddTagsAccompanyingChange}).
* (typically using {@link ChangeTagsStore::canAddTagsAccompanyingChange}).
*
* @return ItemMergeStatus Note that the status is only returned
* to wrap the created revisions, context and saved temp user in a strongly typed container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EditMetadataValidator {

/**
* @param int $maxCommentLength
* @param string[] $allowedTags {@see \ChangeTags::listExplicitlyDefinedTags}
* @param string[] $allowedTags {@see ChangeTagsStore::listExplicitlyDefinedTags}
*/
public function __construct( int $maxCommentLength, array $allowedTags ) {
$this->maxCommentLength = $maxCommentLength;
Expand Down
17 changes: 9 additions & 8 deletions repo/rest-api/src/WbRestApi.ServiceWiring.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,15 @@ function ( MediaWikiServices $services ): StatementSerializationRequestValidatin
);
},

VRD::EDIT_METADATA_REQUEST_VALIDATING_DESERIALIZER => function (): EditMetadataRequestValidatingDeserializer {
return new EditMetadataRequestValidatingDeserializer(
new EditMetadataValidator(
CommentStore::COMMENT_CHARACTER_LIMIT,
ChangeTags::listExplicitlyDefinedTags()
)
);
},
VRD::EDIT_METADATA_REQUEST_VALIDATING_DESERIALIZER =>
function ( MediaWikiServices $services ): EditMetadataRequestValidatingDeserializer {
return new EditMetadataRequestValidatingDeserializer(
new EditMetadataValidator(
CommentStore::COMMENT_CHARACTER_LIMIT,
$services->getChangeTagsStore()->listExplicitlyDefinedTags()
)
);
},

VRD::PATCH_REQUEST_VALIDATING_DESERIALIZER => function (): PatchRequestValidatingDeserializer {
return new PatchRequestValidatingDeserializer( new JsonDiffJsonPatchValidator() );
Expand Down
3 changes: 1 addition & 2 deletions repo/tests/phpunit/includes/Api/MergeItemsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use ApiMain;
use ApiUsageException;
use ChangeTags;
use MediaWiki\Context\RequestContext;
use MediaWiki\Languages\LanguageNameUtils;
use MediaWiki\Request\FauxRequest;
Expand Down Expand Up @@ -327,7 +326,7 @@ public function testMergeRequest(
): void {
// -- set up params ---------------------------------
$tag = __METHOD__ . '-tag';
ChangeTags::defineTag( $tag );
$this->getServiceContainer()->getChangeTagsStore()->defineTag( $tag );
$params = [
'action' => 'wbmergeitems',
'fromid' => 'Q1',
Expand Down
7 changes: 4 additions & 3 deletions repo/tests/phpunit/includes/Api/WikibaseApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Wikibase\Repo\Tests\Api;

use ApiUsageException;
use ChangeTags;
use DataValues\StringValue;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\MediaWikiServices;
Expand Down Expand Up @@ -450,7 +449,9 @@ protected function assertCanTagSuccessfulRequest(
$tokenType = 'csrf'
) {
$dummyTag = __METHOD__ . '-dummy-tag';
ChangeTags::defineTag( $dummyTag );
$changeTagsStore = $this->getServiceContainer()->getChangeTagsStore();

$changeTagsStore->defineTag( $dummyTag );

$params[ 'tags' ] = $dummyTag;

Expand All @@ -467,7 +468,7 @@ protected function assertCanTagSuccessfulRequest(
}

$this->assertContains( $dummyTag,
ChangeTags::getTags( $this->db, null, $lastRevid ) );
$changeTagsStore->getTags( $this->db, null, $lastRevid ) );
}

private function getLastRevIdFromResult( array $result ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Wikibase\Repo\Tests\Specials;

use ChangeTags;
use MediaWiki\Block\AbstractBlock;
use MediaWiki\CommentStore\CommentStoreComment;
use MediaWiki\Context\RequestContext;
Expand Down Expand Up @@ -54,7 +53,7 @@ public function testEntityIsBeingCreated_WhenValidInputIsGiven( array $formData

$entityId = $this->extractEntityIdFromUrl( $webResponse->getHeader( 'location' ) );
$title = WikibaseRepo::getEntityTitleStoreLookup()->getTitleForId( $entityId );
$tags = ChangeTags::getTags( $this->db, null, $title->getLatestRevID() );
$tags = $this->getServiceContainer()->getChangeTagsStore()->getTags( $this->db, null, $title->getLatestRevID() );
$this->assertArrayEquals( self::TAGS, $tags );

$entity = WikibaseRepo::getEntityLookup()->getEntity( $entityId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Wikibase\Repo\Tests\Specials;

use ChangeTags;
use Hamcrest\Matcher;
use HamcrestPHPUnitIntegration;
use MediaWiki\MediaWikiServices;
Expand Down Expand Up @@ -292,7 +291,7 @@ public function testExecutePostModifySiteLink() {
);

$title = WikibaseRepo::getEntityTitleStoreLookup()->getTitleForId( $item->getId() );
$tags = ChangeTags::getTags( $this->getDb(), null, $title->getLatestRevID() );
$tags = $this->getServiceContainer()->getChangeTagsStore()->getTags( $this->getDb(), null, $title->getLatestRevID() );
$this->assertArrayEquals( self::TAGS, $tags );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Wikibase\Repo\Tests\Store\Sql;

use ChangeTags;
use Exception;
use InvalidArgumentException;
use MediaWiki\Language\RawMessage;
Expand Down Expand Up @@ -223,7 +222,7 @@ public function testSaveEntity( EntityDocument $entity, EntityDocument $empty )
$this->assertEquals( $r2->getEntity()->getId(), $r2actual->getEntity()->getId(), 'entity id' );

// check that the tags were applied
$r2tags = ChangeTags::getTags( $this->getDb(), null, $r2->getRevisionId() );
$r2tags = $this->getServiceContainer()->getChangeTagsStore()->getTags( $this->getDb(), null, $r2->getRevisionId() );
$this->assertContains( 'mw-replace', $r2tags );

// check that the term storage got updated (via a DataUpdate).
Expand Down Expand Up @@ -414,7 +413,7 @@ public function testSaveRedirect() {
$this->assertRedirectPerPage( $q33, $oneId );

// check that the tags were applied
$redirectRevTags = ChangeTags::getTags( $this->getDb(), null, $redirectRevId );
$redirectRevTags = $this->getServiceContainer()->getChangeTagsStore()->getTags( $this->getDb(), null, $redirectRevId );
$this->assertContains( 'mw-replace', $redirectRevTags );

// check that the term storage got updated (via a DataUpdate).
Expand Down

0 comments on commit f2ca64c

Please sign in to comment.