Jeroen De Dauw has submitted this change and it was merged. Change subject: Make ClaimGuidGenerator behave like a service ......................................................................
Make ClaimGuidGenerator behave like a service This makes ClaimGuidGenerator take an EntityId in the newGuid() method instead of the constructor. Change-Id: Ifd96ab78424d7b674323becb310294d00b367e73 --- M lib/includes/ClaimGuidGenerator.php M lib/tests/phpunit/ClaimGuidGeneratorTest.php M lib/tests/phpunit/serializers/EntitySerializerBaseTest.php M repo/includes/ChangeOp/ChangeOpClaim.php M repo/includes/ChangeOp/ChangeOpMainSnak.php M repo/includes/ChangeOp/ChangeOpsMerge.php M repo/includes/api/CreateClaim.php M repo/includes/api/EditEntity.php M repo/includes/api/SetClaim.php M repo/includes/api/SetClaimValue.php M repo/tests/phpunit/includes/ChangeOp/ChangeOpClaimTest.php M repo/tests/phpunit/includes/ChangeOp/ChangeOpMainSnakTest.php M repo/tests/phpunit/includes/ChangeOp/ChangeOpQualifierTest.php M repo/tests/phpunit/includes/ChangeOp/ChangeOpReferenceTest.php M repo/tests/phpunit/includes/ChangeOp/ChangeOpStatementRankTest.php M repo/tests/phpunit/includes/EntityViewTest.php M repo/tests/phpunit/includes/api/RemoveClaimsTest.php M repo/tests/phpunit/includes/api/RemoveQualifiersTest.php M repo/tests/phpunit/includes/api/RemoveReferencesTest.php M repo/tests/phpunit/includes/api/SetClaimTest.php M repo/tests/phpunit/includes/api/SetQualifierTest.php M repo/tests/phpunit/includes/content/PropertyContentTest.php 22 files changed, 73 insertions(+), 79 deletions(-) Approvals: WikidataJenkins: Verified Jeroen De Dauw: Looks good to me, approved Objections: Addshore: There's a problem with this change, please improve diff --git a/lib/includes/ClaimGuidGenerator.php b/lib/includes/ClaimGuidGenerator.php index 1231309..2656a53 100644 --- a/lib/includes/ClaimGuidGenerator.php +++ b/lib/includes/ClaimGuidGenerator.php @@ -10,8 +10,9 @@ * * @licence GNU GPL v2+ * @author Jeroen De Dauw < jeroended...@gmail.com > + * @author Daniel Kinzler */ -class ClaimGuidGenerator implements GuidGenerator { +class ClaimGuidGenerator { /** * @since 0.3 @@ -21,29 +22,22 @@ /** * @since 0.5 - * @var EntityId */ - protected $entityId; - - /** - * @param EntityId $entityId - */ - public function __construct( EntityId $entityId ) { - $this->entityId = $entityId; + public function __construct() { $this->baseGenerator = new V4GuidGenerator(); } /** - * Generates and returns a GUID. - * @see http://php.net/manual/en/function.com-create-guid.php - * @see GuidGenerator::newGuid + * Generates and returns a GUID for a claim in the given Entity. * - * @since 0.3 + * @since 0.5 + * + * @param EntityId $entityId * * @return string */ - public function newGuid() { - return $this->entityId->getSerialization() . ClaimGuid::SEPARATOR . $this->baseGenerator->newGuid(); + public function newGuid( EntityId $entityId ) { + return $entityId->getSerialization() . ClaimGuid::SEPARATOR . $this->baseGenerator->newGuid(); } } diff --git a/lib/tests/phpunit/ClaimGuidGeneratorTest.php b/lib/tests/phpunit/ClaimGuidGeneratorTest.php index 3a07a2e..3b4fad0 100644 --- a/lib/tests/phpunit/ClaimGuidGeneratorTest.php +++ b/lib/tests/phpunit/ClaimGuidGeneratorTest.php @@ -6,6 +6,7 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use Wikibase\Lib\ClaimGuidGenerator; +use Wikibase\Lib\V4GuidGenerator; /** * @covers Wikibase\Lib\ClaimGuidGenerator @@ -22,11 +23,11 @@ * @dataProvider entityIdProvider */ public function testGetGuid( EntityId $id ) { - $guidGen = new ClaimGuidGenerator( $id ); + $guidGen = new ClaimGuidGenerator(); - $this->assertIsGuidForId( $guidGen->newGuid(), $id ); - $this->assertIsGuidForId( $guidGen->newGuid(), $id ); - $this->assertIsGuidForId( $guidGen->newGuid(), $id ); + $this->assertIsGuidForId( $guidGen->newGuid( $id ), $id ); + $this->assertIsGuidForId( $guidGen->newGuid( $id ), $id ); + $this->assertIsGuidForId( $guidGen->newGuid( $id ), $id ); } public function entityIdProvider() { diff --git a/lib/tests/phpunit/serializers/EntitySerializerBaseTest.php b/lib/tests/phpunit/serializers/EntitySerializerBaseTest.php index b4221d4..c3a5342 100644 --- a/lib/tests/phpunit/serializers/EntitySerializerBaseTest.php +++ b/lib/tests/phpunit/serializers/EntitySerializerBaseTest.php @@ -143,8 +143,8 @@ ) ); - $claimGuidGenerator = new ClaimGuidGenerator( $entity2->getId() ); - $claim->setGuid( $claimGuidGenerator->newGuid() ); + $guidGenerator = new ClaimGuidGenerator(); + $claim->setGuid( $guidGenerator->newGuid( $entity2->getId() ) ); $entity2->setLabel( 'en', 'foo' ); $entity2->addClaim( $claim ); diff --git a/repo/includes/ChangeOp/ChangeOpClaim.php b/repo/includes/ChangeOp/ChangeOpClaim.php index 026b4d4..1a86a7e 100644 --- a/repo/includes/ChangeOp/ChangeOpClaim.php +++ b/repo/includes/ChangeOp/ChangeOpClaim.php @@ -81,7 +81,7 @@ public function apply( Entity $entity, Summary $summary = null ) { if( $this->claim->getGuid() === null ){ - $this->claim->setGuid( $this->guidGenerator->newGuid() ); + $this->claim->setGuid( $this->guidGenerator->newGuid( $entity->getId() ) ); } $guid = $this->guidParser->parse( $this->claim->getGuid() ); diff --git a/repo/includes/ChangeOp/ChangeOpMainSnak.php b/repo/includes/ChangeOp/ChangeOpMainSnak.php index 958cbfa..ef60baf 100644 --- a/repo/includes/ChangeOp/ChangeOpMainSnak.php +++ b/repo/includes/ChangeOp/ChangeOpMainSnak.php @@ -93,7 +93,7 @@ protected function addClaim( Entity $entity, Claims $claims, Summary $summary = null ) { //TODO: check for claim uniqueness? $claim = $entity->newClaim( $this->snak ); - $claim->setGuid( $this->guidGenerator->newGuid() ); + $claim->setGuid( $this->guidGenerator->newGuid( $entity->getId() ) ); $claims->addClaim( $claim ); $this->updateSummary( $summary, 'create', '', $this->getClaimSummaryArgs( $this->snak ) ); $this->claimGuid = $claim->getGuid(); diff --git a/repo/includes/ChangeOp/ChangeOpsMerge.php b/repo/includes/ChangeOp/ChangeOpsMerge.php index d304193..34ec24b 100644 --- a/repo/includes/ChangeOp/ChangeOpsMerge.php +++ b/repo/includes/ChangeOp/ChangeOpsMerge.php @@ -11,7 +11,7 @@ use Wikibase\DataModel\Reference; use Wikibase\LabelDescriptionDuplicateDetector; use Wikibase\Lib\ClaimGuidGenerator; -use Wikibase\SiteLinkCache; +use Wikibase\SiteLinkLookup; use Wikibase\Term; use Wikibase\Lib\ClaimGuidValidator; use Wikibase\Repo\WikibaseRepo; @@ -38,16 +38,15 @@ * @var LabelDescriptionDuplicateDetector */ private $labelDescriptionDuplicateDetector; - - /** - * @var SitelinkCache - */ - private $sitelinkCache; + + /** @var SiteLinkLookup */ + private $sitelinkLookup; /** * @var ClaimGuidValidator */ private $claimGuidValidator; + /** * @var ClaimGuidParser */ @@ -57,7 +56,7 @@ * @param Item $fromItem * @param Item $toItem * @param LabelDescriptionDuplicateDetector $labelDescriptionDuplicateDetector - * @param SitelinkCache $sitelinkCache + * @param SiteLinkLookup $sitelinkLookup * @param array $ignoreConflicts list of elements to ignore conflicts for * can only contain 'label' and or 'description' and or 'sitelink' */ @@ -65,7 +64,7 @@ Item $fromItem, Item $toItem, LabelDescriptionDuplicateDetector $labelDescriptionDuplicateDetector, - SitelinkCache $sitelinkCache, + SiteLinkLookup $sitelinkLookup, $ignoreConflicts = array() ) { $this->assertValidIgnoreConflictValues( $ignoreConflicts ); @@ -76,9 +75,9 @@ $this->toChangeOps = new ChangeOps(); $this->ignoreConflicts = $ignoreConflicts; $this->labelDescriptionDuplicateDetector = $labelDescriptionDuplicateDetector; - $this->sitelinkCache = $sitelinkCache; + $this->sitelinkLookup = $sitelinkLookup; - //@todo inject me + //@todo FIXME: inject me $this->claimGuidValidator = WikibaseRepo::getDefaultInstance()->getClaimGuidValidator(); $this->claimGuidParser = WikibaseRepo::getDefaultInstance()->getClaimGuidParser(); } @@ -180,7 +179,7 @@ } else { $this->toChangeOps->add( new ChangeOpClaim( $toClaim, - new ClaimGuidGenerator( $this->toItem->getId() ), + new ClaimGuidGenerator(), $this->claimGuidValidator, $this->claimGuidParser ) ); @@ -251,7 +250,7 @@ $this->toItem ); } - $conflictingSitelinks = $this->sitelinkCache->getConflictsForItem( $this->toItem ); + $conflictingSitelinks = $this->sitelinkLookup->getConflictsForItem( $this->toItem ); $conflictString = ''; if( $conflictingTerms !== array() ) { diff --git a/repo/includes/api/CreateClaim.php b/repo/includes/api/CreateClaim.php index 4f83b8a..1f428db 100644 --- a/repo/includes/api/CreateClaim.php +++ b/repo/includes/api/CreateClaim.php @@ -48,7 +48,7 @@ $snak = $this->claimModificationHelper->getSnakInstance( $params, $propertyId ); $summary = $this->claimModificationHelper->createSummary( $params, $this ); - $changeOp = new ChangeOpMainSnak( '', $snak, new ClaimGuidGenerator( $entity->getId() ) ); + $changeOp = new ChangeOpMainSnak( '', $snak, new ClaimGuidGenerator() ); try { $changeOp->apply( $entity, $summary ); diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php index efc4cc7..940b233 100644 --- a/repo/includes/api/EditEntity.php +++ b/repo/includes/api/EditEntity.php @@ -255,7 +255,7 @@ $changeOps->add( $this->getClaimsChangeOps( $data['claims'], - new ClaimGuidGenerator( $entity->getId() ), + new ClaimGuidGenerator(), $this->claimGuidValidator, $this->claimGuidParser ) diff --git a/repo/includes/api/SetClaim.php b/repo/includes/api/SetClaim.php index 8dc96d4..a3d818f 100644 --- a/repo/includes/api/SetClaim.php +++ b/repo/includes/api/SetClaim.php @@ -80,7 +80,7 @@ $changeop = new ChangeOpClaim( $claim, - new ClaimGuidGenerator( $guid->getEntityId() ), + new ClaimGuidGenerator(), $this->getClaimGuidValidator(), $this->claimGuidParser, ( isset( $params['index'] ) ? $params['index'] : null ) diff --git a/repo/includes/api/SetClaimValue.php b/repo/includes/api/SetClaimValue.php index 731b283..21ef600 100644 --- a/repo/includes/api/SetClaimValue.php +++ b/repo/includes/api/SetClaimValue.php @@ -41,7 +41,7 @@ $summary = $this->claimModificationHelper->createSummary( $params, $this ); - $guidGenerator = new ClaimGuidGenerator( $entity->getId() ); + $guidGenerator = new ClaimGuidGenerator(); $changeOp = new ChangeOpMainSnak( $claimGuid, $snak, diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpClaimTest.php b/repo/tests/phpunit/includes/ChangeOp/ChangeOpClaimTest.php index d1b18fc..6776515 100644 --- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpClaimTest.php +++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpClaimTest.php @@ -31,8 +31,8 @@ return new Claim( new PropertyNoValueSnak( 7 ) ); } - public function getValidGuidGenerator( ItemId $itemId ) { - return new ClaimGuidGenerator( $itemId ); + public function getValidGuidGenerator() { + return new ClaimGuidGenerator(); } private function getMockGuidValidator() { @@ -84,7 +84,7 @@ $itemId = new ItemId( 'q42' ); new ChangeOpClaim( $this->getValidClaim(), - $this->getValidGuidGenerator( $itemId), + $this->getValidGuidGenerator(), $this->getMockGuidValidator(), $this->getMockGuidParser( $itemId ), $invalidIndex @@ -168,7 +168,7 @@ $changeOpClaim = new ChangeOpClaim( $claim, - new ClaimGuidGenerator( $entity->getId() ), + new ClaimGuidGenerator(), WikibaseRepo::getDefaultInstance()->getClaimGuidValidator(), //@todo mock me! WikibaseRepo::getDefaultInstance()->getClaimGuidParser(), //@todo mock me! $index @@ -204,7 +204,7 @@ $item = $this->makeNewItemWithClaim( 'Q777', $snak ); $claims = $item->getClaims(); $claim = reset( $claims ); - $guidGenerator = new ClaimGuidGenerator( $item->getId() ); + $guidGenerator = new ClaimGuidGenerator(); // change main snak to "some value" $newSnak = new PropertySomeValueSnak( 67573284 ); @@ -265,8 +265,8 @@ $entity->setId( new ItemId( $itemId ) ); $claim = $entity->newClaim( $snak ); - $guidGenerator = new ClaimGuidGenerator( $entity->getId() ); - $claim->setGuid( $guidGenerator->newGuid() ); + $guidGenerator = new ClaimGuidGenerator(); + $claim->setGuid( $guidGenerator->newGuid( $entity->getId() ) ); $claims = new Claims(); $claims->addClaim( $claim ); diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpMainSnakTest.php b/repo/tests/phpunit/includes/ChangeOp/ChangeOpMainSnakTest.php index 1f4d492..7414cf5 100644 --- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpMainSnakTest.php +++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpMainSnakTest.php @@ -30,9 +30,9 @@ public function invalidArgumentProvider() { $item = ItemContent::newFromArray( array( 'entity' => 'q42' ) )->getEntity(); - $validGuidGenerator = new ClaimGuidGenerator( $item->getId() ); - $guidGenerator = new ClaimGuidGenerator( $item->getId() ); - $validClaimGuid = $guidGenerator->newGuid(); + $validGuidGenerator = new ClaimGuidGenerator(); + $guidGenerator = new ClaimGuidGenerator(); + $validClaimGuid = $guidGenerator->newGuid( $item->getId( $item->getId() ) ); $validSnak = new PropertyValueSnak( 7201010, new StringValue( 'o_O' ) ); $args = array(); @@ -62,7 +62,7 @@ $item = $this->makeNewItemWithClaim( 'q123', $snak ); $newSnak = new PropertyValueSnak( 78462378, new StringValue( 'newSnak' ) ); $claimGuid = ''; - $changeOp = new ChangeOpMainSnak( $claimGuid, $newSnak, new ClaimGuidGenerator( $item->getId() ) ); + $changeOp = new ChangeOpMainSnak( $claimGuid, $newSnak, new ClaimGuidGenerator() ); $expected = $newSnak->getDataValue(); $args['add new claim'] = array ( $item, $changeOp, $expected ); @@ -73,7 +73,7 @@ $claim = reset( $claims ); $claimGuid = $claim->getGuid(); - $changeOp = new ChangeOpMainSnak( $claimGuid, $newSnak, new ClaimGuidGenerator( $item->getId() ) ); + $changeOp = new ChangeOpMainSnak( $claimGuid, $newSnak, new ClaimGuidGenerator() ); $expected = $newSnak->getDataValue(); $args['update claim by guid'] = array ( $item, $changeOp, $expected ); @@ -105,7 +105,7 @@ $claims = $item->getClaims(); $claim = reset( $claims ); $claimGuid = $claim->getGuid(); - $guidGenerator = new ClaimGuidGenerator( $item->getId() ); + $guidGenerator = new ClaimGuidGenerator(); // apply change to the wrong item $wrongItem = Item::newEmpty(); diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpQualifierTest.php b/repo/tests/phpunit/includes/ChangeOp/ChangeOpQualifierTest.php index 5a730de..bd0ec08 100644 --- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpQualifierTest.php +++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpQualifierTest.php @@ -26,8 +26,8 @@ public function invalidArgumentProvider() { $item = ItemContent::newFromArray( array( 'entity' => 'q42' ) )->getEntity(); - $guidGenerator = new ClaimGuidGenerator( $item->getId() ); - $validClaimGuid = $guidGenerator->newGuid(); + $guidGenerator = new ClaimGuidGenerator(); + $validClaimGuid = $guidGenerator->newGuid( $item->getId() ); $validSnak = new PropertyValueSnak( 7201010, new StringValue( 'o_O' ) ); $validSnakHash = $validSnak->getHash(); diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpReferenceTest.php b/repo/tests/phpunit/includes/ChangeOp/ChangeOpReferenceTest.php index ebf5bcc..0a7b399 100644 --- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpReferenceTest.php +++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpReferenceTest.php @@ -30,8 +30,8 @@ public function invalidArgumentProvider() { $item = ItemContent::newFromArray( array( 'entity' => 'q42' ) )->getEntity(); - $guidGenerator = new ClaimGuidGenerator( $item->getId() ); - $validClaimGuid = $guidGenerator->newGuid(); + $guidGenerator = new ClaimGuidGenerator(); + $validClaimGuid = $guidGenerator->newGuid( $item->getId() ); $snaks = new SnakList(); $snaks[] = new PropertyValueSnak( 7201010, new StringValue( 'o_O' ) ); $validReference = new Reference( $snaks ); diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpStatementRankTest.php b/repo/tests/phpunit/includes/ChangeOp/ChangeOpStatementRankTest.php index f14a80a..96610d8 100644 --- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpStatementRankTest.php +++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpStatementRankTest.php @@ -25,8 +25,8 @@ public function invalidArgumentProvider() { $item = ItemContent::newFromArray( array( 'entity' => 'q42' ) )->getEntity(); - $guidGenerator = new ClaimGuidGenerator( $item->getId() ); - $validClaimGuid = $guidGenerator->newGuid(); + $guidGenerator = new ClaimGuidGenerator(); + $validClaimGuid = $guidGenerator->newGuid( $item->getId() ); $validRank = 1; $args = array(); diff --git a/repo/tests/phpunit/includes/EntityViewTest.php b/repo/tests/phpunit/includes/EntityViewTest.php index 7795e2f..cc50c2d 100644 --- a/repo/tests/phpunit/includes/EntityViewTest.php +++ b/repo/tests/phpunit/includes/EntityViewTest.php @@ -324,10 +324,10 @@ new StringValue( 'cats!' ) ); - $claimGuidGenerator = new ClaimGuidGenerator( $itemId ); + $claimGuidGenerator = new ClaimGuidGenerator(); $claim = new Claim( $snak ); - $claim->setGuid( $claimGuidGenerator->newGuid() ); + $claim->setGuid( $claimGuidGenerator->newGuid( $itemId ) ); $entity->addClaim( $claim ); diff --git a/repo/tests/phpunit/includes/api/RemoveClaimsTest.php b/repo/tests/phpunit/includes/api/RemoveClaimsTest.php index 0afbc35..87fd038 100644 --- a/repo/tests/phpunit/includes/api/RemoveClaimsTest.php +++ b/repo/tests/phpunit/includes/api/RemoveClaimsTest.php @@ -56,8 +56,8 @@ ); foreach( $claims as $key => $claim ){ - $guidGenerator = new ClaimGuidGenerator( $entity->getId() ); - $claim->setGuid( $guidGenerator->newGuid() ); + $guidGenerator = new ClaimGuidGenerator(); + $claim->setGuid( $guidGenerator->newGuid( $entity->getId() ) ); $entity->addClaim( $claim ); } diff --git a/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php b/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php index 0996336..e2e31ab 100644 --- a/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php +++ b/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php @@ -79,8 +79,8 @@ wfSuppressWarnings(); // We are referencing properties that don't exist. Not relevant here. $store->saveEntity( $item, '', $GLOBALS['wgUser'], EDIT_NEW ); - $guidGenerator = new ClaimGuidGenerator( $item->getId() ); - $statement->setGuid( $guidGenerator->newGuid() ); + $guidGenerator = new ClaimGuidGenerator(); + $statement->setGuid( $guidGenerator->newGuid( $item->getId() ) ); $item->addClaim( $statement ); $store->saveEntity( $item, '', $GLOBALS['wgUser'], EDIT_UPDATE ); diff --git a/repo/tests/phpunit/includes/api/RemoveReferencesTest.php b/repo/tests/phpunit/includes/api/RemoveReferencesTest.php index 3b5900b..7abc23e 100644 --- a/repo/tests/phpunit/includes/api/RemoveReferencesTest.php +++ b/repo/tests/phpunit/includes/api/RemoveReferencesTest.php @@ -79,8 +79,8 @@ $store = WikibaseRepo::getDefaultInstance()->getEntityStore(); $store->saveEntity( $item, '', $GLOBALS['wgUser'], EDIT_NEW ); - $guidGenerator = new ClaimGuidGenerator( $item->getId() ); - $statement->setGuid( $guidGenerator->newGuid() ); + $guidGenerator = new ClaimGuidGenerator(); + $statement->setGuid( $guidGenerator->newGuid( $item->getId() ) ); $item->addClaim( $statement ); $store->saveEntity( $item, '', $GLOBALS['wgUser'], EDIT_UPDATE ); diff --git a/repo/tests/phpunit/includes/api/SetClaimTest.php b/repo/tests/phpunit/includes/api/SetClaimTest.php index 42d160b..288797f 100644 --- a/repo/tests/phpunit/includes/api/SetClaimTest.php +++ b/repo/tests/phpunit/includes/api/SetClaimTest.php @@ -130,8 +130,8 @@ $store->saveEntity( $item, 'setclaimtest', $GLOBALS['wgUser'], EDIT_NEW ); $itemId = $item->getId(); - $guidGenerator = new ClaimGuidGenerator( $itemId ); - $guid = $guidGenerator->newGuid(); + $guidGenerator = new ClaimGuidGenerator(); + $guid = $guidGenerator->newGuid( $itemId ); $claim->setGuid( $guid ); @@ -172,11 +172,11 @@ $store->saveEntity( $item, 'setclaimtest', $GLOBALS['wgUser'], EDIT_NEW ); $itemId = $item->getId(); - $guidGenerator = new ClaimGuidGenerator( $itemId ); + $guidGenerator = new ClaimGuidGenerator(); for( $i = 1; $i <= 3; $i++ ) { $preexistingClaim = $item->newClaim( new PropertyNoValueSnak( $i ) ); - $preexistingClaim->setGuid( $guidGenerator->newGuid() ); + $preexistingClaim->setGuid( $guidGenerator->newGuid( $itemId ) ); $claims->addClaim( $preexistingClaim ); } @@ -185,7 +185,7 @@ $store->saveEntity( $item, 'setclaimtest', $GLOBALS['wgUser'], EDIT_UPDATE ); // Add new claim at index 2: - $guid = $guidGenerator->newGuid(); + $guid = $guidGenerator->newGuid( $itemId ); /** @var Claim $claim */ foreach( $this->getClaims() as $claim ) { $claim->setGuid( $guid ); @@ -279,9 +279,9 @@ // Generate a single claim: $itemId = $item->getId(); - $guidGenerator = new ClaimGuidGenerator( $itemId ); + $guidGenerator = new ClaimGuidGenerator(); $preexistingClaim = $item->newClaim( new PropertyNoValueSnak( self::$propertyIds[1] ) ); - $preexistingClaim->setGuid( $guidGenerator->newGuid() ); + $preexistingClaim->setGuid( $guidGenerator->newGuid( $itemId ) ); $claims->addClaim( $preexistingClaim ); // Save the single claim @@ -290,7 +290,7 @@ // Add new claim at index 3 using the baserevid and a different property id $newClaim = $item->newClaim( new PropertyNoValueSnak( self::$propertyIds[2] ) ); - $newClaim->setGuid( $guidGenerator->newGuid() ); + $newClaim->setGuid( $guidGenerator->newGuid( $itemId ) ); $this->makeRequest( $newClaim, $itemId, 2, 'addition request', 3, $revision->getRevision() ); } @@ -307,9 +307,9 @@ $item = $store->saveEntity( $item, '', $GLOBALS['wgUser'], EDIT_NEW )->getEntity(); // add a claim - $guidGenerator = new ClaimGuidGenerator( $item->getId() ); + $guidGenerator = new ClaimGuidGenerator(); $claim = new Claim( new PropertyNoValueSnak( $property->getId() ) ); - $claim->setGuid( $guidGenerator->newGuid() ); + $claim->setGuid( $guidGenerator->newGuid( $item->getId() ) ); $item->addClaim( $claim ); $item = $store->saveEntity( $item, '', $GLOBALS['wgUser'], EDIT_UPDATE )->getEntity(); diff --git a/repo/tests/phpunit/includes/api/SetQualifierTest.php b/repo/tests/phpunit/includes/api/SetQualifierTest.php index 1567fbe..c35be8a 100644 --- a/repo/tests/phpunit/includes/api/SetQualifierTest.php +++ b/repo/tests/phpunit/includes/api/SetQualifierTest.php @@ -88,8 +88,8 @@ $propId = $this->makeProperty( $prop, 'string' )->getId(); $claim = new Statement( new PropertyValueSnak( $propId, new StringValue( '^_^' ) ) ); - $guidGenerator = new ClaimGuidGenerator( $item->getId() ); - $claim->setGuid( $guidGenerator->newGuid() ); + $guidGenerator = new ClaimGuidGenerator(); + $claim->setGuid( $guidGenerator->newGuid( $item->getId() ) ); $item->addClaim( $claim ); $store->saveEntity( $item, '', $GLOBALS['wgUser'], EDIT_UPDATE ); diff --git a/repo/tests/phpunit/includes/content/PropertyContentTest.php b/repo/tests/phpunit/includes/content/PropertyContentTest.php index faebda4..4cc5ff3 100644 --- a/repo/tests/phpunit/includes/content/PropertyContentTest.php +++ b/repo/tests/phpunit/includes/content/PropertyContentTest.php @@ -53,7 +53,7 @@ $propertyContent1->getProperty()->setDataTypeId( 'wikibase-item' ); $status = $propertyContent1->save( 'create property', null, EDIT_NEW ); - $this->assertTrue( $status->isOK(), "property creation should work" ); + $this->assertTrue( $status->isOK(), "property creation should wok" ); $propertyContent1->getProperty()->setLabel( 'en', $prefix . 'testLabelUniquenessRestriction' ); -- To view, visit https://gerrit.wikimedia.org/r/121316 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifd96ab78424d7b674323becb310294d00b367e73 Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits