summaryrefslogtreecommitdiff
path: root/includes/Interwiki.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
committerPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
commit9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch)
tree46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/Interwiki.php
parent78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff)
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/Interwiki.php')
-rw-r--r--includes/Interwiki.php48
1 files changed, 39 insertions, 9 deletions
diff --git a/includes/Interwiki.php b/includes/Interwiki.php
index 3c71f6ee..5a3b6556 100644
--- a/includes/Interwiki.php
+++ b/includes/Interwiki.php
@@ -7,7 +7,8 @@
/**
* The interwiki class
* All information is loaded on creation when called by Interwiki::fetch( $prefix ).
- * All work is done on slave, because this should *never* change (except during schema updates etc, which arent wiki-related)
+ * All work is done on slave, because this should *never* change (except during
+ * schema updates etc, which aren't wiki-related)
*/
class Interwiki {
@@ -15,11 +16,13 @@ class Interwiki {
protected static $smCache = array();
const CACHE_LIMIT = 100; // 0 means unlimited, any other value is max number of entries.
- protected $mPrefix, $mURL, $mLocal, $mTrans;
+ protected $mPrefix, $mURL, $mAPI, $mWikiID, $mLocal, $mTrans;
- public function __construct( $prefix = null, $url = '', $local = 0, $trans = 0 ) {
+ public function __construct( $prefix = null, $url = '', $api = '', $wikiId = '', $local = 0, $trans = 0 ) {
$this->mPrefix = $prefix;
$this->mURL = $url;
+ $this->mAPI = $api;
+ $this->mWikiID = $wikiId;
$this->mLocal = $local;
$this->mTrans = $trans;
}
@@ -61,7 +64,7 @@ class Interwiki {
}
if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ) {
reset( self::$smCache );
- unset( self::$smCache[ key( self::$smCache ) ] );
+ unset( self::$smCache[key( self::$smCache )] );
}
self::$smCache[$prefix] = $iw;
return $iw;
@@ -107,7 +110,7 @@ class Interwiki {
$db = CdbReader::open( $wgInterwikiCache );
}
/* Resolve site name */
- if( $wgInterwikiScopes>=3 && !$site ) {
+ if( $wgInterwikiScopes >= 3 && !$site ) {
$site = $db->get( '__sites:' . wfWikiID() );
if ( $site == '' ) {
$site = $wgInterwikiFallbackSite;
@@ -123,8 +126,9 @@ class Interwiki {
if ( $value == '' && $wgInterwikiScopes >= 2 ) {
$value = $db->get( "__global:{$prefix}" );
}
- if ( $value == 'undef' )
+ if ( $value == 'undef' ) {
$value = '';
+ }
return $value;
}
@@ -139,7 +143,7 @@ class Interwiki {
global $wgMemc, $wgInterwikiExpiry;
$key = wfMemcKey( 'interwiki', $prefix );
$mc = $wgMemc->get( $key );
- $iw = false;
+
if( $mc && is_array( $mc ) ) { // is_array is hack for old keys
$iw = Interwiki::loadFromArray( $mc );
if( $iw ) {
@@ -153,7 +157,12 @@ class Interwiki {
__METHOD__ ) );
$iw = Interwiki::loadFromArray( $row );
if ( $iw ) {
- $mc = array( 'iw_url' => $iw->mURL, 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans );
+ $mc = array(
+ 'iw_url' => $iw->mURL,
+ 'iw_api' => $iw->mAPI,
+ 'iw_local' => $iw->mLocal,
+ 'iw_trans' => $iw->mTrans
+ );
$wgMemc->add( $key, $mc, $wgInterwikiExpiry );
return $iw;
}
@@ -173,6 +182,9 @@ class Interwiki {
$iw->mURL = $mc['iw_url'];
$iw->mLocal = $mc['iw_local'];
$iw->mTrans = $mc['iw_trans'];
+ $iw->mAPI = isset( $mc['iw_api'] ) ? $mc['iw_api'] : '';
+ $iw->mWikiID = isset( $mc['iw_wikiid'] ) ? $mc['iw_wikiid'] : '';
+
return $iw;
}
return false;
@@ -180,7 +192,7 @@ class Interwiki {
/**
* Get the URL for a particular title (or with $1 if no title given)
- *
+ *
* @param $title String: what text to put for the article name
* @return String: the URL
*/
@@ -193,6 +205,24 @@ class Interwiki {
}
/**
+ * Get the API URL for this wiki
+ *
+ * @return String: the URL
+ */
+ public function getAPI() {
+ return $this->mAPI;
+ }
+
+ /**
+ * Get the DB name for this wiki
+ *
+ * @return String: the DB name
+ */
+ public function getWikiID() {
+ return $this->mWikiID;
+ }
+
+ /**
* Is this a local link from a sister project, or is
* it something outside, like Google
*