jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/387304 )

Change subject: Add action/user tracking to html cache purge jobs
......................................................................


Add action/user tracking to html cache purge jobs

Change-Id: Ic7155a7303debfaf26b13cb836497ccbc89ea238
---
M includes/Title.php
M includes/deferred/HTMLCacheUpdate.php
M includes/deferred/LinksUpdate.php
M includes/filerepo/file/File.php
M includes/filerepo/file/LocalFile.php
M includes/jobqueue/jobs/HTMLCacheUpdateJob.php
M includes/page/PageArchive.php
M includes/page/WikiFilePage.php
M includes/page/WikiPage.php
9 files changed, 54 insertions(+), 17 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Title.php b/includes/Title.php
index 718239d..90ae57d 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -4619,9 +4619,11 @@
         * 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 db3790f..29846bf 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 @@
        /**
         * @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 c27826d..8913642 100644
--- a/includes/deferred/LinksUpdate.php
+++ b/includes/deferred/LinksUpdate.php
@@ -1055,7 +1055,9 @@
                                        $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 32f4504..54bd0a5 100644
--- a/includes/filerepo/file/File.php
+++ b/includes/filerepo/file/File.php
@@ -1445,7 +1445,9 @@
                // 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 3271c96..455d6ae 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1666,7 +1666,9 @@
                }
 
                # 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 4d75cb3..34028df 100644
--- a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
+++ b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
@@ -47,14 +47,16 @@
                        // 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 @@
                                'recursive' => true
                        ] + Job::newRootJobParams( // "overall" refresh links 
job info
                                
"htmlCacheUpdate:{$table}:{$title->getPrefixedText()}"
-                       )
+                       ) + $params
                );
        }
 
@@ -75,6 +77,11 @@
 
                // 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 @@
                                $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 af936cc..c134b9d 100644
--- a/includes/page/PageArchive.php
+++ b/includes/page/PageArchive.php
@@ -785,7 +785,9 @@
                        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 972a397..4c2ebdc 100644
--- a/includes/page/WikiFilePage.php
+++ b/includes/page/WikiFilePage.php
@@ -173,7 +173,9 @@
 
                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 146c054..2428fc7 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -3264,7 +3264,9 @@
                
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
@@ -3302,7 +3304,9 @@
 
                // Images
                if ( $title->getNamespace() == NS_FILE ) {
-                       DeferredUpdates::addUpdate( new HTMLCacheUpdate( 
$title, 'imagelinks' ) );
+                       DeferredUpdates::addUpdate(
+                               new HTMLCacheUpdate( $title, 'imagelinks', 
'page-delete' )
+                       );
                }
 
                // User talk pages
@@ -3325,10 +3329,14 @@
         */
        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 );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/387304
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic7155a7303debfaf26b13cb836497ccbc89ea238
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to