Daniel Kinzler has uploaded a new change for review.
https://gerrit.wikimedia.org/r/217007
Change subject: Fix bad touch timestamp when LinksUpdateComplete is called via
the JobQueue.
......................................................................
Fix bad touch timestamp when LinksUpdateComplete is called via the JobQueue.
Change-Id: Ia95e9bf60a631b411ffd0e47b9c65302b3f5512f
---
M client/includes/Hooks/DataUpdateHookHandlers.php
M client/tests/phpunit/includes/Usage/UsageTrackingIntegrationTest.php
2 files changed, 23 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/07/217007/1
diff --git a/client/includes/Hooks/DataUpdateHookHandlers.php
b/client/includes/Hooks/DataUpdateHookHandlers.php
index 06998e7..fcf24e4 100644
--- a/client/includes/Hooks/DataUpdateHookHandlers.php
+++ b/client/includes/Hooks/DataUpdateHookHandlers.php
@@ -5,6 +5,7 @@
use Content;
use LinksUpdate;
use ManualLogEntry;
+use RuntimeException;
use User;
use Wikibase\Client\Store\UsageUpdater;
use Wikibase\Client\Usage\ParserOutputUsageAccumulator;
@@ -104,9 +105,13 @@
$parserOutput = $linksUpdate->getParserOutput();
$usageAcc = new ParserOutputUsageAccumulator( $parserOutput );
- // The parser output should tell us when it was parsed. If not,
ask the Title object.
- // These timestamps should usually be the same, but asking
$title may cause a database query.
- $touched = $parserOutput->getTimestamp() ?:
$title->getTouched();
+ // For now, use the current timestamp as the touch date.
+ // $parserOutput->getTimestamp() sounds good, but is documented
as "timestamp of the revision",
+ // which is not what we want. $title->getTouched() sounds good,
but it may not have been
+ // updated reflecting the current run of LinksUpdate yet. Since
on LinksUpdateComplete we
+ // actually want to purge all old tracking entries and only
care about keeping the ones
+ // now present in $parserOutput, using the current timestamp
should be fine.
+ $touched = wfTimestampNow();
// Add or touch any usages present in the new revision
$this->usageUpdater->addUsagesForPage(
diff --git
a/client/tests/phpunit/includes/Usage/UsageTrackingIntegrationTest.php
b/client/tests/phpunit/includes/Usage/UsageTrackingIntegrationTest.php
index ac33983..e0ecda6 100644
--- a/client/tests/phpunit/includes/Usage/UsageTrackingIntegrationTest.php
+++ b/client/tests/phpunit/includes/Usage/UsageTrackingIntegrationTest.php
@@ -55,8 +55,8 @@
$runner->run( array(
'type' => false,
- 'maxJobs' => 20,
- 'maxTime' => 20,
+ 'maxJobs' => false,
+ 'maxTime' => false,
'throttle' => false,
) );
}
@@ -133,11 +133,19 @@
$this->assertTrackedUsages( $expected, $this->articleTitle );
}
+ private function waitForNextTimestamp() {
+ $timestamp = wfTimestampNow();
+
+ while ( ( $now = wfTimestampNow() ) === $timestamp ) {
+ usleep( 100 * 1000 );
+ }
+ }
+
/**
* @depends testUpdateUsageOnCreation
*/
public function testUpdateUsageOnEdit() {
- sleep( 1 ); // make sure we don't get the same timestamp as the
edit before!
+ $this->waitForNextTimestamp(); // make sure we don't get the
same timestamp as the edit before!
// Create the template we'll use below.
$text = "{{#property:P2|from=Q22}}\n";
@@ -162,14 +170,15 @@
* @depends testUpdateUsageOnEdit
*/
public function testUpdateUsageOnTemplateChange() {
- sleep(1); // Make sure we don't get the same timestamp as the
edit before!
+ $this->waitForNextTimestamp(); // Make sure we don't get the
same timestamp as the edit before!
// Assume the state created by testUpdateUsageOnEdit().
// Change the template to use Q33.
$text = "{{#property:P3|from=Q33}}\n";
+
$this->updatePage( $this->templateTitle, $text );
- // Check that Q33, now used by the template, is tracked.
+ // Check that Q33, now used via the template, is tracked.
// Check that Q22 is no longer tracked, due to timestamp-based
pruning.
$expected = array(
new EntityUsage( new ItemId( 'Q33' ),
EntityUsage::OTHER_USAGE ),
@@ -182,7 +191,7 @@
* @depends testUpdateUsageOnTemplateChange
*/
public function testUpdateUsageOnDelete() {
- sleep(1); // make sure we don't get the same timestamp as the
edit before!
+ $this->waitForNextTimestamp(); // make sure we don't get the
same timestamp as the edit before!
// Assume the state created by
testUpdateUsageOnTemplateChange().
// Delete the page.
--
To view, visit https://gerrit.wikimedia.org/r/217007
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia95e9bf60a631b411ffd0e47b9c65302b3f5512f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits