24use \Cdb\Exception as CdbException;
25use \Cdb\Reader as CdbReader;
130 $result = $this->
fetch( $prefix );
142 if ( $prefix ==
'' ) {
146 $prefix = $this->contentLanguage->lc( $prefix );
147 if ( $this->localCache->has( $prefix ) ) {
148 return $this->localCache->get( $prefix );
151 if ( $this->cdbData ) {
154 $iw = $this->
load( $prefix );
159 $this->localCache->set( $prefix, $iw );
170 $this->localCache->clear();
178 $this->localCache->clear( $prefix );
180 $key = $this->objectCache->makeKey(
'interwiki', $prefix );
181 $this->objectCache->delete( $key );
197 list( $local, $url ) = explode(
' ',
$value, 2 );
198 return new Interwiki( $prefix, $url,
'',
'', (
int)$local );
213 wfDebug( __METHOD__ .
"( $prefix )\n" );
217 if ( $this->interwikiScopes >= 3 && !$this->thisSite ) {
219 if ( $this->thisSite ==
'' ) {
226 if (
$value ==
'' && $this->interwikiScopes >= 3 ) {
230 if (
$value ==
'' && $this->interwikiScopes >= 2 ) {
233 if (
$value ==
'undef' ) {
236 }
catch ( CdbException
$e ) {
237 wfDebug( __METHOD__ .
": CdbException caught, error message was "
238 .
$e->getMessage() );
245 if ( $this->cdbReader ===
null ) {
246 if ( is_string( $this->cdbData ) ) {
247 $this->cdbReader = \Cdb\Reader::open( $this->cdbData );
248 } elseif ( is_array( $this->cdbData ) ) {
249 $this->cdbReader = new \Cdb\Reader\Hash( $this->cdbData );
251 $this->cdbReader =
false;
255 if ( $this->cdbReader ) {
256 return $this->cdbReader->get( $key );
268 private function load( $prefix ) {
270 if ( !
Hooks::run(
'InterwikiLoadPrefix', [ $prefix, &$iwData ] ) ) {
274 if ( is_array( $iwData ) ) {
281 $iwData = $this->objectCache->getWithSetCallback(
282 $this->objectCache->makeKey(
'interwiki', $prefix ),
283 $this->objectCacheExpiry,
284 function ( $oldValue, &$ttl, array &$setOpts ) use ( $prefix ) {
287 $setOpts += Database::getCacheSetOptions(
$dbr );
289 $row =
$dbr->selectRow(
291 self::selectFields(),
292 [
'iw_prefix' => $prefix ],
296 return $row ? (
array)$row :
'!NONEXISTENT';
300 if ( is_array( $iwData ) ) {
314 if ( isset( $mc[
'iw_url'] ) ) {
315 $url = $mc[
'iw_url'];
316 $local = isset( $mc[
'iw_local'] ) ? $mc[
'iw_local'] : 0;
317 $trans = isset( $mc[
'iw_trans'] ) ? $mc[
'iw_trans'] : 0;
318 $api = isset( $mc[
'iw_api'] ) ? $mc[
'iw_api'] :
'';
319 $wikiId = isset( $mc[
'iw_wikiid'] ) ? $mc[
'iw_wikiid'] :
'';
321 return new Interwiki(
null, $url, $api, $wikiId, $local, $trans );
334 wfDebug( __METHOD__ .
"()\n" );
338 if ( $this->interwikiScopes >= 3 && !$this->thisSite ) {
344 $this->thisSite = $site;
351 if ( $this->interwikiScopes >= 2 ) {
352 $sources[] =
'__global';
355 if ( $this->interwikiScopes >= 3 ) {
360 foreach ( $sources as
$source ) {
362 foreach ( explode(
' ', $list ) as $iw_prefix ) {
368 list( $iw_local, $iw_url ) = explode(
' ', $row );
370 if ( $local !==
null && $local != $iw_local ) {
374 $data[$iw_prefix] = [
375 'iw_prefix' => $iw_prefix,
377 'iw_local' => $iw_local,
381 }
catch ( CdbException
$e ) {
382 wfDebug( __METHOD__ .
": CdbException caught, error message was "
383 .
$e->getMessage() );
386 return array_values( $data );
400 if ( $local !==
null ) {
402 $where[
'iw_local'] = 1;
403 } elseif ( $local == 0 ) {
404 $where[
'iw_local'] = 0;
408 $res = $db->select(
'interwiki',
409 self::selectFields(),
410 $where, __METHOD__, [
'ORDER BY' =>
'iw_prefix' ]
414 foreach (
$res as $row ) {
428 if ( $this->cdbData ) {
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Value object for representing interwiki records.
Internationalisation code.
Handles a simple LRU key/value map with a maximum number of entries.
Multi-datacenter aware caching interface.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
when a variable name is used in a function
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace being checked & $result
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account incomplete not yet checked for validity & $retval
returning false will NOT prevent logging $e
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy load