25use Cdb\Exception as CdbException;
26use Cdb\Reader as CdbReader;
131 $result = $this->
fetch( $prefix );
143 if ( $prefix ==
'' ) {
147 $prefix = $this->contentLanguage->lc( $prefix );
148 if ( $this->localCache->has( $prefix ) ) {
149 return $this->localCache->get( $prefix );
152 if ( $this->cdbData ) {
155 $iw = $this->
load( $prefix );
160 $this->localCache->set( $prefix, $iw );
171 $this->localCache->clear();
179 $this->localCache->clear( $prefix );
181 $key = $this->objectCache->makeKey(
'interwiki', $prefix );
182 $this->objectCache->delete( $key );
198 list( $local, $url ) = explode(
' ',
$value, 2 );
199 return new Interwiki( $prefix, $url,
'',
'', (
int)$local );
214 wfDebug( __METHOD__ .
"( $prefix )\n" );
218 if ( $this->interwikiScopes >= 3 && !$this->thisSite ) {
220 if ( $this->thisSite ==
'' ) {
227 if (
$value ==
'' && $this->interwikiScopes >= 3 ) {
231 if (
$value ==
'' && $this->interwikiScopes >= 2 ) {
234 if (
$value ==
'undef' ) {
237 }
catch ( CdbException
$e ) {
238 wfDebug( __METHOD__ .
": CdbException caught, error message was "
239 .
$e->getMessage() );
246 if ( $this->cdbReader ===
null ) {
247 if ( is_string( $this->cdbData ) ) {
248 $this->cdbReader = \Cdb\Reader::open( $this->cdbData );
249 } elseif ( is_array( $this->cdbData ) ) {
250 $this->cdbReader = new \Cdb\Reader\Hash( $this->cdbData );
252 $this->cdbReader =
false;
256 if ( $this->cdbReader ) {
257 return $this->cdbReader->get( $key );
269 private function load( $prefix ) {
271 if ( !
Hooks::run(
'InterwikiLoadPrefix', [ $prefix, &$iwData ] ) ) {
275 if ( is_array( $iwData ) ) {
282 $iwData = $this->objectCache->getWithSetCallback(
283 $this->objectCache->makeKey(
'interwiki', $prefix ),
284 $this->objectCacheExpiry,
285 function ( $oldValue, &$ttl, array &$setOpts ) use ( $prefix ) {
288 $setOpts += Database::getCacheSetOptions(
$dbr );
290 $row =
$dbr->selectRow(
292 self::selectFields(),
293 [
'iw_prefix' => $prefix ],
297 return $row ? (
array)$row :
'!NONEXISTENT';
301 if ( is_array( $iwData ) ) {
315 if ( isset( $mc[
'iw_url'] ) ) {
316 $url = $mc[
'iw_url'];
317 $local = isset( $mc[
'iw_local'] ) ? $mc[
'iw_local'] : 0;
318 $trans = isset( $mc[
'iw_trans'] ) ? $mc[
'iw_trans'] : 0;
319 $api = isset( $mc[
'iw_api'] ) ? $mc[
'iw_api'] :
'';
320 $wikiId = isset( $mc[
'iw_wikiid'] ) ? $mc[
'iw_wikiid'] :
'';
322 return new Interwiki(
null, $url, $api, $wikiId, $local, $trans );
335 wfDebug( __METHOD__ .
"()\n" );
339 if ( $this->interwikiScopes >= 3 && !$this->thisSite ) {
345 $this->thisSite = $site;
352 if ( $this->interwikiScopes >= 2 ) {
353 $sources[] =
'__global';
356 if ( $this->interwikiScopes >= 3 ) {
361 foreach ( $sources as
$source ) {
363 foreach ( explode(
' ', $list ) as $iw_prefix ) {
369 list( $iw_local, $iw_url ) = explode(
' ', $row );
371 if ( $local !==
null && $local != $iw_local ) {
375 $data[$iw_prefix] = [
376 'iw_prefix' => $iw_prefix,
378 'iw_local' => $iw_local,
382 }
catch ( CdbException
$e ) {
383 wfDebug( __METHOD__ .
": CdbException caught, error message was "
384 .
$e->getMessage() );
387 return array_values( $data );
401 if ( $local !==
null ) {
403 $where[
'iw_local'] = 1;
404 } elseif ( $local == 0 ) {
405 $where[
'iw_local'] = 0;
409 $res = $db->select(
'interwiki',
410 self::selectFields(),
411 $where, __METHOD__, [
'ORDER BY' =>
'iw_prefix' ]
415 foreach (
$res as $row ) {
429 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