Jeroen De Dauw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/175744
Change subject: Act on TODO: rename getRevision to getRevisionId
......................................................................
Act on TODO: rename getRevision to getRevisionId
Change-Id: Ifd2885d5991dd93ee47a7212e635545b3962163a
---
M lib/includes/store/EntityRevision.php
M lib/tests/phpunit/MockRepository.php
M lib/tests/phpunit/MockRepositoryTest.php
M lib/tests/phpunit/store/CachingEntityRevisionLookupTest.php
M repo/includes/EditEntity.php
M repo/includes/EntityView.php
M repo/includes/api/MergeItems.php
M repo/includes/api/ModifyEntity.php
M repo/includes/api/ResultBuilder.php
M repo/includes/rdf/RdfSerializer.php
M repo/includes/specials/SpecialMergeItems.php
M repo/tests/phpunit/includes/ContentRetrieverTest.php
M repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
M repo/tests/phpunit/includes/actions/ActionTestCase.php
M repo/tests/phpunit/includes/api/SetClaimTest.php
M repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
M repo/tests/phpunit/includes/store/WikiPageEntityRevisionLookupTest.php
M repo/tests/phpunit/includes/store/sql/WikiPageEntityStoreTest.php
18 files changed, 43 insertions(+), 44 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/44/175744/1
diff --git a/lib/includes/store/EntityRevision.php
b/lib/includes/store/EntityRevision.php
index cffb4fa..7c4cc45 100644
--- a/lib/includes/store/EntityRevision.php
+++ b/lib/includes/store/EntityRevision.php
@@ -60,11 +60,10 @@
/**
* @see Revision::getId
- * @todo Rename to getRevisionId, it does not return a Revision.
*
* @return int
*/
- public function getRevision() {
+ public function getRevisionId() {
return $this->revisionId;
}
diff --git a/lib/tests/phpunit/MockRepository.php
b/lib/tests/phpunit/MockRepository.php
index c82a5f8..6715ecd 100644
--- a/lib/tests/phpunit/MockRepository.php
+++ b/lib/tests/phpunit/MockRepository.php
@@ -145,7 +145,7 @@
$entityRev = $revisions[$revision];
$entityRev = new EntityRevision( // return a copy!
$entityRev->getEntity()->copy(), // return a copy!
- $entityRev->getRevision(),
+ $entityRev->getRevisionId(),
$entityRev->getTimestamp()
);
@@ -629,7 +629,7 @@
public function getLatestRevisionId( EntityId $entityId ) {
$rev = $this->getEntityRevision( $entityId );
- return $rev === null ? false : $rev->getRevision();
+ return $rev === null ? false : $rev->getRevisionId();
}
/**
@@ -666,7 +666,7 @@
throw new StorageException( 'No base revision found for
' . $id->getSerialization() );
}
- if ( $baseRevId !== false && $this->getEntityRevision( $id
)->getRevision() !== $baseRevId ) {
+ if ( $baseRevId !== false && $this->getEntityRevision( $id
)->getRevisionId() !== $baseRevId ) {
$status->fatal( 'edit-conflict' );
}
@@ -676,7 +676,7 @@
$entityRevision = $this->putEntity( $entity, 0, 0, $user );
- $this->putLog( $entityRevision->getRevision(),
$entity->getId(), $summary, $user->getName() );
+ $this->putLog( $entityRevision->getRevisionId(),
$entity->getId(), $summary, $user->getName() );
return $entityRevision;
}
diff --git a/lib/tests/phpunit/MockRepositoryTest.php
b/lib/tests/phpunit/MockRepositoryTest.php
index d19d0c9..633ad95 100644
--- a/lib/tests/phpunit/MockRepositoryTest.php
+++ b/lib/tests/phpunit/MockRepositoryTest.php
@@ -119,14 +119,14 @@
$this->assertNotNull( $item, "Entity " . $itemId );
$this->assertInstanceOf( '\Wikibase\EntityRevision', $itemRev,
"Entity " . $itemId );
$this->assertInstanceOf( 'Wikibase\DataModel\Entity\Item',
$itemRev->getEntity(), "Entity " . $itemId );
- $this->assertEquals( 24, $itemRev->getRevision() );
+ $this->assertEquals( 24, $itemRev->getRevisionId() );
// test item by rev id
$itemRev = $this->repo->getEntityRevision( $itemId, 23 );
$this->assertNotNull( $item, "Entity " . $itemId . "@23" );
$this->assertInstanceOf( '\Wikibase\EntityRevision', $itemRev,
"Entity " . $itemId );
$this->assertInstanceOf( 'Wikibase\DataModel\Entity\Item',
$itemRev->getEntity(), "Entity " . $itemId );
- $this->assertEquals( 23, $itemRev->getRevision() );
+ $this->assertEquals( 23, $itemRev->getRevisionId() );
$this->assertEquals( "20130101000000", $itemRev->getTimestamp()
);
// test latest prop
@@ -553,9 +553,9 @@
$rev = $this->repo->saveEntity( $entity, 'f00',
$GLOBALS['wgUser'], $flags, $baseRevId );
- $logEntry = $this->repo->getLogEntry( $rev->getRevision() );
+ $logEntry = $this->repo->getLogEntry( $rev->getRevisionId() );
$this->assertNotNull( $logEntry );
- $this->assertEquals( $rev->getRevision(), $logEntry['revision']
);
+ $this->assertEquals( $rev->getRevisionId(),
$logEntry['revision'] );
$this->assertEquals( $entity->getId()->getSerialization(),
$logEntry['entity'] );
$this->assertEquals( 'f00', $logEntry['summary'] );
@@ -679,25 +679,25 @@
$rev1 = $this->repo->saveEntity( $item, 'testing 1', $user1,
EDIT_NEW );
$itemId = $item->getId();
- $this->assertTrue( $this->repo->userWasLastToEdit( $user1,
$itemId, $rev1->getRevision() ), 'user was first and last to edit' );
- $this->assertFalse( $this->repo->userWasLastToEdit( $user2,
$itemId, $rev1->getRevision() ), 'user has not edited yet' );
+ $this->assertTrue( $this->repo->userWasLastToEdit( $user1,
$itemId, $rev1->getRevisionId() ), 'user was first and last to edit' );
+ $this->assertFalse( $this->repo->userWasLastToEdit( $user2,
$itemId, $rev1->getRevisionId() ), 'user has not edited yet' );
// second edit by another user
$item = $item->copy();
$item->setLabel( 'en', 'two' );
$rev2 = $this->repo->saveEntity( $item, 'testing 2', $user2,
EDIT_UPDATE );
- $this->assertFalse( $this->repo->userWasLastToEdit( $user1,
$itemId, $rev1->getRevision() ), 'original user was no longer last to edit' );
- $this->assertTrue( $this->repo->userWasLastToEdit( $user2,
$itemId, $rev2->getRevision() ), 'second user has just edited' );
+ $this->assertFalse( $this->repo->userWasLastToEdit( $user1,
$itemId, $rev1->getRevisionId() ), 'original user was no longer last to edit' );
+ $this->assertTrue( $this->repo->userWasLastToEdit( $user2,
$itemId, $rev2->getRevisionId() ), 'second user has just edited' );
// subsequent edit by the original user
$item = $item->copy();
$item->setLabel( 'en', 'three' );
$rev3 = $this->repo->saveEntity( $item, 'testing 3', $user1,
EDIT_UPDATE );
- $this->assertFalse( $this->repo->userWasLastToEdit( $user1,
$itemId, $rev1->getRevision() ), 'another user had edited at some point' );
- $this->assertTrue( $this->repo->userWasLastToEdit( $user1,
$itemId, $rev3->getRevision() ), 'original user was last to edit' );
- $this->assertFalse( $this->repo->userWasLastToEdit( $user2,
$itemId, $rev2->getRevision() ), 'other user was no longer last to edit' );
+ $this->assertFalse( $this->repo->userWasLastToEdit( $user1,
$itemId, $rev1->getRevisionId() ), 'another user had edited at some point' );
+ $this->assertTrue( $this->repo->userWasLastToEdit( $user1,
$itemId, $rev3->getRevisionId() ), 'original user was last to edit' );
+ $this->assertFalse( $this->repo->userWasLastToEdit( $user2,
$itemId, $rev2->getRevisionId() ), 'other user was no longer last to edit' );
}
}
diff --git a/lib/tests/phpunit/store/CachingEntityRevisionLookupTest.php
b/lib/tests/phpunit/store/CachingEntityRevisionLookupTest.php
index 06e81a1..d1c5822 100644
--- a/lib/tests/phpunit/store/CachingEntityRevisionLookupTest.php
+++ b/lib/tests/phpunit/store/CachingEntityRevisionLookupTest.php
@@ -34,7 +34,7 @@
$mock = new MockRepository();
foreach ( $entityRevisions as $entityRev ) {
- $mock->putEntity( $entityRev->getEntity(),
$entityRev->getRevision() );
+ $mock->putEntity( $entityRev->getEntity(),
$entityRev->getRevisionId() );
}
foreach ( $entityRedirects as $entityRedir ) {
@@ -67,7 +67,7 @@
$this->assertEquals( 12, $revId, 'new revision should be
detected if verification is enabled' );
$rev = $lookup->getEntityRevision( $id );
- $this->assertEquals( 12, $rev->getRevision(), 'new revision
should be detected if verification is enabled' );
+ $this->assertEquals( 12, $rev->getRevisionId(), 'new revision
should be detected if verification is enabled' );
// remove the item
$mock->removeEntity( $id );
@@ -103,7 +103,7 @@
$this->assertEquals( 11, $revId, 'new revision should be
ignored if verification is disabled' );
$rev = $lookup->getEntityRevision( $id );
- $this->assertEquals( 11, $rev->getRevision(), 'new revision
should be ignored if verification is disabled' );
+ $this->assertEquals( 11, $rev->getRevisionId(), 'new revision
should be ignored if verification is disabled' );
// remove the item
$mock->removeEntity( $id );
@@ -113,7 +113,7 @@
$this->assertEquals( 11, $revId, 'deletion should be ignored if
verification is disabled' );
$rev = $lookup->getEntityRevision( $id );
- $this->assertEquals( 11, $rev->getRevision(), 'deletion should
be ignored if verification is disabled' );
+ $this->assertEquals( 11, $rev->getRevisionId(), 'deletion
should be ignored if verification is disabled' );
}
public function testEntityUpdated() {
@@ -142,7 +142,7 @@
$this->assertEquals( 12, $revId, 'new revision should be
detected after notification' );
$rev = $lookup->getEntityRevision( $id );
- $this->assertEquals( 12, $rev->getRevision(), 'new revision
should be detected after notification' );
+ $this->assertEquals( 12, $rev->getRevisionId(), 'new revision
should be detected after notification' );
}
public function testRedirectUpdated() {
diff --git a/repo/includes/EditEntity.php b/repo/includes/EditEntity.php
index 7ccff02..4730e51 100644
--- a/repo/includes/EditEntity.php
+++ b/repo/includes/EditEntity.php
@@ -288,7 +288,7 @@
wfProfileIn( __METHOD__ );
if ( $this->latestRevId === null ) {
if ( $this->latestRev !== null ) {
- $this->latestRevId =
$this->latestRev->getRevision();
+ $this->latestRevId =
$this->latestRev->getRevisionId();
} else {
$this->latestRevId =
$this->entityRevisionLookup->getLatestRevisionId( $this->getEntityId() );
}
diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php
index ffb1405..137a03c 100644
--- a/repo/includes/EntityView.php
+++ b/repo/includes/EntityView.php
@@ -235,7 +235,7 @@
return $this->textInjector->newMarker(
'termbox',
$entityId->getSerialization(),
- $entityRevision->getRevision()
+ $entityRevision->getRevisionId()
);
}
diff --git a/repo/includes/api/MergeItems.php b/repo/includes/api/MergeItems.php
index d5ec03c..4c6484f 100644
--- a/repo/includes/api/MergeItems.php
+++ b/repo/includes/api/MergeItems.php
@@ -168,7 +168,7 @@
private function addEntityToOutput( EntityRevision $entityRevision,
$name ) {
$entityId = $entityRevision->getEntity()->getId();
- $revisionId = $entityRevision->getRevision();
+ $revisionId = $entityRevision->getRevisionId();
$this->resultBuilder->addBasicEntityInformation( $entityId,
$name );
diff --git a/repo/includes/api/ModifyEntity.php
b/repo/includes/api/ModifyEntity.php
index 3691559..96f0135 100644
--- a/repo/includes/api/ModifyEntity.php
+++ b/repo/includes/api/ModifyEntity.php
@@ -328,7 +328,7 @@
}
} else {
$entity = $entityRev->getEntity();
- $entityRevId = $entityRev->getRevision();
+ $entityRevId = $entityRev->getRevisionId();
}
if ( $entity->getId() === null ) {
diff --git a/repo/includes/api/ResultBuilder.php
b/repo/includes/api/ResultBuilder.php
index a05e9c6..540d591 100644
--- a/repo/includes/api/ResultBuilder.php
+++ b/repo/includes/api/ResultBuilder.php
@@ -312,7 +312,7 @@
$record['pageid'] = $title->getArticleID();
$record['ns'] = intval( $title->getNamespace()
);
$record['title'] = $title->getPrefixedText();
- $record['lastrevid'] = intval(
$entityRevision->getRevision() );
+ $record['lastrevid'] = intval(
$entityRevision->getRevisionId() );
$record['modified'] = wfTimestamp( TS_ISO_8601,
$entityRevision->getTimestamp() );
}
@@ -550,7 +550,7 @@
if ( $revision instanceof Revision ) {
$revisionId = $revision->getId();
} elseif ( $revision instanceof EntityRevision ) {
- $revisionId = $revision->getRevision();
+ $revisionId = $revision->getRevisionId();
}
$this->setValue( $path, 'lastrevid', empty( $revisionId
) ? 0 : $revisionId );
diff --git a/repo/includes/rdf/RdfSerializer.php
b/repo/includes/rdf/RdfSerializer.php
index 630ceee..85d9c0b 100644
--- a/repo/includes/rdf/RdfSerializer.php
+++ b/repo/includes/rdf/RdfSerializer.php
@@ -121,7 +121,7 @@
$builder->addEntityRevisionInfo(
$entityRevision->getEntity()->getId(),
- $entityRevision->getRevision(),
+ $entityRevision->getRevisionId(),
$entityRevision->getTimestamp()
);
diff --git a/repo/includes/specials/SpecialMergeItems.php
b/repo/includes/specials/SpecialMergeItems.php
index 8cf313c..a5862dd 100644
--- a/repo/includes/specials/SpecialMergeItems.php
+++ b/repo/includes/specials/SpecialMergeItems.php
@@ -195,9 +195,9 @@
$this->getOutput()->addWikiMsg(
'wikibase-mergeitems-success',
$fromId->getSerialization(),
- $newRevisionFrom->getRevision(),
+ $newRevisionFrom->getRevisionId(),
$toId->getSerialization(),
- $newRevisionTo->getRevision() );
+ $newRevisionTo->getRevisionId() );
}
/**
diff --git a/repo/tests/phpunit/includes/ContentRetrieverTest.php
b/repo/tests/phpunit/includes/ContentRetrieverTest.php
index 6d224da..f488a4c 100644
--- a/repo/tests/phpunit/includes/ContentRetrieverTest.php
+++ b/repo/tests/phpunit/includes/ContentRetrieverTest.php
@@ -175,7 +175,7 @@
$item->setDescription( 'en', $description );
$rev = $store->saveEntity( $item, "edit description",
$GLOBALS['wgUser'], EDIT_UPDATE );
- $revIds[] = $rev->getRevision();
+ $revIds[] = $rev->getRevisionId();
}
/**
diff --git a/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
b/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
index 0b548a2..20845fb 100644
--- a/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
+++ b/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
@@ -43,7 +43,7 @@
$mockRepository = new MockRepository();
foreach ( self::getEntityRevisions() as $entityRev ) {
- $mockRepository->putEntity( $entityRev->getEntity(),
$entityRev->getRevision(), $entityRev->getTimestamp() );
+ $mockRepository->putEntity( $entityRev->getEntity(),
$entityRev->getRevisionId(), $entityRev->getTimestamp() );
}
foreach ( self::getEntityRedirects() as $entityRedir ) {
diff --git a/repo/tests/phpunit/includes/actions/ActionTestCase.php
b/repo/tests/phpunit/includes/actions/ActionTestCase.php
index 18c691d..5be21ab 100644
--- a/repo/tests/phpunit/includes/actions/ActionTestCase.php
+++ b/repo/tests/phpunit/includes/actions/ActionTestCase.php
@@ -348,7 +348,7 @@
$result = $rev->getEntity();
//XXX: hack - glue refid to item, so we can compare it later in
resetTestItem()
- $result->revid = $rev->getRevision();
+ $result->revid = $rev->getRevisionId();
return $result;
}
diff --git a/repo/tests/phpunit/includes/api/SetClaimTest.php
b/repo/tests/phpunit/includes/api/SetClaimTest.php
index e39e753..d63515e 100644
--- a/repo/tests/phpunit/includes/api/SetClaimTest.php
+++ b/repo/tests/phpunit/includes/api/SetClaimTest.php
@@ -413,7 +413,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( $itemId ) );
- $this->makeRequest( $newClaim, $itemId, 2, 'addition request',
3, $revision->getRevision() );
+ $this->makeRequest( $newClaim, $itemId, 2, 'addition request',
3, $revision->getRevisionId() );
}
public function testBadPropertyError() {
diff --git a/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
b/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
index 8dccf31..f325f36 100644
--- a/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
+++ b/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
@@ -228,7 +228,7 @@
$builder = $this->newRdfBuilder();
$builder->addEntity( $entityRevision->getEntity() );
- $builder->addEntityRevisionInfo(
$entityRevision->getEntity()->getId(), $entityRevision->getRevision(),
$entityRevision->getTimestamp() );
+ $builder->addEntityRevisionInfo(
$entityRevision->getEntity()->getId(), $entityRevision->getRevisionId(),
$entityRevision->getTimestamp() );
$graph = $builder->getGraph();
foreach ( $expectedGraph->resources() as $rc ) {
diff --git
a/repo/tests/phpunit/includes/store/WikiPageEntityRevisionLookupTest.php
b/repo/tests/phpunit/includes/store/WikiPageEntityRevisionLookupTest.php
index 265b94f..406a8aa 100644
--- a/repo/tests/phpunit/includes/store/WikiPageEntityRevisionLookupTest.php
+++ b/repo/tests/phpunit/includes/store/WikiPageEntityRevisionLookupTest.php
@@ -59,7 +59,7 @@
// make sure all test entities are in the database.
foreach ( $entityRevisions as $entityRev ) {
- $logicalRev = $entityRev->getRevision();
+ $logicalRev = $entityRev->getRevisionId();
if ( !isset( self::$testEntities[$logicalRev] ) ) {
$rev = self::storeTestEntity(
$entityRev->getEntity() );
@@ -82,7 +82,7 @@
protected function resolveLogicalRevision( $revision ) {
if ( is_int( $revision ) && isset(
self::$testEntities[$revision] ) ) {
- $revision =
self::$testEntities[$revision]->getRevision();
+ $revision =
self::$testEntities[$revision]->getRevisionId();
}
return $revision;
diff --git a/repo/tests/phpunit/includes/store/sql/WikiPageEntityStoreTest.php
b/repo/tests/phpunit/includes/store/sql/WikiPageEntityStoreTest.php
index 35396d4..b308c00 100644
--- a/repo/tests/phpunit/includes/store/sql/WikiPageEntityStoreTest.php
+++ b/repo/tests/phpunit/includes/store/sql/WikiPageEntityStoreTest.php
@@ -132,7 +132,7 @@
$entityId = $r1->getEntity()->getId();
$r1actual = $lookup->getEntityRevision( $entityId );
- $this->assertEquals( $r1->getRevision(),
$r1actual->getRevision(), 'revid' );
+ $this->assertEquals( $r1->getRevisionId(),
$r1actual->getRevisionId(), 'revid' );
$this->assertEquals( $r1->getTimestamp(),
$r1actual->getTimestamp(), 'timestamp' );
$this->assertEquals( $r1->getEntity()->getId(),
$r1actual->getEntity()->getId(), 'entity id' );
@@ -143,10 +143,10 @@
$entity->setLabel( 'en', 'UPDATED' );
$r2 = $store->saveEntity( $entity, 'update one', $user,
EDIT_UPDATE );
- $this->assertNotEquals( $r1->getRevision(), $r2->getRevision(),
'expected new revision id' );
+ $this->assertNotEquals( $r1->getRevisionId(),
$r2->getRevisionId(), 'expected new revision id' );
$r2actual = $lookup->getEntityRevision( $entityId );
- $this->assertEquals( $r2->getRevision(),
$r2actual->getRevision(), 'revid' );
+ $this->assertEquals( $r2->getRevisionId(),
$r2actual->getRevisionId(), 'revid' );
$this->assertEquals( $r2->getTimestamp(),
$r2actual->getTimestamp(), 'timestamp' );
$this->assertEquals( $r2->getEntity()->getId(),
$r2actual->getEntity()->getId(), 'entity id' );
@@ -199,7 +199,7 @@
// inject ids
if ( is_int( $baseRevId ) ) {
// use target item's revision as an offset
- $baseRevId += $r1->getRevision();
+ $baseRevId += $r1->getRevisionId();
}
if ( $entity->getId() === null ) {
@@ -268,7 +268,7 @@
// Revert to original content
$r1 = $store->saveEntity( $one, 'restore one', $user,
EDIT_UPDATE );
- $revision = Revision::newFromId( $r1->getRevision() );
+ $revision = Revision::newFromId( $r1->getRevisionId() );
$this->assertFalse( $revision->getTitle()->isRedirect(),
'Title::isRedirect' );
$this->assertFalse( $revision->getContent()->isRedirect(),
'EntityContent::isRedirect()' );
@@ -411,7 +411,7 @@
try {
$rev = $store->saveEntity( $entity, $summary, $user,
$flags, $baseRevId );
- $status = Status::newGood( Revision::newFromId(
$rev->getRevision() ) );
+ $status = Status::newGood( Revision::newFromId(
$rev->getRevisionId() ) );
} catch ( StorageException $ex ) {
$status = $ex->getStatus();
--
To view, visit https://gerrit.wikimedia.org/r/175744
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd2885d5991dd93ee47a7212e635545b3962163a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits