MediaWiki REL1_31
DeleteLinksJob.php
Go to the documentation of this file.
1<?php
25
34class DeleteLinksJob extends Job {
35 function __construct( Title $title, array $params ) {
36 parent::__construct( 'deleteLinks', $title, $params );
37 $this->removeDuplicates = true;
38 }
39
40 function run() {
41 if ( is_null( $this->title ) ) {
42 $this->setLastError( "deleteLinks: Invalid title" );
43 return false;
44 }
45
46 $pageId = $this->params['pageId'];
47
48 // Serialize links updates by page ID so they see each others' changes
49 $scopedLock = LinksUpdate::acquirePageLock( wfGetDB( DB_MASTER ), $pageId, 'job' );
50
51 if ( WikiPage::newFromID( $pageId, WikiPage::READ_LATEST ) ) {
52 // The page was restored somehow or something went wrong
53 $this->setLastError( "deleteLinks: Page #$pageId exists" );
54 return false;
55 }
56
57 $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
58 $timestamp = isset( $this->params['timestamp'] ) ? $this->params['timestamp'] : null;
59 $page = WikiPage::factory( $this->title ); // title when deleted
60
61 $update = new LinksDeletionUpdate( $page, $pageId, $timestamp );
62 $update->setTransactionTicket( $factory->getEmptyTransactionTicket( __METHOD__ ) );
63 $update->doUpdate();
64
65 return true;
66 }
67}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Job to prune link tables for pages that were deleted.
__construct(Title $title, array $params)
run()
Run the job.
Class to both describe a background job and handle jobs.
Definition Job.php:31
setLastError( $error)
Definition Job.php:419
array $params
Array of job parameters.
Definition Job.php:36
Update object handling the cleanup of links tables after a page was deleted.
static acquirePageLock(IDatabase $dbw, $pageId, $why='atomicity')
Acquire a lock for performing link table updates for a page on a DB.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Represents a title within MediaWiki.
Definition Title.php:39
const DB_MASTER
Definition defines.php:29