Add hook InterwikiLoadPrefix
authorPlatonides <platonides@users.mediawiki.org>
Thu, 17 Mar 2011 15:51:19 +0000 (15:51 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Thu, 17 Mar 2011 15:51:19 +0000 (15:51 +0000)
docs/hooks.txt
includes/Interwiki.php

index f3e9fa3..1feec0c 100644 (file)
@@ -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
index 84f2686..05412f0 100644 (file)
@@ -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;
                        }