r84173 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84172‎ | r84173 | r84174 >
Date:15:51, 17 March 2011
Author:platonides
Status:ok
Tags:
Comment:
Add hook InterwikiLoadPrefix
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/Interwiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -962,6 +962,12 @@
963963 $target: Title/string of redirect target
964964 $article: Article object
965965
 966+'InterwikiLoadPrefix': When resolving if a given prefix is an interwiki or not.
 967+Return true without providing an interwiki to continue interwiki search.
 968+$prefix: interwiki prefix we are looking for.
 969+&$iwData: output array describing the interwiki with keys iw_url, iw_local,
 970+ iw_trans and optionally iw_api and iw_wikiid.
 971+
966972 'InternalParseBeforeLinks': during Parser's internalParse method before links
967973 but after noinclude/includeonly/onlyinclude and other processing.
968974 &$parser: Parser object
Index: trunk/phase3/includes/Interwiki.php
@@ -141,11 +141,19 @@
142142 */
143143 protected static function load( $prefix ) {
144144 global $wgMemc, $wgInterwikiExpiry;
145 - $key = wfMemcKey( 'interwiki', $prefix );
146 - $mc = $wgMemc->get( $key );
147145
148 - if( $mc && is_array( $mc ) ) { // is_array is hack for old keys
149 - $iw = Interwiki::loadFromArray( $mc );
 146+ $iwData = false;
 147+ if ( !wfRunHooks('InterwikiLoadPrefix', array( $prefix, &$iwData ) ) ) {
 148+ return Interwiki::loadFromArray( $iwData );
 149+ }
 150+
 151+ if ( !$iwData ) {
 152+ $key = wfMemcKey( 'interwiki', $prefix );
 153+ $iwData = $wgMemc->get( $key );
 154+ }
 155+
 156+ if( $iwData && is_array( $iwData ) ) { // is_array is hack for old keys
 157+ $iw = Interwiki::loadFromArray( $iwData );
150158 if( $iw ) {
151159 return $iw;
152160 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r84175Enable preprocessDump.php to work without a db....platonides16:06, 17 March 2011

Status & tagging log