r16930 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16929‎ | r16930 | r16931 >
Date:10:10, 11 October 2006
Author:rainman
Status:old
Tags:
Comment:

Detects if aliases are used, and in that case, purges squid cache.
Modified paths:
  • /branches/SerbianVariants/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: branches/SerbianVariants/phase3/includes/Title.php
@@ -821,6 +821,8 @@
822822 function getFullVariantURL( $variant = '' ) {
823823 global $wgServer, $wgRequest;
824824
 825+ $url = ''; // should not be called for interwiki
 826+
825827 if ( '' == $this->mInterwiki ) {
826828 $url = $this->getLocalVariantURL( $variant );
827829
@@ -829,11 +831,6 @@
830832 }
831833 }
832834
833 - # Finally, add the fragment.
834 - if ( '' != $this->mFragment ) {
835 - $url .= '#' . $this->mFragment;
836 - }
837 -
838835 return $url;
839836 }
840837
@@ -907,10 +904,12 @@
908905 if($variant=='') return $this->getLocalURL();
909906
910907 if($wgVariantArticlePath==false)
911 - $wgVariantArticlePath = "$wgScript?title=$1&variant=$2";
 908+ $vArticlePath = "$wgScript?title=$1&variant=$2"; // default
 909+ else
 910+ $vArticlePath = $wgVariantArticlePath;
912911
913912 $dbkey = wfUrlencode( $this->getPrefixedDBkey() );
914 - $url = str_replace( '$1', $dbkey, $wgVariantArticlePath );
 913+ $url = str_replace( '$1', $dbkey, $vArticlePath );
915914 $code = urlencode( $variant );
916915 $url = str_replace( '$2', $code, $url );
917916
@@ -958,6 +957,23 @@
959958 }
960959
961960 /**
 961+ * Get the URL form for an internal variant link.
 962+ * - Used in various Squid-related code, in case we have a different
 963+ * internal hostname for the server from the exposed one.
 964+ *
 965+ * @param string $variant an optional query string
 966+ * @return string the URL
 967+ * @access public
 968+ */
 969+ function getInternalVariantURL( $variant = '' ) {
 970+ global $wgInternalServer;
 971+ $url = $wgInternalServer . $this->getLocalVariantURL( $variant );
 972+ // not sure: wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) );
 973+ return $url;
 974+ }
 975+
 976+
 977+ /**
962978 * Get the edit URL for this Title
963979 * @return string the URL, or a null string if this is an
964980 * interwiki link
@@ -1749,10 +1765,23 @@
17501766 * @access public
17511767 */
17521768 function getSquidURLs() {
1753 - return array(
 1769+ global $wgContLang,$wgVariantArticlePath;
 1770+
 1771+ $urls = array(
17541772 $this->getInternalURL(),
17551773 $this->getInternalURL( 'action=history' )
17561774 );
 1775+
 1776+ // purge variant url's as well (when using aliases)
 1777+ if($wgContLang->hasVariants() && $wgVariantArticlePath!=false){
 1778+ $variants = $wgContLang->getVariants();
 1779+ foreach($variants as $vCode){
 1780+ if($vCode==$wgContLang->getCode()) continue; // we don't want default variant
 1781+ $urls[] = $this->getInternalVariantURL($vCode);
 1782+ }
 1783+ }
 1784+
 1785+ return $urls;
17571786 }
17581787
17591788 function purgeSquid() {