- // Avoid an infinite loop by checking if we have already processed this target
- if (!isset ($this->mAllPages[$row->pl_namespace][$row->pl_title])) {
- $linkBatch->add($row->pl_namespace, $row->pl_title);
- }
- } else {
- // This redirect page has more than one link.
- // This is very slow, but safer until bug 7304 is resolved
- $title = Title :: newFromID($plfrom);
- $titleStrFrom = $title->getPrefixedText();
-
- $article = new Article($title);
- $text = $article->getContent();
- $titleTo = Title :: newFromRedirect($text);
- $titleStrTo = $titleTo->getPrefixedText();
-
- if (is_null($titleStrTo))
- ApiBase :: dieDebug(__METHOD__, 'Bug7304 workaround: redir target from {$title->getPrefixedText()} not found');
-
- // Avoid an infinite loop by checking if we have already processed this target
- if (!isset ($this->mAllPages[$titleTo->getNamespace()][$titleTo->getDBkey()])) {
- $linkBatch->addObj($titleTo);
+ 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;