From 6ee2816e281f51d382032ce2965987758e61b4ba Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 11 Sep 2019 15:15:17 -0700 Subject: [PATCH] Make PageArchive/WikiPage CDN purges use JobQueueGroup::lazyPush() in one batch Change-Id: I1fd19ebee1cfe1c94cab3e8fe40824d9723573da --- includes/page/PageArchive.php | 8 ++++++-- includes/page/WikiFilePage.php | 7 +++++-- includes/page/WikiPage.php | 32 +++++++++++++++++++++----------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/includes/page/PageArchive.php b/includes/page/PageArchive.php index 40c63d22e4..8b2ff6bca8 100644 --- a/includes/page/PageArchive.php +++ b/includes/page/PageArchive.php @@ -756,10 +756,14 @@ class PageArchive { Hooks::run( 'ArticleUndelete', [ &$this->title, $created, $comment, $oldPageId, $restoredPages ] ); + if ( $this->title->getNamespace() == NS_FILE ) { - DeferredUpdates::addUpdate( - new HTMLCacheUpdate( $this->title, 'imagelinks', 'file-restore' ) + $job = HTMLCacheUpdateJob::newForBacklinks( + $this->title, + 'imagelinks', + [ 'causeAction' => 'file-restore' ] ); + JobQueueGroup::singleton()->lazyPush( $job ); } } diff --git a/includes/page/WikiFilePage.php b/includes/page/WikiFilePage.php index acd506ba79..fd9f7b24d8 100644 --- a/includes/page/WikiFilePage.php +++ b/includes/page/WikiFilePage.php @@ -176,9 +176,12 @@ class WikiFilePage extends WikiPage { if ( $this->mFile->exists() ) { wfDebug( 'ImagePage::doPurge purging ' . $this->mFile->getName() . "\n" ); - DeferredUpdates::addUpdate( - new HTMLCacheUpdate( $this->mTitle, 'imagelinks', 'file-purge' ) + $job = HTMLCacheUpdateJob::newForBacklinks( + $this->mTitle, + 'imagelinks', + [ 'causeAction' => 'file-purge' ] ); + JobQueueGroup::singleton()->lazyPush( $job ); } else { wfDebug( 'ImagePage::doPurge no image for ' . $this->mFile->getName() . "; limiting purge to cache only\n" ); diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index bad75da4fb..9f53092ea7 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -3407,9 +3407,12 @@ class WikiPage implements Page, IDBAccessObject { MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title ); // Invalidate caches of articles which include this page - DeferredUpdates::addUpdate( - new HTMLCacheUpdate( $title, 'templatelinks', 'page-create' ) + $job = HTMLCacheUpdateJob::newForBacklinks( + $title, + 'templatelinks', + [ 'causeAction' => 'page-create' ] ); + JobQueueGroup::singleton()->lazyPush( $job ); if ( $title->getNamespace() == NS_CATEGORY ) { // Load the Category object, which will schedule a job to create @@ -3451,9 +3454,12 @@ class WikiPage implements Page, IDBAccessObject { // Images if ( $title->getNamespace() == NS_FILE ) { - DeferredUpdates::addUpdate( - new HTMLCacheUpdate( $title, 'imagelinks', 'page-delete' ) + $job = HTMLCacheUpdateJob::newForBacklinks( + $title, + 'imagelinks', + [ 'causeAction' => 'page-delete' ] ); + JobQueueGroup::singleton()->lazyPush( $job ); } // User talk pages @@ -3485,20 +3491,24 @@ class WikiPage implements Page, IDBAccessObject { $slotsChanged = null ) { // TODO: move this into a PageEventEmitter service - - if ( $slotsChanged === null || in_array( SlotRecord::MAIN, $slotsChanged ) ) { + $jobs = []; + if ( $slotsChanged === null || in_array( SlotRecord::MAIN, $slotsChanged ) ) { // Invalidate caches of articles which include this page. // Only for the main slot, because only the main slot is transcluded. // TODO: MCR: not true for TemplateStyles! [SlotHandler] - DeferredUpdates::addUpdate( - new HTMLCacheUpdate( $title, 'templatelinks', 'page-edit' ) + $jobs[] = HTMLCacheUpdateJob::newForBacklinks( + $title, + 'templatelinks', + [ 'causeAction' => 'page-edit' ] ); } - // Invalidate the caches of all pages which redirect here - DeferredUpdates::addUpdate( - new HTMLCacheUpdate( $title, 'redirect', 'page-edit' ) + $jobs[] = HTMLCacheUpdateJob::newForBacklinks( + $title, + 'redirect', + [ 'causeAction' => 'page-edit' ] ); + JobQueueGroup::singleton()->lazyPush( $jobs ); MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title ); -- 2.20.1