[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Pass root job params through WikiPageUpdater

2017-09-18 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/375819 )

Change subject: Pass root job params through WikiPageUpdater
..


Pass root job params through WikiPageUpdater

Root job timestamps help with deduplication.

Bug: T173710
Change-Id: I566d2253080a0e8fb74526f33763d23f7ecdadcf
---
M client/includes/ChangeNotificationJob.php
M client/includes/Changes/ChangeHandler.php
M client/includes/Changes/InjectRCRecordsJob.php
M client/includes/Changes/PageUpdater.php
M client/includes/Changes/WikiPageUpdater.php
M client/tests/phpunit/includes/Changes/ChangeHandlerTest.php
M client/tests/phpunit/includes/Changes/InjectRCRecordsJobTest.php
M client/tests/phpunit/includes/Changes/MockPageUpdater.php
M client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
M docs/hooks.txt
M repo/includes/Notifications/JobQueueChangeNotificationSender.php
M 
repo/tests/phpunit/includes/Notifications/JobQueueChangeNotificationSenderTest.php
12 files changed, 360 insertions(+), 68 deletions(-)

Approvals:
  jenkins-bot: Verified
  Thiemo Mättig (WMDE): Looks good to me, approved



diff --git a/client/includes/ChangeNotificationJob.php 
b/client/includes/ChangeNotificationJob.php
index 3822471..2a4fe72 100644
--- a/client/includes/ChangeNotificationJob.php
+++ b/client/includes/ChangeNotificationJob.php
@@ -96,7 +96,7 @@
$changes = $this->getChanges();
 
$changeHandler = $this->getChangeHandler();
-   $changeHandler->handleChanges( $changes );
+   $changeHandler->handleChanges( $changes, 
$this->getRootJobParams() );
 
if ( $changes ) {
/* @var EntityChange $last */
diff --git a/client/includes/Changes/ChangeHandler.php 
b/client/includes/Changes/ChangeHandler.php
index 8d8046d..4ce3e10 100644
--- a/client/includes/Changes/ChangeHandler.php
+++ b/client/includes/Changes/ChangeHandler.php
@@ -75,20 +75,21 @@
 
/**
 * @param EntityChange[] $changes
+* @param array $rootJobParams any relevant root job parameters to be 
inherited by new jobs.
 */
-   public function handleChanges( array $changes ) {
+   public function handleChanges( array $changes, array $rootJobParams = 
[] ) {
$changes = $this->changeRunCoalescer->transformChangeList( 
$changes );
 
-   if ( !Hooks::run( 'WikibaseHandleChanges', [ $changes ] ) ) {
+   if ( !Hooks::run( 'WikibaseHandleChanges', [ $changes, 
$rootJobParams ] ) ) {
return;
}
 
foreach ( $changes as $change ) {
-   if ( !Hooks::run( 'WikibaseHandleChange', [ $change ] ) 
) {
+   if ( !Hooks::run( 'WikibaseHandleChange', [ $change, 
$rootJobParams ] ) ) {
continue;
}
 
-   $this->handleChange( $change );
+   $this->handleChange( $change, $rootJobParams );
}
}
 
@@ -98,10 +99,9 @@
 * @todo: process multiple changes at once!
 *
 * @param EntityChange $change
-*
-* @throws MWException
+* @param array $rootJobParams any relevant root job parameters to be 
inherited by new jobs.
 */
-   public function handleChange( EntityChange $change ) {
+   public function handleChange( EntityChange $change, array 
$rootJobParams = [] ) {
$changeId = $this->getChangeIdForLog( $change );
wfDebugLog( __CLASS__, __FUNCTION__ . ": handling change 
#$changeId"
. ' (' . $change->getType() . ')' );
@@ -116,10 +116,67 @@
 
( new LinkBatch( $titlesToUpdate ) )->execute();
 
-   $this->updater->purgeWebCache( $titlesToUpdate );
-   $this->updater->scheduleRefreshLinks( $titlesToUpdate );
-   $this->updater->injectRCRecords( $titlesToUpdate, $change );
-   // TODO: inject dummy revisions
+   // NOTE: deduplicate
+   $titleBatchSignature = $this->getTitleBatchSignature( 
$titlesToUpdate );
+   $rootJobParams['rootJobSignature'] = $titleBatchSignature;
+
+   if ( !isset( $rootJobParams['rootJobTimestamp'] ) ) {
+   $rootJobParams['rootJobTimestamp'] = wfTimestampNow();
+   }
+
+   $this->updater->purgeWebCache( $titlesToUpdate, $rootJobParams 
);
+   $this->updater->scheduleRefreshLinks( $titlesToUpdate, 
$rootJobParams );
+
+   // NOTE: signature depends on change ID, effectively disabling 
deduplication
+   $changeSignature = $this->getChangeSignature( $change );
+   $rootJobParams['rootJobSignature'] = $titleBatchSignature . '&' 
. $changeSignature;
+   $this->updater->injectRCRecords( $titlesToUpdate, 

[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Pass root job params through WikiPageUpdater

2017-09-04 Thread Daniel Kinzler (Code Review)
Daniel Kinzler has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/375819 )

Change subject: Pass root job params through WikiPageUpdater
..

Pass root job params through WikiPageUpdater

Root job timestamps help with deduplication.

Change-Id: I566d2253080a0e8fb74526f33763d23f7ecdadcf
---
M client/includes/ChangeNotificationJob.php
M client/includes/Changes/ChangeHandler.php
M client/includes/Changes/InjectRCRecordsJob.php
M client/includes/Changes/PageUpdater.php
M client/includes/Changes/WikiPageUpdater.php
M client/tests/phpunit/includes/Changes/MockPageUpdater.php
M docs/hooks.txt
7 files changed, 61 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/19/375819/1

diff --git a/client/includes/ChangeNotificationJob.php 
b/client/includes/ChangeNotificationJob.php
index 3822471..2a4fe72 100644
--- a/client/includes/ChangeNotificationJob.php
+++ b/client/includes/ChangeNotificationJob.php
@@ -96,7 +96,7 @@
$changes = $this->getChanges();
 
$changeHandler = $this->getChangeHandler();
-   $changeHandler->handleChanges( $changes );
+   $changeHandler->handleChanges( $changes, 
$this->getRootJobParams() );
 
if ( $changes ) {
/* @var EntityChange $last */
diff --git a/client/includes/Changes/ChangeHandler.php 
b/client/includes/Changes/ChangeHandler.php
index 8d8046d..ad39923 100644
--- a/client/includes/Changes/ChangeHandler.php
+++ b/client/includes/Changes/ChangeHandler.php
@@ -75,20 +75,21 @@
 
/**
 * @param EntityChange[] $changes
+* @param array $rootJobParams any relevant root job parameters to be 
inherited by new jobs.
 */
-   public function handleChanges( array $changes ) {
+   public function handleChanges( array $changes, array $rootJobParams = 
[] ) {
$changes = $this->changeRunCoalescer->transformChangeList( 
$changes );
 
-   if ( !Hooks::run( 'WikibaseHandleChanges', [ $changes ] ) ) {
+   if ( !Hooks::run( 'WikibaseHandleChanges', [ $changes, 
$rootJobParams ] ) ) {
return;
}
 
foreach ( $changes as $change ) {
-   if ( !Hooks::run( 'WikibaseHandleChange', [ $change ] ) 
) {
+   if ( !Hooks::run( 'WikibaseHandleChange', [ $change, 
$rootJobParams ] ) ) {
continue;
}
 
-   $this->handleChange( $change );
+   $this->handleChange( $change, $rootJobParams );
}
}
 
@@ -98,10 +99,9 @@
 * @todo: process multiple changes at once!
 *
 * @param EntityChange $change
-*
-* @throws MWException
+* @param array $rootJobParams any relevant root job parameters to be 
inherited by new jobs.
 */
-   public function handleChange( EntityChange $change ) {
+   public function handleChange( EntityChange $change, array 
$rootJobParams = [] ) {
$changeId = $this->getChangeIdForLog( $change );
wfDebugLog( __CLASS__, __FUNCTION__ . ": handling change 
#$changeId"
. ' (' . $change->getType() . ')' );
@@ -116,9 +116,9 @@
 
( new LinkBatch( $titlesToUpdate ) )->execute();
 
-   $this->updater->purgeWebCache( $titlesToUpdate );
-   $this->updater->scheduleRefreshLinks( $titlesToUpdate );
-   $this->updater->injectRCRecords( $titlesToUpdate, $change );
+   $this->updater->purgeWebCache( $titlesToUpdate, $rootJobParams 
);
+   $this->updater->scheduleRefreshLinks( $titlesToUpdate, 
$rootJobParams );
+   $this->updater->injectRCRecords( $titlesToUpdate, $change, 
$rootJobParams );
// TODO: inject dummy revisions
}
 
diff --git a/client/includes/Changes/InjectRCRecordsJob.php 
b/client/includes/Changes/InjectRCRecordsJob.php
index d47acb6..2f0a712 100644
--- a/client/includes/Changes/InjectRCRecordsJob.php
+++ b/client/includes/Changes/InjectRCRecordsJob.php
@@ -75,10 +75,15 @@
/**
 * @param Title[] $titles
 * @param EntityChange $change
+* @param array $rootJobParams
 *
 * @return JobSpecification
 */
-   public static function makeJobSpecification( array $titles, 
EntityChange $change ) {
+   public static function makeJobSpecification(
+   array $titles,
+   EntityChange $change,
+   array $rootJobParams = []
+   ) {
$pages = [];
 
foreach ( $titles as $t ) {
@@ -91,10 +96,10 @@
$changeData = $change->getFields();
$changeData['info'] = $change->getSerializedInfo( [ 'changes' ] 
);
 
-