Instead of trying to duplicate the code to build a LinkBatch while
handling whatever special titles might exist, let's just use
processTitlesArray() to do it for us.
To do it right we also need to add some more deduplication to
processTitlesArray().
Bug: T41492
Change-Id: I28ed0d813a026b64a42b5a2518de9b02a8543aac
private $mMissingPageIDs = [];
private $mRedirectTitles = [];
private $mSpecialTitles = [];
private $mMissingPageIDs = [];
private $mRedirectTitles = [];
private $mSpecialTitles = [];
+ private $mAllSpecials = []; // separate from mAllPages to avoid breaking getAllTitlesByNamespace()
private $mNormalizedTitles = [];
private $mInterwikiTitles = [];
/** @var Title[] */
private $mNormalizedTitles = [];
private $mInterwikiTitles = [];
/** @var Title[] */
* @return LinkBatch
*/
private function getRedirectTargets() {
* @return LinkBatch
*/
private function getRedirectTargets() {
$db = $this->getDB();
$res = $db->select(
$db = $this->getDB();
$res = $db->select(
unset( $this->mPendingRedirectIDs[$rdfrom] );
if ( $to->isExternal() ) {
$this->mInterwikiTitles[$to->getPrefixedText()] = $to->getInterwiki();
unset( $this->mPendingRedirectIDs[$rdfrom] );
if ( $to->isExternal() ) {
$this->mInterwikiTitles[$to->getPrefixedText()] = $to->getInterwiki();
- } elseif ( !isset( $this->mAllPages[$row->rd_namespace][$row->rd_title] ) ) {
- $lb->add( $row->rd_namespace, $row->rd_title );
+ } elseif ( !isset( $this->mAllPages[$to->getNamespace()][$to->getDBkey()] ) ) {
+ $titlesToResolve[] = $to;
}
$this->mRedirectTitles[$from] = $to;
}
}
$this->mRedirectTitles[$from] = $to;
}
// What the hell. Let's just ignore this
continue;
}
// What the hell. Let's just ignore this
continue;
}
+ if ( $rt->isExternal() ) {
+ $this->mInterwikiTitles[$rt->getPrefixedText()] = $rt->getInterwiki();
+ } elseif ( !isset( $this->mAllPages[$rt->getNamespace()][$rt->getDBkey()] ) ) {
+ $titlesToResolve[] = $rt;
+ }
$from = $title->getPrefixedText();
$this->mResolvedRedirectTitles[$from] = $title;
$this->mRedirectTitles[$from] = $rt;
$from = $title->getPrefixedText();
$this->mResolvedRedirectTitles[$from] = $title;
$this->mRedirectTitles[$from] = $rt;
+ return $this->processTitlesArray( $titlesToResolve );
$titleObj = Title::newFromTextThrow( $title, $this->mDefaultNamespace );
} catch ( MalformedTitleException $ex ) {
// Handle invalid titles gracefully
$titleObj = Title::newFromTextThrow( $title, $this->mDefaultNamespace );
} catch ( MalformedTitleException $ex ) {
// Handle invalid titles gracefully
- $this->mAllPages[0][$title] = $this->mFakePageId;
- $this->mInvalidTitles[$this->mFakePageId] = [
- 'title' => $title,
- 'invalidreason' => $this->getErrorFormatter()->formatException( $ex, [ 'bc' => true ] ),
- ];
- $this->mFakePageId--;
+ if ( !isset( $this->mAllPages[0][$title] ) ) {
+ $this->mAllPages[0][$title] = $this->mFakePageId;
+ $this->mInvalidTitles[$this->mFakePageId] = [
+ 'title' => $title,
+ 'invalidreason' => $this->getErrorFormatter()->formatException( $ex, [ 'bc' => true ] ),
+ ];
+ $this->mFakePageId--;
+ }
continue; // There's nothing else we can do
}
} else {
continue; // There's nothing else we can do
}
} else {
if ( $titleObj->getNamespace() < 0 ) {
// Handle Special and Media pages
$titleObj = $titleObj->fixSpecialName();
if ( $titleObj->getNamespace() < 0 ) {
// Handle Special and Media pages
$titleObj = $titleObj->fixSpecialName();
- $this->mSpecialTitles[$this->mFakePageId] = $titleObj;
- $this->mFakePageId--;
+ $ns = $titleObj->getNamespace();
+ $dbkey = $titleObj->getDBkey();
+ if ( !isset( $this->mAllSpecials[$ns][$dbkey] ) ) {
+ $this->mAllSpecials[$ns][$dbkey] = $this->mFakePageId;
+ $this->mSpecialTitles[$this->mFakePageId] = $titleObj;
+ $this->mFakePageId--;
+ }
} else {
// Regular page
$linkBatch->addObj( $titleObj );
} else {
// Regular page
$linkBatch->addObj( $titleObj );