jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/390339 )
Change subject: Add cause action/agent tracking to html purge jobs
......................................................................
Add cause action/agent tracking to html purge jobs
Also made scheduleRefreshLinks() use array_merge.
Change-Id: I7f4b9a227b04a87f17d37dffc56f7b2eb6a02fcf
---
M client/includes/Changes/ChangeHandler.php
M client/includes/Changes/PageUpdater.php
M client/includes/Changes/WikiPageUpdater.php
M client/tests/phpunit/includes/Changes/MockPageUpdater.php
M client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
5 files changed, 38 insertions(+), 8 deletions(-)
Approvals:
jenkins-bot: Verified
Thiemo Mättig (WMDE): Looks good to me, approved
diff --git a/client/includes/Changes/ChangeHandler.php
b/client/includes/Changes/ChangeHandler.php
index e9c34ff..4580910 100644
--- a/client/includes/Changes/ChangeHandler.php
+++ b/client/includes/Changes/ChangeHandler.php
@@ -135,7 +135,12 @@
$rootJobParams['rootJobTimestamp'] = wfTimestampNow();
}
- $this->updater->purgeWebCache( $titlesToUpdate, $rootJobParams
);
+ $this->updater->purgeWebCache(
+ $titlesToUpdate,
+ $rootJobParams,
+ $change->getAction(),
+ $change->hasField( 'user_id' ) ? 'uid:' .
$change->getUserId() : 'uid:?'
+ );
$this->updater->scheduleRefreshLinks(
$titlesToUpdate,
$rootJobParams,
diff --git a/client/includes/Changes/PageUpdater.php
b/client/includes/Changes/PageUpdater.php
index 8d1019d..22ded29 100644
--- a/client/includes/Changes/PageUpdater.php
+++ b/client/includes/Changes/PageUpdater.php
@@ -21,8 +21,15 @@
*
* @param Title[] $titles The Titles of the pages to update
* @param array $rootJobParams any relevant root job parameters to be
inherited by new jobs.
+ * @param string $causeAction Triggering action
+ * @param string $causeAgent Triggering agent
*/
- public function purgeWebCache( array $titles, array $rootJobParams = []
);
+ public function purgeWebCache(
+ array $titles,
+ array $rootJobParams,
+ $causeAction,
+ $causeAgent
+ );
/**
* Schedules RefreshLinks jobs for the given titles
diff --git a/client/includes/Changes/WikiPageUpdater.php
b/client/includes/Changes/WikiPageUpdater.php
index b4f5f0f..0814a91 100644
--- a/client/includes/Changes/WikiPageUpdater.php
+++ b/client/includes/Changes/WikiPageUpdater.php
@@ -142,8 +142,15 @@
*
* @param Title[] $titles The Titles of the pages to update
* @param array $rootJobParams
+ * @param string $causeAction Triggering action
+ * @param string $causeAgent Triggering agent
*/
- public function purgeWebCache( array $titles, array $rootJobParams = []
) {
+ public function purgeWebCache(
+ array $titles,
+ array $rootJobParams,
+ $causeAction,
+ $causeAgent
+ ) {
if ( $titles === [] ) {
return;
}
@@ -152,6 +159,7 @@
$titleBatches = array_chunk( $titles,
$this->purgeCacheBatchSize );
$dummyTitle = Title::makeTitle( NS_SPECIAL, 'Badtitle/' .
__CLASS__ );
+ $cause = [ 'causeAction' => $causeAction, 'causeAgent' =>
$causeAgent ];
/* @var Title[] $batch */
foreach ( $titleBatches as $batch ) {
wfDebugLog( __CLASS__, __FUNCTION__ . ": scheduling
HTMLCacheUpdateJob for "
@@ -159,7 +167,7 @@
$jobs[] = new HTMLCacheUpdateJob(
$dummyTitle, // the title will be ignored
because the 'pages' parameter is set.
- $this->buildJobParams( $batch, $rootJobParams )
+ array_merge( $this->buildJobParams( $batch,
$rootJobParams ), $cause )
);
}
@@ -194,7 +202,7 @@
$cause = [ 'causeAction' => $causeAction, 'causeAgent' =>
$causeAgent ];
foreach ( $titles as $title ) {
$this->jobQueueGroup->lazyPush(
- new RefreshLinksJob( $title, $rootJobParams +
$cause )
+ new RefreshLinksJob( $title, array_merge(
$rootJobParams, $cause ) )
);
}
diff --git a/client/tests/phpunit/includes/Changes/MockPageUpdater.php
b/client/tests/phpunit/includes/Changes/MockPageUpdater.php
index 99cfeac..6904948 100644
--- a/client/tests/phpunit/includes/Changes/MockPageUpdater.php
+++ b/client/tests/phpunit/includes/Changes/MockPageUpdater.php
@@ -38,8 +38,15 @@
/**
* @param Title[] $titles
* @param array $rootJobParams
+ * @param string $causeAction
+ * @param string $causeAgent
*/
- public function purgeWebCache( array $titles, array $rootJobParams = []
) {
+ public function purgeWebCache(
+ array $titles,
+ array $rootJobParams,
+ $causeAction,
+ $causeAgent
+ ) {
foreach ( $titles as $title ) {
$key = $title->getPrefixedDBkey();
$this->updates['purgeWebCache'][ $key ] = $title;
diff --git a/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
b/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
index 63e3e79..6f32a13 100644
--- a/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
+++ b/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
@@ -176,7 +176,10 @@
], [
'rootJobTimestamp' => '20202211060708',
'rootJobSignature' => 'Kittens!',
- ] );
+ ],
+ 'test~action',
+ 'uid:1'
+ );
$this->assertEquals( [ 21, 22, 23 ], array_keys( $pages ) );
$this->assertEquals( [ 0, 'Foo' ], $pages[21], '$pages[21]' );
@@ -231,7 +234,7 @@
'rootJobSignature' => 'Kittens!',
],
'test~action',
- 'uid:Tests'
+ 'uid:1'
);
$this->assertEquals( [ 21, 22, 23 ], array_keys( $pages ) );
--
To view, visit https://gerrit.wikimedia.org/r/390339
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7f4b9a227b04a87f17d37dffc56f7b2eb6a02fcf
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits