From 84e2e2ff13dd257d9f72fb1defb939696626321a Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 3 Jun 2005 05:46:24 +0000 Subject: [PATCH] * (bug 2130) Fixed interwiki links with fragments --- RELEASE-NOTES | 1 + includes/Parser.php | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d448708b2b..4cac32b865 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -238,6 +238,7 @@ Various bugfixes, small features, and a few experimental things: * (bug 2274) Respect stub threshold in category page list * (bug 2173) Fatal error when removing an article with an empty title from the watchlist * Removed -f parameter from mail() usage, likely to cause failures and bounces. +* (bug 2130) Fixed interwiki links with fragments === Caveats === diff --git a/includes/Parser.php b/includes/Parser.php index c2860034f9..7d32701bcc 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -140,7 +140,10 @@ class Parser $this->mStripState = array(); $this->mArgStack = array(); $this->mInPre = false; - $this->mInterwikiLinkHolders = array(); + $this->mInterwikiLinkHolders = array( + 'texts' => array(), + 'titles' => array() + ); $this->mLinkHolders = array( 'namespaces' => array(), 'dbkeys' => array(), @@ -1423,8 +1426,8 @@ class Parser list( $inside, $trail ) = Linker::splitTrail( $trail ); if ( $nt->isExternal() ) { - $iwRecord = array( $nt->getPrefixedDBkey(), $prefix.$text.$inside ); - $nr = array_push($this->mInterwikiLinkHolders, $iwRecord); + $nr = array_push( $this->mInterwikiLinkHolders['texts'], $prefix.$text.$inside ); + $this->mInterwikiLinkHolders['titles'][] =& $nt; $retVal = '{$trail}"; } else { $nr = array_push( $this->mLinkHolders['namespaces'], $nt->getNamespace() ); @@ -2481,7 +2484,7 @@ class Parser "\$this->mLinkHolders['texts'][\$1]", $canonized_headline ); $canonized_headline = preg_replace( '//e', - "\$this->mInterwikiLinkHolders[\$1][1]", + "\$this->mInterwikiLinkHolders['texts'][\$1]", $canonized_headline ); # strip out HTML @@ -2985,13 +2988,13 @@ class Parser # Now process interwiki link holders # This is quite a bit simpler than internal links - if ( !empty( $this->mInterwikiLinkHolders ) ) { + if ( !empty( $this->mInterwikiLinkHolders['texts'] ) ) { wfProfileIn( $fname.'-interwiki' ); # Make interwiki link HTML $wgOutputReplace = array(); - foreach( $this->mInterwikiLinkHolders as $i => $lh ) { - $s = $sk->makeLink( $lh[0], $lh[1] ); - $wgOutputReplace[] = $s; + foreach( $this->mInterwikiLinkHolders['texts'] as $key => $link ) { + $title = $this->mInterwikiLinkHolders['titles'][$key]; + $wgOutputReplace[$key] = $sk->makeLinkObj( $title, $link ); } $text = preg_replace_callback( @@ -3040,8 +3043,8 @@ class Parser return $this->mLinkHolders['texts'][$key]; } } elseif( $type == 'IWLINK' ) { - if( isset( $this->mInterwikiLinkHolders[$key][1] ) ) { - return $this->mInterwikiLinkHolders[$key][1]; + if( isset( $this->mInterwikiLinkHolders['texts'][$key] ) ) { + return $this->mInterwikiLinkHolders['texts'][$key]; } } return $matches[0]; -- 2.20.1