From 467ae14ca26b3690eb73e62c9495f11c921ed205 Mon Sep 17 00:00:00 2001 From: Platonides Date: Thu, 17 Mar 2011 15:51:19 +0000 Subject: [PATCH] Add hook InterwikiLoadPrefix --- docs/hooks.txt | 6 ++++++ includes/Interwiki.php | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index f3e9fa35db..1feec0c2d0 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -962,6 +962,12 @@ $ignoreRedirect: boolean to skip redirect check $target: Title/string of redirect target $article: Article object +'InterwikiLoadPrefix': When resolving if a given prefix is an interwiki or not. +Return true without providing an interwiki to continue interwiki search. +$prefix: interwiki prefix we are looking for. +&$iwData: output array describing the interwiki with keys iw_url, iw_local, + iw_trans and optionally iw_api and iw_wikiid. + 'InternalParseBeforeLinks': during Parser's internalParse method before links but after noinclude/includeonly/onlyinclude and other processing. &$parser: Parser object diff --git a/includes/Interwiki.php b/includes/Interwiki.php index 84f268662c..05412f0fd7 100644 --- a/includes/Interwiki.php +++ b/includes/Interwiki.php @@ -141,11 +141,19 @@ class Interwiki { */ protected static function load( $prefix ) { global $wgMemc, $wgInterwikiExpiry; - $key = wfMemcKey( 'interwiki', $prefix ); - $mc = $wgMemc->get( $key ); - if( $mc && is_array( $mc ) ) { // is_array is hack for old keys - $iw = Interwiki::loadFromArray( $mc ); + $iwData = false; + if ( !wfRunHooks('InterwikiLoadPrefix', array( $prefix, &$iwData ) ) ) { + return Interwiki::loadFromArray( $iwData ); + } + + if ( !$iwData ) { + $key = wfMemcKey( 'interwiki', $prefix ); + $iwData = $wgMemc->get( $key ); + } + + if( $iwData && is_array( $iwData ) ) { // is_array is hack for old keys + $iw = Interwiki::loadFromArray( $iwData ); if( $iw ) { return $iw; } -- 2.20.1