jenkins-bot has submitted this change and it was merged.
Change subject: Remove UsageTracker::removeEntities and all implementations
......................................................................
Remove UsageTracker::removeEntities and all implementations
Unused, also we don't plan to unlink deleted entities.
Bug: T114654
Change-Id: Id126d968987d2e0aa39539a876276d74a9fe0e70
---
M client/includes/Usage/NullUsageTracker.php
M client/includes/Usage/Sql/EntityUsageTable.php
M client/includes/Usage/Sql/SqlUsageTracker.php
M client/includes/Usage/UsageTracker.php
M client/tests/phpunit/includes/Usage/Sql/EntityUsageTableTest.php
M client/tests/phpunit/includes/Usage/Sql/SqlUsageTrackerTest.php
M client/tests/phpunit/includes/Usage/UsageTrackerContractTester.php
7 files changed, 0 insertions(+), 160 deletions(-)
Approvals:
Daniel Kinzler: Looks good to me, approved
Thiemo Mättig (WMDE): Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/client/includes/Usage/NullUsageTracker.php
b/client/includes/Usage/NullUsageTracker.php
index 893efc9..58b2789 100644
--- a/client/includes/Usage/NullUsageTracker.php
+++ b/client/includes/Usage/NullUsageTracker.php
@@ -38,15 +38,6 @@
}
/**
- * @see UsageTracker::removeEntities
- *
- * @param EntityId[] $entityIds
- */
- public function removeEntities( array $entityIds ) {
- // no-op
- }
-
- /**
* @see UsageTracker::getUsagesForPage
*
* @param int $pageId
diff --git a/client/includes/Usage/Sql/EntityUsageTable.php
b/client/includes/Usage/Sql/EntityUsageTable.php
index 72bbcc1..4a4cf36 100644
--- a/client/includes/Usage/Sql/EntityUsageTable.php
+++ b/client/includes/Usage/Sql/EntityUsageTable.php
@@ -333,36 +333,6 @@
}
/**
- * Removes usage tracking for the given set of entities.
- * This is used typically when entities were deleted.
- *
- * @see UsageTracker::removeEntities
- *
- * @param EntityId[] $entityIds
- */
- public function removeEntities( array $entityIds ) {
- if ( empty( $entityIds ) ) {
- return;
- }
-
- $idStrings = $this->getEntityIdStrings( $entityIds );
-
- $batches = array_chunk( $idStrings, $this->batchSize );
-
- foreach ( $batches as $batch ) {
- $this->connection->begin( __METHOD__ );
- $this->connection->delete(
- $this->tableName,
- array(
- 'eu_entity_id' => $batch,
- ),
- __METHOD__
- );
- $this->connection->commit( __METHOD__ );
- }
- }
-
- /**
* @see UsageLookup::getPagesUsing
*
* @param EntityId[] $entityIds
diff --git a/client/includes/Usage/Sql/SqlUsageTracker.php
b/client/includes/Usage/Sql/SqlUsageTracker.php
index a72aba1..710f929 100644
--- a/client/includes/Usage/Sql/SqlUsageTracker.php
+++ b/client/includes/Usage/Sql/SqlUsageTracker.php
@@ -192,39 +192,6 @@
}
/**
- * @see UsageTracker::removeEntities
- *
- * @param EntityId[] $entityIds
- *
- * @throws UsageTrackerException
- * @throws Exception
- */
- public function removeEntities( array $entityIds ) {
- if ( empty( $entityIds ) ) {
- return;
- }
-
- // NOTE: while logically we'd like the below to be atomic, we
don't wrap it in a
- // transaction to prevent long lock retention during big
updates.
- $db = $this->connectionManager->getWriteConnection();
-
- try {
- $usageTable = $this->newUsageTable( $db );
- $usageTable->removeEntities( $entityIds );
-
- $this->connectionManager->releaseConnection( $db );
- } catch ( Exception $ex ) {
- $this->connectionManager->releaseConnection( $db );
-
- if ( $ex instanceof DBError ) {
- throw new UsageTrackerException(
$ex->getMessage(), $ex->getCode(), $ex );
- } else {
- throw $ex;
- }
- }
- }
-
- /**
* @see UsageLookup::getUsagesForPage
*
* @param int $pageId
diff --git a/client/includes/Usage/UsageTracker.php
b/client/includes/Usage/UsageTracker.php
index b166e95..b593b87 100644
--- a/client/includes/Usage/UsageTracker.php
+++ b/client/includes/Usage/UsageTracker.php
@@ -41,15 +41,4 @@
*/
public function pruneStaleUsages( $pageId, $lastUpdatedBefore );
- /**
- * Removes usage tracking for the given set of entities.
- * This is used typically when entities were deleted.
- * Calling this method more than once on the same entity has no effect.
- *
- * @param EntityId[] $entityIds
- *
- * @throws UsageTrackerException
- */
- public function removeEntities( array $entityIds );
-
}
diff --git a/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableTest.php
b/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableTest.php
index 6cf2ba8..58f7b52 100644
--- a/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableTest.php
+++ b/client/tests/phpunit/includes/Usage/Sql/EntityUsageTableTest.php
@@ -363,35 +363,6 @@
$this->assertUsageTableContains( $rowsT2 );
}
- public function testRemoveEntities() {
- $touched = wfTimestamp( TS_MW );
-
- $q3 = new ItemId( 'Q3' );
- $q4 = new ItemId( 'Q4' );
- $q5 = new ItemId( 'Q5' );
-
- $usages = array(
- new EntityUsage( $q3, EntityUsage::SITELINK_USAGE ),
- new EntityUsage( $q3, EntityUsage::LABEL_USAGE ),
- new EntityUsage( $q4, EntityUsage::LABEL_USAGE ),
- new EntityUsage( $q5, EntityUsage::ALL_USAGE ),
- );
-
- $usageTable = $this->getEntityUsageTable();
- $usageTable->addUsages( 23, $usages, $touched );
-
- $rows = $this->getUsageRows( 23, $usages, $touched );
- $itemsToRemove = array( $q4, $q5 );
-
- $retainedRows = array_intersect_key( $rows, array( 'Q3#S' => 1,
'Q3#L' => 1 ) );
- $removedRows = array_intersect_key( $rows, array( 'Q4#L' => 1,
'Q5#X' => 1 ) );
-
- $usageTable->removeEntities( $itemsToRemove );
-
- $this->assertUsageTableContains( $retainedRows );
- $this->assertUsageTableDoesNotContain( $removedRows );
- }
-
public function testAddTouchUsages_batching() {
$t1 = '20150111000000';
$t2 = '20150222000000';
@@ -409,24 +380,6 @@
// touching more rows than fit into a single batch
$usageTable->touchUsages( 7, $usages, $t2 );
$this->assertUsageTableContains( $rowsT2 );
- }
-
- public function testRemoveEntities_batching() {
- $touched = wfTimestamp( TS_MW );
- $usages = $this->makeUsages( 10 );
- $rows7 = $this->getUsageRows( 7, $usages, $touched );
- $rows8 = $this->getUsageRows( 8, $usages, $touched );
-
- $usageTable = $this->getEntityUsageTable( 3 );
- $usageTable->addUsages( 7, $usages, $touched );
- $usageTable->addUsages( 8, $usages, $touched );
-
- // removing more rows than fit into a single batch
- $entitiesToRemove = array_slice( $this->getItemIds( $usages ),
0, 5 );
- $usageTable->removeEntities( $entitiesToRemove );
-
- $this->assertUsageTableContains( $this->removeRowsForEntities(
$rows7, $entitiesToRemove ) );
- $this->assertUsageTableContains( $this->removeRowsForEntities(
$rows8, $entitiesToRemove ) );
}
public function testGetPagesUsing() {
diff --git a/client/tests/phpunit/includes/Usage/Sql/SqlUsageTrackerTest.php
b/client/tests/phpunit/includes/Usage/Sql/SqlUsageTrackerTest.php
index b3e4af2..48276fb 100644
--- a/client/tests/phpunit/includes/Usage/Sql/SqlUsageTrackerTest.php
+++ b/client/tests/phpunit/includes/Usage/Sql/SqlUsageTrackerTest.php
@@ -73,10 +73,6 @@
$this->trackerTester->testTrackUsedEntities();
}
- public function testRemoveEntities() {
- $this->trackerTester->testRemoveEntities();
- }
-
public function testPruneStaleUsages() {
$this->trackerTester->testPruneStaleUsages();
}
diff --git a/client/tests/phpunit/includes/Usage/UsageTrackerContractTester.php
b/client/tests/phpunit/includes/Usage/UsageTrackerContractTester.php
index fa5039e..2ec69d3 100644
--- a/client/tests/phpunit/includes/Usage/UsageTrackerContractTester.php
+++ b/client/tests/phpunit/includes/Usage/UsageTrackerContractTester.php
@@ -88,32 +88,6 @@
// the provided usage entries will be tracked, and are updated
to the new timestamp.
}
- public function testRemoveEntities() {
- $q3 = new ItemId( 'Q3' );
- $q4 = new ItemId( 'Q4' );
- $q5 = new ItemId( 'Q5' );
-
- $usages = array(
- new EntityUsage( $q3, EntityUsage::SITELINK_USAGE ),
- new EntityUsage( $q3, EntityUsage::LABEL_USAGE, 'de' ),
- new EntityUsage( $q4, EntityUsage::LABEL_USAGE, 'de' ),
- new EntityUsage( $q5, EntityUsage::ALL_USAGE ),
- );
-
- $entitiesToRemove = array( $q3, $q5 );
- $expectedUsage = array(
- new EntityUsage( $q4, EntityUsage::LABEL_USAGE, 'de' ),
- );
-
- $this->tracker->trackUsedEntities( 23, $usages,
'20150102030405' );
- $this->tracker->removeEntities( $entitiesToRemove );
-
- $oldUsages = $this->getUsages( 23, '20150102030405' );
- $this->assertSameUsages( $expectedUsage, $oldUsages );
-
- $this->tracker->trackUsedEntities( 24, array(),
'20150102030405' );
- }
-
public function testPruneStaleUsages() {
$t1 = '20150111000000';
$t2 = '20150222000000';
--
To view, visit https://gerrit.wikimedia.org/r/243699
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id126d968987d2e0aa39539a876276d74a9fe0e70
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits