Go to the documentation of this file.
24 use Wikimedia\ScopedCallback;
32 define(
'MSG_CACHE_VERSION', 2 );
114 if ( self::$instance ===
null ) {
116 self::$instance =
new self(
117 MediaWikiServices::getInstance()->getMainWANObjectCache(),
120 ? MediaWikiServices::getInstance()->getLocalServerObjectCache()
122 $wgUseDatabaseMessages,
136 self::$instance =
null;
148 $lckey = strtr( $key,
' ',
'_' );
149 if ( ord( $lckey ) < 128 ) {
150 $lckey[0] = strtolower( $lckey[0] );
176 $this->mDisable = !$useDB;
177 $this->mExpiry = $expiry;
188 if ( !$this->mParserOptions ) {
189 if ( !
$wgUser->isSafeToLoad() ) {
194 $po->setEditSection(
false );
195 $po->setAllowUnsafeRawHtml(
false );
204 $this->mParserOptions->setAllowUnsafeRawHtml(
false );
219 return $this->srvCache->get( $cacheKey );
230 $this->srvCache->set( $cacheKey,
$cache );
255 if ( !is_string(
$code ) ) {
256 throw new InvalidArgumentException(
"Missing language code" );
259 # Don't do double loading...
260 if ( isset( $this->mLoadedLanguages[
$code] ) && $mode != self::FOR_UPDATE ) {
264 # 8 lines of code just to say (once) that message cache is disabled
265 if ( $this->mDisable ) {
266 static $shownDisabled =
false;
267 if ( !$shownDisabled ) {
268 wfDebug( __METHOD__ .
": disabled\n" );
269 $shownDisabled =
true;
275 # Loading code starts
278 $where = []; # Debug info, delayed to avoid spamming debug log
too much
280 # Hash of the contents is stored in memcache, to detect if data-center cache
281 # or local cache goes out of date (e.g. due to replace() on some other server)
283 $this->mCacheVolatile[
$code] = $hashVolatile;
285 # Try the local cache and check against the cluster hash key...
288 $where[] =
'local cache is empty';
289 } elseif ( !isset(
$cache[
'HASH'] ) ||
$cache[
'HASH'] !== $hash ) {
290 $where[] =
'local cache has the wrong hash';
293 $where[] =
'local cache is expired';
295 } elseif ( $hashVolatile ) {
296 $where[] =
'local cache validation key is expired/volatile';
299 $where[] =
'got from local cache';
306 # Try the global cache. If it is empty, try to acquire a lock. If
307 # the lock can't be acquired, wait for the other thread to finish
308 # and then try the global cache a second time.
309 for ( $failedAttempts = 0; $failedAttempts <= 1; $failedAttempts++ ) {
310 if ( $hashVolatile && $staleCache ) {
311 # Do not bother fetching the whole cache blob to avoid I/O.
312 # Instead, just try to get the non-blocking $statusKey lock
313 # below, and use the local stale value if it was not acquired.
314 $where[] =
'global cache is presumed expired';
316 $cache = $this->clusterCache->get( $cacheKey );
318 $where[] =
'global cache is empty';
320 $where[] =
'global cache is expired';
322 } elseif ( $hashVolatile ) {
323 # DB results are replica DB lag prone until the holdoff TTL passes.
324 # By then, updates should be reflected in loadFromDBWithLock().
325 # One thread renerates the cache while others use old values.
326 $where[] =
'global cache is expired/volatile';
329 $where[] =
'got from global cache';
337 # Done, no need to retry
341 # We need to call loadFromDB. Limit the concurrency to one process.
342 # This prevents the site from going down when the cache expires.
343 # Note that the DB slam protection lock here is non-blocking.
345 if ( $loadStatus ===
true ) {
348 } elseif ( $staleCache ) {
349 # Use the stale cache while some other thread constructs the new one
350 $where[] =
'using stale cache';
351 $this->mCache[
$code] = $staleCache;
354 } elseif ( $failedAttempts > 0 ) {
355 # Already blocked once, so avoid another lock/unlock cycle.
356 # This case will typically be hit if memcached is down, or if
357 # loadFromDB() takes longer than LOCK_WAIT.
358 $where[] =
"could not acquire status key.";
360 } elseif ( $loadStatus ===
'cantacquire' ) {
361 # Wait for the other thread to finish, then retry. Normally,
362 # the memcached get() will then yeild the other thread's result.
363 $where[] =
'waited for other thread to complete';
366 # Disable cache; $loadStatus is 'disabled'
373 $where[] =
'loading FAILED - cache is disabled';
374 $this->mDisable =
true;
375 $this->mCache =
false;
376 wfDebugLog(
'MessageCacheError', __METHOD__ .
": Failed to load $code\n" );
377 # This used to throw an exception, but that led to nasty side effects like
378 # the whole wiki being instantly down if the memcached server died
380 # All good, just record the success
381 $this->mLoadedLanguages[
$code] =
true;
384 $info = implode(
', ', $where );
385 wfDebugLog(
'MessageCache', __METHOD__ .
": Loading $code... $info\n" );
397 # If cache updates on all levels fail, give up on message overrides.
398 # This is to avoid easy site outages; see $saveSuccess comments below.
400 $status = $this->clusterCache->get( $statusKey );
402 $where[] =
"could not load; method is still globally disabled";
406 # Now let's regenerate
407 $where[] =
'loading from database';
409 # Lock the cache to prevent conflicting writes.
410 # This lock is non-blocking so stale cache can quickly be used.
411 # Note that load() will call a blocking getReentrantScopedLock()
412 # after this if it really need to wait for any current thread.
415 if ( !$scopedLock ) {
416 $where[] =
'could not acquire main lock';
417 return 'cantacquire';
424 if ( !$saveSuccess ) {
439 $this->clusterCache->set( $statusKey,
'error', 60 * 5 );
440 $where[] =
'could not save cache, disabled globally for 5 minutes';
442 $where[] =
"could not save global cache";
467 'page_is_redirect' => 0,
474 $this->
load( $wgLanguageCode );
477 foreach ( $mostused
as $key =>
$value ) {
478 $mostused[$key] =
"$value/$code";
482 if (
count( $mostused ) ) {
483 $conds[
'page_title'] = $mostused;
485 $conds[] =
'page_title' .
$dbr->buildLike(
$dbr->anyString(),
'/',
$code );
487 # Effectively disallows use of '/' character in NS_MEDIAWIKI for uses
488 # other than language code.
489 $conds[] =
'page_title NOT' .
490 $dbr->buildLike(
$dbr->anyString(),
'/',
$dbr->anyString() );
493 # Conditions to fetch oversized pages to ignore them
495 $bigConds[] =
'page_len > ' . intval( $wgMaxMsgCacheEntrySize );
497 # Load titles for all oversized pages in the MediaWiki namespace
500 [
'page_title',
'page_latest' ],
502 __METHOD__ .
"($code)-big"
504 foreach (
$res as $row ) {
505 $cache[$row->page_title] =
'!TOO BIG';
507 $cache[
'EXCESSIVE'][$row->page_title] = $row->page_latest;
510 # Conditions to load the remaining pages with their contents
511 $smallConds = $conds;
512 $smallConds[] =
'page_latest=rev_id';
513 $smallConds[] =
'rev_text_id=old_id';
514 $smallConds[] =
'page_len <= ' . intval( $wgMaxMsgCacheEntrySize );
517 [
'page',
'revision',
'text' ],
518 [
'page_title',
'old_id',
'old_text',
'old_flags' ],
520 __METHOD__ .
"($code)-small"
523 foreach (
$res as $row ) {
525 if ( $text ===
false ) {
533 .
": failed to load message page text for {$row->page_title} ($code)"
536 $entry =
' ' . $text;
538 $cache[$row->page_title] = $entry;
544 # Hash for validating local cache (APC). No need to take into account
545 # messages larger than $wgMaxMsgCacheEntrySize, since those are only
546 # stored and fetched from memcache.
562 if ( $this->mDisable ) {
573 if ( $text ===
false ) {
587 if ( !$scopedLock ) {
588 LoggerFactory::getInstance(
'MessageCache' )->error(
589 __METHOD__ .
': could not acquire lock to update {title} ({code})',
598 $page->loadPageData( $page::READ_LATEST );
601 if ( is_string( $text ) && strlen( $text ) > $wgMaxMsgCacheEntrySize ) {
603 $this->wanCache->set( $titleKey,
' ' . $text, $this->mExpiry );
607 $this->mCache[
$code][
'LATEST'] = time();
614 ScopedCallback::consume( $scopedLock );
621 if (
$code ===
'en' ) {
634 $blobStore = $resourceloader->getMessageBlobStore();
635 $blobStore->updateMessage(
$wgContLang->lcfirst( $msg ) );
650 if ( !isset(
$cache[
'VERSION'] ) || !isset(
$cache[
'EXPIRY'] ) ) {
673 if ( $dest ===
'all' ) {
694 $value = $this->wanCache->get(
695 $this->wanCache->makeKey(
'messages',
$code,
'hash',
'v1' ),
709 $expired = ( $curTTL < 0 );
717 return [ $hash, $expired ];
731 $this->wanCache->set(
732 $this->wanCache->makeKey(
'messages',
$code,
'hash',
'v1' ),
735 'latest' => isset(
$cache[
'LATEST'] ) ?
$cache[
'LATEST'] : 0
747 return $this->clusterCache->getScopedLock( $key, $timeout, self::LOCK_TTL, __METHOD__ );
784 function get( $key, $useDB =
true, $langcode =
true, $isFullKey =
false ) {
785 if ( is_int( $key ) ) {
789 } elseif ( !is_string( $key ) ) {
791 } elseif ( $key ===
'' ) {
797 $pos = strrpos( $key,
'/' );
798 if ( $isFullKey && $pos !==
false ) {
799 $langcode = substr( $key, $pos + 1 );
800 $key = substr( $key, 0, $pos );
806 Hooks::run(
'MessageCache::get', [ &$lckey ] );
813 !$this->mDisable && $useDB
817 if ( $message ===
false ) {
818 $parts = explode(
'/', $lckey );
822 if (
count( $parts ) == 2 && $parts[1] !==
'' ) {
824 if ( $message ===
null ) {
831 if ( $message !==
false ) {
833 $message = str_replace(
835 # Fix
for trailing whitespace, removed
by textarea
837 # Fix
for NBSP, converted to space
by firefox
874 if ( $message !==
false ) {
879 $message = $this->
getMessageForLang( $wgContLang, $lckey, $useDB, $alreadyTried );
896 $langcode =
$lang->getCode();
902 if ( !isset( $alreadyTried[ $langcode ] ) ) {
908 if ( $message !==
false ) {
911 $alreadyTried[ $langcode ] =
true;
918 $message =
$lang->getMessage( $lckey );
919 if ( $message !==
null ) {
927 foreach ( $fallbackChain
as $code ) {
928 if ( isset( $alreadyTried[
$code ] ) ) {
935 if ( $message !==
false ) {
938 $alreadyTried[
$code ] =
true;
959 return "$uckey/$langcode";
980 if ( substr( $entry, 0, 1 ) ===
' ' ) {
982 return (
string)substr( $entry, 1 );
983 } elseif ( $entry ===
'!NONEXISTENT' ) {
985 } elseif ( $entry ===
'!TOO BIG' ) {
992 if ( $message !==
false ) {
1002 if ( $this->mCacheVolatile[
$code] ) {
1005 LoggerFactory::getInstance(
'MessageCache' )->debug(
1006 __METHOD__ .
': loading volatile key \'{titleKey}\'',
1007 [
'titleKey' => $titleKey,
'code' =>
$code ] );
1010 $entry = $this->wanCache->get( $titleKey );
1013 if ( $entry !==
false ) {
1014 if ( substr( $entry, 0, 1 ) ===
' ' ) {
1017 return (
string)substr( $entry, 1 );
1018 } elseif ( $entry ===
'!NONEXISTENT' ) {
1024 $this->wanCache->delete( $titleKey );
1030 $cacheOpts = Database::getCacheSetOptions(
$dbr );
1033 if ( $titleObj->getLatestRevID() ) {
1036 $titleObj->getArticleID(),
1037 $titleObj->getLatestRevID()
1044 $content = $revision->getContent();
1047 if ( is_string( $message ) ) {
1049 $this->wanCache->set( $titleKey,
' ' . $message, $this->mExpiry, $cacheOpts );
1053 LoggerFactory::getInstance(
'MessageCache' )->warning(
1054 __METHOD__ .
': failed to load message page text for \'{titleKey}\'',
1055 [
'titleKey' => $titleKey,
'code' =>
$code ] );
1062 if ( $message ===
false ) {
1065 $this->wanCache->set( $titleKey,
'!NONEXISTENT', $this->mExpiry, $cacheOpts );
1080 if ( strpos( $message,
'{{' ) ===
false ) {
1084 if ( $this->mInParser ) {
1091 $popts->setInterfaceMessage( $interface );
1092 $popts->setTargetLanguage( $language );
1094 $userlang = $popts->setUserLang( $language );
1095 $this->mInParser =
true;
1096 $message =
$parser->transformMsg( $message, $popts,
$title );
1097 $this->mInParser =
false;
1098 $popts->setUserLang( $userlang );
1110 if ( !$this->mParser && isset(
$wgParser ) ) {
1111 # Do some initialisation so that we don't have to do it twice
1113 # Clone it and store it
1114 $class = $wgParserConf[
'class'];
1115 if ( $class ==
'ParserDiffTest' ) {
1117 $this->mParser =
new $class( $wgParserConf );
1135 $interface =
false, $language =
null
1139 if ( $this->mInParser ) {
1140 return htmlspecialchars( $text );
1145 $popts->setInterfaceMessage( $interface );
1147 if ( is_string( $language ) ) {
1150 $popts->setTargetLanguage( $language );
1153 wfDebugLog(
'GlobalTitleFail', __METHOD__ .
' called by ' .
1159 # It's not uncommon having a null $wgTitle in scripts. See r80898
1160 # Create a ghost title in such case
1164 $this->mInParser =
true;
1166 $this->mInParser =
false;
1172 $this->mDisable =
true;
1176 $this->mDisable =
false;
1200 foreach ( array_keys( $langs )
as $code ) {
1201 # Global and local caches
1202 $this->wanCache->touchCheckKey(
wfMemcKey(
'messages',
$code ) );
1205 $this->mLoadedLanguages = [];
1215 $pieces = explode(
'/', $key );
1216 if (
count( $pieces ) < 2 ) {
1220 $lang = array_pop( $pieces );
1225 $message = implode(
'/', $pieces );
1227 return [ $message,
$lang ];
1242 if ( !isset( $this->mCache[
$code] ) ) {
1248 unset(
$cache[
'VERSION'] );
1249 unset(
$cache[
'EXPIRY'] );
1250 unset(
$cache[
'EXCESSIVE'] );
1269 if ( $msgText ===
null ) {
1292 $msgText =
$content->getWikitextForTransclusion();
1293 if ( $msgText ===
false || $msgText ===
null ) {
1296 LoggerFactory::getInstance(
'MessageCache' )->warning(
1297 __METHOD__ .
": message content doesn't provide wikitext "
1298 .
"(content model: " .
$content->getModel() .
")" );
1314 return $this->wanCache->makeKey(
'messages-big', $hash,
$title );
static getFallbacksFor( $code)
Get the ordered list of fallback languages.
transform( $message, $interface=false, $language=null, $title=null)
Set options of the Parser.
$mLoadedLanguages
Variable for tracking which variables are already loaded.
setValidationHash( $code, array $cache)
Set the md5 used to validate the local disk cache.
processing should stop and the error should be shown to the user * false
static normalizeKey( $key)
Normalize message key input.
parse( $text, $title=null, $linestart=true, $interface=false, $language=null)
A BagOStuff object with no objects in it.
saveToCaches(array $cache, $dest, $code=false)
Shortcut to update caches.
if(!isset( $args[0])) $lang
ParserOptions $mParserOptions
Message cache has its own parser which it uses to transform messages.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
static newKnownCurrent(IDatabase $db, $pageId, $revId)
Load a revision based on a known page ID and current revision ID from the DB.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
static newFromAnon()
Get a ParserOptions object for an anonymous user.
const LOCK_TTL
How long memcached locks last.
bool[] $mCacheVolatile
Map of (language code => boolean)
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
interface is intended to be more or less compatible with the PHP memcached client.
saveToLocalCache( $code, $cache)
Save the cache to APC.
if(! $wgRequest->checkUrlExtension()) if(isset( $_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] !='') if(! $wgEnableAPI) $wgTitle
you have access to all of the normal MediaWiki so you can get a DB use the cache
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
getValidationHash( $code)
Get the md5 used to validate the local APC cache.
getMessageTextFromContent(Content $content=null)
static addCallableUpdate( $callable, $stage=self::POSTSEND, IDatabase $dbw=null)
Add a callable update.
$wgAdaptiveMessageCache
Instead of caching everything, only cache those messages which have been customised in the site conte...
static $instance
Singleton instance.
getDBkey()
Get the main part with underscores.
loadFromDB( $code, $mode=null)
Loads cacheable messages from the database.
wfMemcKey()
Make a cache key for the local wiki.
namespace and then decline to actually register it file or subcat img or subcat $title
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre >< span ></span >< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></pre ></div > ! end ! test Multiline< source/> in lists !input *< source > a b</source > *foo< source > a b</source > ! html< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! html tidy< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! end ! test Custom attributes !input< source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;"> var a
getMsgFromNamespace( $title, $code)
Get a message from the MediaWiki namespace, with caching.
bigMessageCacheKey( $hash, $title)
static fetchLanguageNames( $inLanguage=null, $include='mw')
Get an array of language names, indexed by code.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static getMessageFor( $key, $code)
Get a message for a given language.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
null for the wiki Added in
$mCache
Process local cache of loaded messages that are defined in MediaWiki namespace.
getMessagePageName( $langcode, $uckey)
Get the message page name for a given language.
const MSG_CACHE_VERSION
MediaWiki message cache structure version.
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
do that in ParserLimitReportFormat instead $parser
replace( $title, $text)
Updates cache as necessary when message page is changed.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
when a variable name is used in a it is silently declared as a new masking the global
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this submitted means any form of or written communication sent to the Licensor or its including but not limited to communication on electronic mailing source code control and issue tracking systems that are managed by
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
</source > ! result< p > Text< code class="mw-highlight" dir="ltr">< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></code ></p > ! end ! test Enclose none(inline code) !!input Text< source lang
getMessageFromFallbackChain( $lang, $lckey, $useDB)
Given a language, try and fetch messages from that language.
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
static singleton()
Get the signleton instance of this class.
updateMessageOverride(Title $title, Content $content=null)
Purge message caches when a MediaWiki: page is created, updated, or deleted.
const WAIT_SEC
How long to wait for memcached locks.
__construct(WANObjectCache $wanCache, BagOStuff $clusterCache, BagOStuff $srvCache, $useDB, $expiry)
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for so if you want to use a style that puts opening braces on the next that s OK too
clear()
Clear all stored messages.
Multi-datacenter aware caching interface.
$wgLanguageCode
Site language code.
getReentrantScopedLock( $key, $timeout=self::WAIT_SEC)
static fetchLanguageName( $code, $inLanguage=null, $include='all')
static getMain()
Static methods.
wfGetAllCallers( $limit=3)
Return a string consisting of callers in the stack.
Base interface for content objects.
getLocalCache( $code)
Try to load the cache from APC.
wfGetMessageCacheStorage()
Get the cache object used by the message cache.
Represents a title within MediaWiki.
loadFromDBWithLock( $code, array &$where, $mode=null)
$mDisable
Should mean that database cannot be used, but check.
load( $code, $mode=null)
Loads messages from caches or from database in this order: (1) local message cache (if $wgUseLocalMes...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
isDisabled()
Whether DB/cache usage is disabled for determining messages.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getParserOptions()
ParserOptions is lazy initialised.
isCacheExpired( $cache)
Is the given cache array expired due to time passing or a version change?
passed in as a query string parameter to the various URLs constructed here(i.e. $prevlink) $ldel you ll need to handle error messages
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
$mExpiry
Lifetime for cache, used by object caching.
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
static factory( $code)
Get a cached or new language object for a given language code.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Message cache Performs various MediaWiki namespace-related functions.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
getMessageForLang( $lang, $lckey, $useDB, &$alreadyTried)
Given a language, try and fetch messages from that language and its fallbacks.
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
$wgUseLocalMessageCache
Set this to true to maintain a copy of the message cache on the local server.
the array() calling protocol came about after MediaWiki 1.4rc1.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
getAllMessageKeys( $code)
Get all message keys stored in the message cache for a given language.
static destroyInstance()
Destroy the singleton instance.