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; }
/** * Merge page histories * * @param integer $id The page_id * @param Title $newTitle The new title * @return bool */ private function mergePage($row, Title $newTitle) { $id = $row->page_id; // Construct the WikiPage object we will need later, while the // page_id still exists. Note that this cannot use makeTitleSafe(), // we are deliberately constructing an invalid title. $sourceTitle = Title::makeTitle($row->page_namespace, $row->page_title); $sourceTitle->resetArticleID($id); $wikiPage = new WikiPage($sourceTitle); $wikiPage->loadPageData('fromdbmaster'); $destId = $newTitle->getArticleId(); $this->beginTransaction($this->db, __METHOD__); $this->db->update('revision', array('rev_page' => $destId), array('rev_page' => $id), __METHOD__); $this->db->delete('page', array('page_id' => $id), __METHOD__); /* Call LinksDeletionUpdate to delete outgoing links from the old title, * and update category counts. * * Calling external code with a fake broken Title is a fairly dubious * idea. It's necessary because it's quite a lot of code to duplicate, * but that also makes it fragile since it would be easy for someone to * accidentally introduce an assumption of title validity to the code we * are calling. */ $update = new LinksDeletionUpdate($wikiPage); $update->doUpdate(); $this->commitTransaction($this->db, __METHOD__); return true; }