From c583372f958472307346978b8d3dd81242fa07f7 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 13 Jun 2016 11:04:33 -0700 Subject: [PATCH] Track deletion timestamp in LinksDeletionUpdate Use this to prevent deleting new RC entries at the title of page deletion that were created since the deletion. This is useful if an event performs a deletion and makes a new RC entry or if there is high job queue lag. Change-Id: I20f6a4aa0a660a24583c1d71f825b73daa748a24 --- includes/deferred/LinksDeletionUpdate.php | 13 ++++++++++--- includes/jobqueue/jobs/DeleteLinksJob.php | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/includes/deferred/LinksDeletionUpdate.php b/includes/deferred/LinksDeletionUpdate.php index b8bd74722c..260e323569 100644 --- a/includes/deferred/LinksDeletionUpdate.php +++ b/includes/deferred/LinksDeletionUpdate.php @@ -27,13 +27,16 @@ class LinksDeletionUpdate extends SqlDataUpdate implements EnqueueableDataUpdate protected $page; /** @var integer */ protected $pageId; + /** @var string */ + protected $timestamp; /** * @param WikiPage $page Page we are updating * @param integer|null $pageId ID of the page we are updating [optional] + * @param string|null $timestamp TS_MW timestamp of deletion * @throws MWException */ - function __construct( WikiPage $page, $pageId = null ) { + function __construct( WikiPage $page, $pageId = null, $timestamp = null ) { parent::__construct( false ); // no implicit transaction $this->page = $page; @@ -44,6 +47,8 @@ class LinksDeletionUpdate extends SqlDataUpdate implements EnqueueableDataUpdate } else { throw new InvalidArgumentException( "Page ID not known. Page doesn't exist?" ); } + + $this->timestamp = $timestamp ?: wfTimestampNow(); } public function doUpdate() { @@ -135,7 +140,9 @@ class LinksDeletionUpdate extends SqlDataUpdate implements EnqueueableDataUpdate [ 'rc_type != ' . RC_LOG, 'rc_namespace' => $title->getNamespace(), - 'rc_title' => $title->getDBkey() + 'rc_title' => $title->getDBkey(), + 'rc_timestamp < ' . + $this->mDb->addQuotes( $this->mDb->timestamp( $this->timestamp ) ) ], __METHOD__ ); @@ -188,7 +195,7 @@ class LinksDeletionUpdate extends SqlDataUpdate implements EnqueueableDataUpdate 'wiki' => $this->mDb->getWikiID(), 'job' => new JobSpecification( 'deleteLinks', - [ 'pageId' => $this->pageId ], + [ 'pageId' => $this->pageId, 'timestamp' => $this->timestamp ], [ 'removeDuplicates' => true ], $this->page->getTitle() ) diff --git a/includes/jobqueue/jobs/DeleteLinksJob.php b/includes/jobqueue/jobs/DeleteLinksJob.php index e5357cec53..ca5d534f40 100644 --- a/includes/jobqueue/jobs/DeleteLinksJob.php +++ b/includes/jobqueue/jobs/DeleteLinksJob.php @@ -48,8 +48,10 @@ class DeleteLinksJob extends Job { return false; } + $timestamp = isset( $this->params['timestamp'] ) ? $this->params['timestamp'] : null; + $page = WikiPage::factory( $this->title ); // title when deleted - $update = new LinksDeletionUpdate( $page, $pageId ); + $update = new LinksDeletionUpdate( $page, $pageId, $timestamp ); DataUpdate::runUpdates( [ $update ] ); return true; -- 2.20.1