/** * Back-end article deletion * Deletes the article with database consistency, writes logs, purges caches * Returns success */ function doDeleteArticle($reason, $rc = true) { global $wgUseSquid, $wgDeferredUpdateList; global $wgPostCommitUpdateList, $wgUseTrackbacks; wfDebug(__METHOD__ . "\n"); $dbw =& wfGetDB(DB_MASTER); $ns = $this->mTitle->getNamespace(); $t = $this->mTitle->getDBkey(); $id = $this->mTitle->getArticleID(); if ($t == '' || $id == 0) { return false; } $u = new SiteStatsUpdate(0, 1, -(int) $this->isCountable($this->getContent()), -1); array_push($wgDeferredUpdateList, $u); // For now, shunt the revision data into the archive table. // Text is *not* removed from the text table; bulk storage // is left intact to avoid breaking block-compression or // immutable storage schemes. // // For backwards compatibility, note that some older archive // table entries will have ar_text and ar_flags fields still. // // In the future, we may keep revisions and mark them with // the rev_deleted field, which is reserved for this purpose. $dbw->insertSelect('archive', array('page', 'revision'), array('ar_namespace' => 'page_namespace', 'ar_title' => 'page_title', 'ar_comment' => 'rev_comment', 'ar_user' => 'rev_user', 'ar_user_text' => 'rev_user_text', 'ar_timestamp' => 'rev_timestamp', 'ar_minor_edit' => 'rev_minor_edit', 'ar_rev_id' => 'rev_id', 'ar_text_id' => 'rev_text_id'), array('page_id' => $id, 'page_id = rev_page'), __METHOD__); # Now that it's safely backed up, delete it $dbw->delete('revision', array('rev_page' => $id), __METHOD__); $dbw->delete('page', array('page_id' => $id), __METHOD__); if ($wgUseTrackbacks) { $dbw->delete('trackbacks', array('tb_page' => $id), __METHOD__); } # Clean up recentchanges entries... $dbw->delete('recentchanges', array('rc_namespace' => $ns, 'rc_title' => $t), __METHOD__); // WERELATE: remove from watchlists on delete if (Namespac::isMain($ns)) { $rows = $dbw->select(array('watchlist', 'user'), array('user_name'), array('wl_user=user_id', 'wl_namespace' => $ns, 'wl_title' => $t)); while ($row = $dbw->fetchObject($rows)) { $user = User::newFromName($row->user_name, false); $wl = WatchedItem::fromUserTitle($user, $this->mTitle); $wl->removeWatch(); } $dbw->freeResult($rows); } # Finally, clean up the link tables $t = $this->mTitle->getPrefixedDBkey(); # Clear caches Article::onArticleDelete($this->mTitle); # Delete outgoing links $dbw->delete('pagelinks', array('pl_from' => $id)); $dbw->delete('imagelinks', array('il_from' => $id)); $dbw->delete('categorylinks', array('cl_from' => $id)); $dbw->delete('templatelinks', array('tl_from' => $id)); $dbw->delete('externallinks', array('el_from' => $id)); $dbw->delete('langlinks', array('ll_from' => $id)); # Log the deletion $log = new LogPage('delete', $rc); // WERELATE - add id as a log param $log->addEntry('delete', $this->mTitle, $reason, array($id)); # Clear the cached article id so the interface doesn't act like we exist $this->mTitle->resetArticleID(0); $this->mTitle->mArticleID = 0; return true; }
/** * If the namespace isn't listed on the priority list return the * default priority for the namespace, varies depending on whether it's * a talkpage or not. * * @param int $namespace The namespace to get the priority for * * @return string */ function guessPriority($namespace) { return Namespac::isMain($namespace) ? $this->priorities[GS_MAIN] : $this->priorities[GS_TALK]; }