X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/jobqueue/jobs/DeleteLinksJob.php diff --git a/includes/jobqueue/jobs/DeleteLinksJob.php b/includes/jobqueue/jobs/DeleteLinksJob.php new file mode 100644 index 00000000..5c0f89f7 --- /dev/null +++ b/includes/jobqueue/jobs/DeleteLinksJob.php @@ -0,0 +1,66 @@ +removeDuplicates = true; + } + + function run() { + if ( is_null( $this->title ) ) { + $this->setLastError( "deleteLinks: Invalid title" ); + return false; + } + + $pageId = $this->params['pageId']; + + // Serialize links updates by page ID so they see each others' changes + $scopedLock = LinksUpdate::acquirePageLock( wfGetDB( DB_MASTER ), $pageId, 'job' ); + + if ( WikiPage::newFromID( $pageId, WikiPage::READ_LATEST ) ) { + // The page was restored somehow or something went wrong + $this->setLastError( "deleteLinks: Page #$pageId exists" ); + return false; + } + + $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + $timestamp = isset( $this->params['timestamp'] ) ? $this->params['timestamp'] : null; + $page = WikiPage::factory( $this->title ); // title when deleted + + $update = new LinksDeletionUpdate( $page, $pageId, $timestamp ); + $update->setTransactionTicket( $factory->getEmptyTransactionTicket( __METHOD__ ) ); + $update->doUpdate(); + + return true; + } +}