https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112295

Revision: 112295
Author:   reedy
Date:     2012-02-24 03:40:43 +0000 (Fri, 24 Feb 2012)
Log Message:
-----------
Revert r99937 to fix bug 34674 in trunk

Modified Paths:
--------------
    trunk/extensions/DoubleWiki/DoubleWiki_body.php

Modified: trunk/extensions/DoubleWiki/DoubleWiki_body.php
===================================================================
--- trunk/extensions/DoubleWiki/DoubleWiki_body.php     2012-02-24 03:37:22 UTC 
(rev 112294)
+++ trunk/extensions/DoubleWiki/DoubleWiki_body.php     2012-02-24 03:40:43 UTC 
(rev 112295)
@@ -66,60 +66,59 @@
                        $nt = Title::newFromText( $l );
                        $iw = $nt->getInterwiki();
 
-                       if ( $iw !== $match_request ) {
-                               continue;
-                       }
-                       $key = wfMemcKey( 'doublewiki', $wgLang->getCode(), 
$nt->getPrefixedDbKey() );
-                       $cachedText = $wgMemc->get( $key );
+                       if ( $iw === $match_request ) {
 
-                       if( $cachedText ) {
-                               $text = $cachedText;
-                       } else {
-                               $url =  $nt->getCanonicalURL();
-                               $myURL = $out->getTitle()->getLocalURL();
-                               $languageName = $wgContLang->getLanguageName( 
$iw );
-                               $myLanguage = $wgLang->getLanguageName( 
$wgContLang->getCode() );
-                               $translation = Http::get( wfAppendQuery( $url, 
array( 'action' => 'render' ) ) );
+                               $key = wfMemcKey( 'doublewiki', 
$wgLang->getCode(), $nt->getPrefixedDbKey() );
+                               $cachedText = $wgMemc->get( $key );
 
-                               if ( $translation !== null ) {
-                                       break;
-                               }
-                               /**
-                                * first find all links that have no 'class' 
parameter.
-                                * these links are local so we add '?match=xx' 
to their url,
-                                * unless it already contains a '?'
-                                */
-                               $translation = preg_replace(
-                                       "/<a 
href=\"http:\/\/([^\"\?]*)\"(([\s]+)(c(?!lass=)|[^c\>\s])([^\>\s]*))*\>/i",
-                                       "<a 
href=\"http://\\1?match={$wgContLanguageCode}\"\\2>", $translation );
-                               // now add class='extiw' to these links
-                               $translation = preg_replace(
-                                       "/<a 
href=\"http:\/\/([^\"]*)\"(([\s]+)(c(?!lass=)|[^c\>\s])([^\>\s]*))*\>/i",
-                                       "<a href=\"http://\\1\"; 
class=\"extiw\"\\3>", $translation );
-                               // use class='extiw' for images too
-                               $translation = preg_replace(
-                                       "/<a 
href=\"http:\/\/([^\"]*)\"([^\>]*)class=\"image\"([^\>]*)\>/i",
-                                       "<a 
href=\"http://\\1\"\\2class=\"extiw\"\\3>", $translation );
+                               if( $cachedText ) {
+                                       $text = $cachedText;
+                               } else {
+                                       $url =  $nt->getCanonicalURL();
+                                       $myURL = 
$out->getTitle()->getLocalURL();
+                                       $languageName = 
$wgContLang->getLanguageName( $iw );
+                                       $myLanguage = $wgLang->getLanguageName( 
$wgContLang->getCode() );
+                                       $translation = Http::get( 
wfAppendQuery( $url, array( 'action' => 'render' ) ) );
 
-                               // add prefixes to internal links, in order to 
prevent duplicates
-                               $translation = preg_replace( "/<a 
href=\"#(.*?)\"/i", "<a href=\"#l_\\1\"",
-                                                               $translation );
-                               $translation = preg_replace( "/<li 
id=\"(.*?)\"/i", "<li id=\"l_\\1\"",
-                                                               $translation );
-                               $text = preg_replace( "/<a href=\"#(.*?)\"/i", 
"<a href=\"#r_\\1\"", $text );
-                               $text = preg_replace( "/<li id=\"(.*?)\"/i", 
"<li id=\"r_\\1\"", $text );
+                                       if ( $translation !== null ) {
+                                               /**
+                                                * first find all links that 
have no 'class' parameter.
+                                                * these links are local so we 
add '?match=xx' to their url,
+                                                * unless it already contains a 
'?'
+                                                */
+                                               $translation = preg_replace(
+                                                       "/<a 
href=\"http:\/\/([^\"\?]*)\"(([\s]+)(c(?!lass=)|[^c\>\s])([^\>\s]*))*\>/i",
+                                                       "<a 
href=\"http://\\1?match={$wgContLanguageCode}\"\\2>", $translation );
+                                               // now add class='extiw' to 
these links
+                                               $translation = preg_replace(
+                                                       "/<a 
href=\"http:\/\/([^\"]*)\"(([\s]+)(c(?!lass=)|[^c\>\s])([^\>\s]*))*\>/i",
+                                                       "<a href=\"http://\\1\"; 
class=\"extiw\"\\3>", $translation );
+                                               // use class='extiw' for images 
too
+                                               $translation = preg_replace(
+                                                       "/<a 
href=\"http:\/\/([^\"]*)\"([^\>]*)class=\"image\"([^\>]*)\>/i",
+                                                       "<a 
href=\"http://\\1\"\\2class=\"extiw\"\\3>", $translation );
 
-                               // add ?match= to local links of the local wiki
-                               $text = preg_replace( "/<a 
href=\"\/([^\"\?]*)\"/i",
-                                               "<a 
href=\"/\\1?match={$match_request}\"", $text );
+                                               // add prefixes to internal 
links, in order to prevent duplicates
+                                               $translation = preg_replace( 
"/<a href=\"#(.*?)\"/i", "<a href=\"#l_\\1\"",
+                                                                               
$translation );
+                                               $translation = preg_replace( 
"/<li id=\"(.*?)\"/i", "<li id=\"l_\\1\"",
+                                                                               
$translation );
+                                               $text = preg_replace( "/<a 
href=\"#(.*?)\"/i", "<a href=\"#r_\\1\"", $text );
+                                               $text = preg_replace( "/<li 
id=\"(.*?)\"/i", "<li id=\"r_\\1\"", $text );
 
-                               // do the job
-                               $text = $this->matchColumns ( $text, 
$myLanguage, $myURL, $wgContLanguageCode,
-                                                          $translation, 
$languageName, $url, $match_request );
+                                               // add ?match= to local links 
of the local wiki
+                                               $text = preg_replace( "/<a 
href=\"\/([^\"\?]*)\"/i",
+                                                               "<a 
href=\"/\\1?match={$match_request}\"", $text );
 
-                               $wgMemc->set( $key, $text, 
$wgDoubleWikiCacheTime );
+                                               // do the job
+                                               $text = $this->matchColumns ( 
$text, $myLanguage, $myURL, $wgContLanguageCode,
+                                                                          
$translation, $languageName, $url, $match_request );
+
+                                               $wgMemc->set( $key, $text, 
$wgDoubleWikiCacheTime );
+                                       }
+                               }
+                               break;
                        }
-                       break;
                }
                return true;
        }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to