/** * Get the targets of the pending redirects from the database * * Also creates entries in the redirect table for redirects that don't * have one. * @return LinkBatch */ private function getRedirectTargets() { $lb = new LinkBatch(); $db = $this->getDB(); $this->profileDBIn(); $res = $db->select('redirect', array('rd_from', 'rd_namespace', 'rd_fragment', 'rd_interwiki', 'rd_title'), array('rd_from' => array_keys($this->mPendingRedirectIDs)), __METHOD__); $this->profileDBOut(); foreach ($res as $row) { $rdfrom = intval($row->rd_from); $from = $this->mPendingRedirectIDs[$rdfrom]->getPrefixedText(); $to = Title::makeTitle($row->rd_namespace, $row->rd_title, $row->rd_fragment, $row->rd_interwiki); unset($this->mPendingRedirectIDs[$rdfrom]); if (!isset($this->mAllPages[$row->rd_namespace][$row->rd_title])) { $lb->add($row->rd_namespace, $row->rd_title); } $this->mRedirectTitles[$from] = $to; } if ($this->mPendingRedirectIDs) { // We found pages that aren't in the redirect table // Add them foreach ($this->mPendingRedirectIDs as $id => $title) { $article = new Article($title); $rt = $article->insertRedirect(); if (!$rt) { // What the hell. Let's just ignore this continue; } $lb->addObj($rt); $this->mRedirectTitles[$title->getPrefixedText()] = $rt; unset($this->mPendingRedirectIDs[$id]); } } return $lb; }