function wfUndeleteNFD(&$title, $create) { if ($title->getNamespace() != NS_MAIN) { return true; } $article = new Article($title); $revision = Revision::newFromTitle($title); // if an article becomes a redirect, vanquish all previous nfd entries if (preg_match("@^#REDIRECT@", $revision->getText())) { NFDProcessor::markPreviousAsInactive($article->getID()); return true; } // do the templates wfDebug("NFD: Looking for NFD templates\n"); $l = new NFDProcessor($revision, $article); $l->process(); return true; }
public static function checkArticlesInNfdTable() { $dbr = wfGetDB(DB_SLAVE); $count = 0; $results = array(); $res = $dbr->select('nfd', array('nfd_id', 'nfd_page', 'nfd_reason'), array('nfd_patrolled' => '0', "(nfd_status = '" . NFDGuardian::NFD_AVAILABLE . "' OR nfd_status = '" . NFDGuardian::NFD_ADVANCED . "')")); while ($result = $dbr->fetchObject($res)) { $results[] = $result; } foreach ($results as $result) { $t = Title::newFromID($result->nfd_page); if ($t) { $a = new Article($t); /*if($result->nfd_reason == "dup"){ NFDProcessor::markPreviousAsInactive($result->nfd_page); echo "Removing Dup: " . $t->getText() . "\n"; $count++; } else*/ if ($a->isRedirect()) { //check if its a redirect NFDProcessor::markPreviousAsInactive($result->nfd_page); echo "Removing Redirect: " . $t->getText() . "\n"; $count++; } else { //check to see if it still has an NFD tag $revision = Revision::newFromTitle($t); if ($a && $revision) { $l = new NFDProcessor($revision, $a); $l->process(true); } } } else { //title doesn't exist, so remove it from the db NFDProcessor::markPreviousAsInactive($result->nfd_page); echo "Title no longer exists: " . $result->nfd_page . "\n"; $count++; } } //echo "Removed a total of " . $count . " articles from tool.\n"; }