From: jenkins-bot Date: Thu, 9 Nov 2017 22:33:48 +0000 (+0000) Subject: Merge "Add action/user tracking to html cache purge jobs" X-Git-Tag: 1.31.0-rc.0~1560 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=b5370206ff602728c08403f14756d4339bf0a708;hp=3deafe350309a6f85bef66ce7d3f043972714c1c Merge "Add action/user tracking to html cache purge jobs" --- diff --git a/includes/Title.php b/includes/Title.php index d043b442ac..829be448b2 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4622,9 +4622,11 @@ class Title implements LinkTarget { * on the number of links. Typically called on create and delete. */ public function touchLinks() { - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'pagelinks' ) ); + DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'pagelinks', 'page-touch' ) ); if ( $this->getNamespace() == NS_CATEGORY ) { - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'categorylinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $this, 'categorylinks', 'category-touch' ) + ); } } diff --git a/includes/deferred/HTMLCacheUpdate.php b/includes/deferred/HTMLCacheUpdate.php index db3790f7d3..29846bfb77 100644 --- a/includes/deferred/HTMLCacheUpdate.php +++ b/includes/deferred/HTMLCacheUpdate.php @@ -26,7 +26,7 @@ * * @ingroup Cache */ -class HTMLCacheUpdate implements DeferrableUpdate { +class HTMLCacheUpdate extends DataUpdate { /** @var Title */ public $mTitle; @@ -36,14 +36,24 @@ class HTMLCacheUpdate implements DeferrableUpdate { /** * @param Title $titleTo * @param string $table + * @param string $causeAction Triggering action + * @param string $causeAgent Triggering user */ - function __construct( Title $titleTo, $table ) { + function __construct( + Title $titleTo, $table, $causeAction = 'unknown', $causeAgent = 'unknown' + ) { $this->mTitle = $titleTo; $this->mTable = $table; + $this->causeAction = $causeAction; + $this->causeAgent = $causeAgent; } public function doUpdate() { - $job = HTMLCacheUpdateJob::newForBacklinks( $this->mTitle, $this->mTable ); + $job = HTMLCacheUpdateJob::newForBacklinks( + $this->mTitle, + $this->mTable, + [ 'causeAction' => $this->getCauseAction(), 'causeAgent' => $this->getCauseAgent() ] + ); JobQueueGroup::singleton()->lazyPush( $job ); } diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php index c27826d50d..8913642891 100644 --- a/includes/deferred/LinksUpdate.php +++ b/includes/deferred/LinksUpdate.php @@ -1055,7 +1055,9 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { $inv = [ $inv ]; } foreach ( $inv as $table ) { - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, $table ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $this->mTitle, $table, 'page-props' ) + ); } } } diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 32f4504ba6..54bd0a586f 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -1445,7 +1445,9 @@ abstract class File implements IDBAccessObject { // Purge cache of all pages using this file $title = $this->getTitle(); if ( $title ) { - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $title, 'imagelinks', 'file-purge' ) + ); } } diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 44c90af347..bb12515056 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1740,7 +1740,9 @@ class LocalFile extends File { } # Invalidate cache for all pages using this file - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $this->getTitle(), 'imagelinks', 'file-upload' ) + ); return Status::newGood(); } diff --git a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php index 4d75cb303c..34028df172 100644 --- a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php +++ b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php @@ -47,14 +47,16 @@ class HTMLCacheUpdateJob extends Job { // Multiple pages per job make matches unlikely !( isset( $params['pages'] ) && count( $params['pages'] ) != 1 ) ); + $this->params += [ 'causeAction' => 'unknown', 'causeAgent' => 'unknown' ]; } /** * @param Title $title Title to purge backlink pages from * @param string $table Backlink table name + * @param array $params Additional job parameters * @return HTMLCacheUpdateJob */ - public static function newForBacklinks( Title $title, $table ) { + public static function newForBacklinks( Title $title, $table, $params = [] ) { return new self( $title, [ @@ -62,7 +64,7 @@ class HTMLCacheUpdateJob extends Job { 'recursive' => true ] + Job::newRootJobParams( // "overall" refresh links job info "htmlCacheUpdate:{$table}:{$title->getPrefixedText()}" - ) + ) + $params ); } @@ -75,6 +77,11 @@ class HTMLCacheUpdateJob extends Job { // Job to purge all (or a range of) backlink pages for a page if ( !empty( $this->params['recursive'] ) ) { + // Carry over information for de-duplication + $extraParams = $this->getRootJobParams(); + // Carry over cause information for logging + $extraParams['causeAction'] = $this->params['causeAction']; + $extraParams['causeAgent'] = $this->params['causeAgent']; // Convert this into no more than $wgUpdateRowsPerJob HTMLCacheUpdateJob per-title // jobs and possibly a recursive HTMLCacheUpdateJob job for the rest of the backlinks $jobs = BacklinkJobUtils::partitionBacklinkJob( @@ -82,7 +89,7 @@ class HTMLCacheUpdateJob extends Job { $wgUpdateRowsPerJob, $wgUpdateRowsPerQuery, // jobs-per-title // Carry over information for de-duplication - [ 'params' => $this->getRootJobParams() ] + [ 'params' => $extraParams ] ); JobQueueGroup::singleton()->push( $jobs ); // Job to purge pages for a set of titles diff --git a/includes/page/PageArchive.php b/includes/page/PageArchive.php index 209551b296..c03d6b21d6 100644 --- a/includes/page/PageArchive.php +++ b/includes/page/PageArchive.php @@ -764,7 +764,9 @@ class PageArchive { Hooks::run( 'ArticleUndelete', [ &$this->title, $created, $comment, $oldPageId, $restoredPages ] ); if ( $this->title->getNamespace() == NS_FILE ) { - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->title, 'imagelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $this->title, 'imagelinks', 'file-restore' ) + ); } } diff --git a/includes/page/WikiFilePage.php b/includes/page/WikiFilePage.php index 972a397c5e..4c2ebdc297 100644 --- a/includes/page/WikiFilePage.php +++ b/includes/page/WikiFilePage.php @@ -173,7 +173,9 @@ class WikiFilePage extends WikiPage { if ( $this->mFile->exists() ) { wfDebug( 'ImagePage::doPurge purging ' . $this->mFile->getName() . "\n" ); - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, 'imagelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $this->mTitle, 'imagelinks', 'file-purge' ) + ); } 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 95b7be265e..8b349288fe 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -3317,7 +3317,9 @@ class WikiPage implements Page, IDBAccessObject { MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title ); // Invalidate caches of articles which include this page - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'templatelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $title, 'templatelinks', 'page-create' ) + ); if ( $title->getNamespace() == NS_CATEGORY ) { // Load the Category object, which will schedule a job to create @@ -3355,7 +3357,9 @@ class WikiPage implements Page, IDBAccessObject { // Images if ( $title->getNamespace() == NS_FILE ) { - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $title, 'imagelinks', 'page-delete' ) + ); } // User talk pages @@ -3378,10 +3382,14 @@ class WikiPage implements Page, IDBAccessObject { */ public static function onArticleEdit( Title $title, Revision $revision = null ) { // Invalidate caches of articles which include this page - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'templatelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $title, 'templatelinks', 'page-edit' ) + ); // Invalidate the caches of all pages which redirect here - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'redirect' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $title, 'redirect', 'page-edit' ) + ); MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title );