Add hook InterwikiLoadPrefix

This commit is contained in:
Platonides 2011-03-17 15:51:19 +00:00
parent 7f604b9a6c
commit 467ae14ca2
2 changed files with 18 additions and 4 deletions

View 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

View 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;
}