24use Wikimedia\ScopedCallback;
32define(
'MSG_CACHE_VERSION', 2 );
114 if ( self::$instance ===
null ) {
116 self::$instance =
new self(
117 MediaWikiServices::getInstance()->getMainWANObjectCache(),
120 ? MediaWikiServices::getInstance()->getLocalServerObjectCache()
136 self::$instance =
null;
148 $lckey = strtr( $key,
' ',
'_' );
149 if ( ord( $lckey ) < 128 ) {
150 $lckey[0] = strtolower( $lckey[0] );
174 $this->srvCache = $serverCache;
176 $this->mDisable = !$useDB;
177 $this->mExpiry = $expiry;
188 if ( !$this->mParserOptions ) {
189 if ( !
$wgUser->isSafeToLoad() ) {
193 $po = ParserOptions::newFromAnon();
194 $po->setAllowUnsafeRawHtml(
false );
215 $cacheKey = $this->srvCache->makeKey( __CLASS__,
$code );
217 return $this->srvCache->get( $cacheKey );
227 $cacheKey = $this->srvCache->makeKey( __CLASS__,
$code );
228 $this->srvCache->set( $cacheKey,
$cache );
253 if ( !is_string(
$code ) ) {
254 throw new InvalidArgumentException(
"Missing language code" );
257 # Don't do double loading...
258 if ( isset( $this->mLoadedLanguages[
$code] ) && $mode != self::FOR_UPDATE ) {
262 # 8 lines of code just to say (once) that message cache is disabled
263 if ( $this->mDisable ) {
264 static $shownDisabled =
false;
265 if ( !$shownDisabled ) {
266 wfDebug( __METHOD__ .
": disabled\n" );
267 $shownDisabled =
true;
273 # Loading code starts
274 $success =
false; # Keep track of success
275 $staleCache =
false; # a
cache array with expired
data, or
false if none has been loaded
276 $where = []; # Debug info, delayed to avoid spamming debug log too much
278 # Hash of the contents is stored in memcache, to detect if data-center cache
279 # or local cache goes out of date (e.g. due to replace() on some other server)
281 $this->mCacheVolatile[
$code] = $hashVolatile;
283 # Try the local cache and check against the cluster hash key...
286 $where[] =
'local cache is empty';
287 } elseif ( !isset(
$cache[
'HASH'] ) ||
$cache[
'HASH'] !== $hash ) {
288 $where[] =
'local cache has the wrong hash';
291 $where[] =
'local cache is expired';
293 } elseif ( $hashVolatile ) {
294 $where[] =
'local cache validation key is expired/volatile';
297 $where[] =
'got from local cache';
303 $cacheKey = $this->clusterCache->makeKey(
'messages',
$code );
304 # Try the global cache. If it is empty, try to acquire a lock. If
305 # the lock can't be acquired, wait for the other thread to finish
306 # and then try the global cache a second time.
307 for ( $failedAttempts = 0; $failedAttempts <= 1; $failedAttempts++ ) {
308 if ( $hashVolatile && $staleCache ) {
309 # Do not bother fetching the whole cache blob to avoid I/O.
310 # Instead, just try to get the non-blocking $statusKey lock
311 # below, and use the local stale value if it was not acquired.
312 $where[] =
'global cache is presumed expired';
314 $cache = $this->clusterCache->get( $cacheKey );
316 $where[] =
'global cache is empty';
318 $where[] =
'global cache is expired';
320 } elseif ( $hashVolatile ) {
321 # DB results are replica DB lag prone until the holdoff TTL passes.
322 # By then, updates should be reflected in loadFromDBWithLock().
323 # One thread renerates the cache while others use old values.
324 $where[] =
'global cache is expired/volatile';
327 $where[] =
'got from global cache';
335 # Done, no need to retry
339 # We need to call loadFromDB. Limit the concurrency to one process.
340 # This prevents the site from going down when the cache expires.
341 # Note that the DB slam protection lock here is non-blocking.
343 if ( $loadStatus ===
true ) {
346 } elseif ( $staleCache ) {
347 # Use the stale cache while some other thread constructs the new one
348 $where[] =
'using stale cache';
349 $this->mCache[
$code] = $staleCache;
352 } elseif ( $failedAttempts > 0 ) {
353 # Already blocked once, so avoid another lock/unlock cycle.
354 # This case will typically be hit if memcached is down, or if
355 # loadFromDB() takes longer than LOCK_WAIT.
356 $where[] =
"could not acquire status key.";
358 } elseif ( $loadStatus ===
'cantacquire' ) {
359 # Wait for the other thread to finish, then retry. Normally,
360 # the memcached get() will then yeild the other thread's result.
361 $where[] =
'waited for other thread to complete';
364 # Disable cache; $loadStatus is 'disabled'
371 $where[] =
'loading FAILED - cache is disabled';
372 $this->mDisable =
true;
373 $this->mCache =
false;
374 wfDebugLog(
'MessageCacheError', __METHOD__ .
": Failed to load $code\n" );
375 # This used to throw an exception, but that led to nasty side effects like
376 # the whole wiki being instantly down if the memcached server died
378 # All good, just record the success
379 $this->mLoadedLanguages[
$code] =
true;
382 $info = implode(
', ', $where );
383 wfDebugLog(
'MessageCache', __METHOD__ .
": Loading $code... $info\n" );
395 # If cache updates on all levels fail, give up on message overrides.
396 # This is to avoid easy site outages; see $saveSuccess comments below.
397 $statusKey = $this->clusterCache->makeKey(
'messages',
$code,
'status' );
398 $status = $this->clusterCache->get( $statusKey );
400 $where[] =
"could not load; method is still globally disabled";
404 # Now let's regenerate
405 $where[] =
'loading from database';
407 # Lock the cache to prevent conflicting writes.
408 # This lock is non-blocking so stale cache can quickly be used.
409 # Note that load() will call a blocking getReentrantScopedLock()
410 # after this if it really need to wait for any current thread.
411 $cacheKey = $this->clusterCache->makeKey(
'messages',
$code );
413 if ( !$scopedLock ) {
414 $where[] =
'could not acquire main lock';
415 return 'cantacquire';
422 if ( !$saveSuccess ) {
437 $this->clusterCache->set( $statusKey,
'error', 60 * 5 );
438 $where[] =
'could not save cache, disabled globally for 5 minutes';
440 $where[] =
"could not save global cache";
469 'page_is_redirect' => 0,
476 $this->
load( $wgLanguageCode );
479 foreach ( $mostused as $key =>
$value ) {
480 $mostused[$key] =
"$value/$code";
484 if ( count( $mostused ) ) {
485 $conds[
'page_title'] = $mostused;
487 $conds[] =
'page_title' .
$dbr->buildLike(
$dbr->anyString(),
'/',
$code );
489 # Effectively disallows use of '/' character in NS_MEDIAWIKI for uses
490 # other than language code.
491 $conds[] =
'page_title NOT' .
492 $dbr->buildLike(
$dbr->anyString(),
'/',
$dbr->anyString() );
495 # Conditions to fetch oversized pages to ignore them
499 # Load titles for all oversized pages in the MediaWiki namespace
502 [
'page_title',
'page_latest' ],
504 __METHOD__ .
"($code)-big"
506 foreach (
$res as $row ) {
507 $cache[$row->page_title] =
'!TOO BIG';
509 $cache[
'EXCESSIVE'][$row->page_title] = $row->page_latest;
512 # Conditions to load the remaining pages with their contents
513 $smallConds = $conds;
517 [
'page',
'revision',
'text' ],
518 [
'page_title',
'old_id',
'old_text',
'old_flags' ],
520 __METHOD__ .
"($code)-small",
523 'revision' => [
'JOIN',
'page_latest=rev_id' ],
524 'text' => [
'JOIN',
'rev_text_id=old_id' ],
528 foreach (
$res as $row ) {
529 $text = Revision::getRevisionText( $row );
530 if ( $text ===
false ) {
538 .
": failed to load message page text for {$row->page_title} ($code)"
541 $entry =
' ' . $text;
543 $cache[$row->page_title] = $entry;
549 # Hash for validating local cache (APC). No need to take into account
550 # messages larger than $wgMaxMsgCacheEntrySize, since those are only
551 # stored and fetched from memcache.
567 if ( $this->mDisable ) {
578 if ( $text ===
false ) {
587 DeferredUpdates::addCallableUpdate(
588 function () use ( $title, $msg,
$code ) {
592 $this->clusterCache->makeKey(
'messages',
$code )
594 if ( !$scopedLock ) {
595 LoggerFactory::getInstance(
'MessageCache' )->error(
596 __METHOD__ .
': could not acquire lock to update {title} ({code})',
597 [
'title' => $title,
'code' =>
$code ] );
604 $page = WikiPage::factory( Title::makeTitle( NS_MEDIAWIKI, $title ) );
605 $page->loadPageData( $page::READ_LATEST );
610 $this->wanCache->set( $titleKey,
' ' . $text, $this->mExpiry );
614 $this->mCache[
$code][
'LATEST'] = time();
621 ScopedCallback::consume( $scopedLock );
625 $this->wanCache->touchCheckKey( $this->
getCheckKey( $code ) );
629 $blobStore = $resourceloader->getMessageBlobStore();
630 $blobStore->updateMessage(
$wgContLang->lcfirst( $msg ) );
632 Hooks::run(
'MessageCacheReplace', [ $title, $text ] );
634 DeferredUpdates::PRESEND
645 if ( !isset(
$cache[
'VERSION'] ) || !isset(
$cache[
'EXPIRY'] ) ) {
668 if ( $dest ===
'all' ) {
669 $cacheKey = $this->clusterCache->makeKey(
'messages',
$code );
689 $value = $this->wanCache->get(
690 $this->wanCache->makeKey(
'messages',
$code,
'hash',
'v1' ),
692 [ $this->getCheckKey(
$code ) ]
697 if ( ( time() -
$value[
'latest'] ) < WANObjectCache::TTL_MINUTE ) {
704 $expired = ( $curTTL < 0 );
712 return [ $hash, $expired ];
726 $this->wanCache->set(
727 $this->wanCache->makeKey(
'messages',
$code,
'hash',
'v1' ),
730 'latest' => isset(
$cache[
'LATEST'] ) ?
$cache[
'LATEST'] : 0
732 WANObjectCache::TTL_INDEFINITE
742 return $this->clusterCache->getScopedLock( $key, $timeout, self::LOCK_TTL, __METHOD__ );
779 function get( $key, $useDB =
true, $langcode =
true, $isFullKey =
false ) {
780 if ( is_int( $key ) ) {
784 } elseif ( !is_string( $key ) ) {
786 } elseif ( $key ===
'' ) {
792 $pos = strrpos( $key,
'/' );
793 if ( $isFullKey && $pos !==
false ) {
794 $langcode = substr( $key, $pos + 1 );
795 $key = substr( $key, 0, $pos );
801 Hooks::run(
'MessageCache::get', [ &$lckey ] );
808 !$this->mDisable && $useDB
812 if ( $message ===
false ) {
813 $parts = explode(
'/', $lckey );
817 if ( count( $parts ) == 2 && $parts[1] !==
'' ) {
818 $message = Language::getMessageFor( $parts[0], $parts[1] );
819 if ( $message ===
null ) {
826 if ( $message !==
false ) {
828 $message = str_replace(
830 # Fix
for trailing whitespace, removed by textarea
832 # Fix
for NBSP, converted to space by firefox
869 if ( $message !==
false ) {
874 $message = $this->
getMessageForLang( $wgContLang, $lckey, $useDB, $alreadyTried );
891 $langcode =
$lang->getCode();
897 if ( !isset( $alreadyTried[$langcode] ) ) {
903 if ( $message !==
false ) {
906 $alreadyTried[$langcode] =
true;
913 $message =
$lang->getMessage( $lckey );
914 if ( $message !==
null ) {
920 $fallbackChain = Language::getFallbacksFor( $langcode );
922 foreach ( $fallbackChain as
$code ) {
923 if ( isset( $alreadyTried[
$code] ) ) {
930 if ( $message !==
false ) {
933 $alreadyTried[
$code] =
true;
954 return "$uckey/$langcode";
973 if ( isset( $this->mCache[
$code][$title] ) ) {
975 if ( substr( $entry, 0, 1 ) ===
' ' ) {
977 return (
string)substr( $entry, 1 );
978 } elseif ( $entry ===
'!NONEXISTENT' ) {
985 Hooks::run(
'MessagesPreLoad', [ $title, &$message,
$code ] );
986 if ( $message !==
false ) {
996 if ( $this->mCacheVolatile[
$code] ) {
999 LoggerFactory::getInstance(
'MessageCache' )->debug(
1000 __METHOD__ .
': loading volatile key \'{titleKey}\'',
1001 [
'titleKey' => $titleKey,
'code' =>
$code ] );
1004 $entry = $this->wanCache->get( $titleKey );
1007 if ( $entry !==
false ) {
1008 if ( substr( $entry, 0, 1 ) ===
' ' ) {
1011 return (
string)substr( $entry, 1 );
1012 } elseif ( $entry ===
'!NONEXISTENT' ) {
1018 $this->wanCache->delete( $titleKey );
1024 $cacheOpts = Database::getCacheSetOptions(
$dbr );
1026 $titleObj = Title::makeTitle( NS_MEDIAWIKI, $title );
1027 if ( $titleObj->getLatestRevID() ) {
1028 $revision = Revision::newKnownCurrent(
1037 $content = $revision->getContent();
1040 if ( is_string( $message ) ) {
1042 $this->wanCache->set( $titleKey,
' ' . $message, $this->mExpiry, $cacheOpts );
1046 LoggerFactory::getInstance(
'MessageCache' )->warning(
1047 __METHOD__ .
': failed to load message page text for \'{titleKey}\'',
1048 [
'titleKey' => $titleKey,
'code' =>
$code ] );
1055 if ( $message ===
false ) {
1058 $this->wanCache->set( $titleKey,
'!NONEXISTENT', $this->mExpiry, $cacheOpts );
1071 public function transform( $message, $interface =
false, $language =
null, $title =
null ) {
1073 if ( strpos( $message,
'{{' ) ===
false ) {
1077 if ( $this->mInParser ) {
1084 $popts->setInterfaceMessage( $interface );
1085 $popts->setTargetLanguage( $language );
1087 $userlang = $popts->setUserLang( $language );
1088 $this->mInParser =
true;
1089 $message =
$parser->transformMsg( $message, $popts, $title );
1090 $this->mInParser =
false;
1091 $popts->setUserLang( $userlang );
1103 if ( !$this->mParser && isset(
$wgParser ) ) {
1104 # Do some initialisation so that we don't have to do it twice
1106 # Clone it and store it
1108 if ( $class == ParserDiffTest::class ) {
1127 public function parse( $text, $title =
null, $linestart =
true,
1128 $interface =
false, $language =
null
1132 if ( $this->mInParser ) {
1133 return htmlspecialchars( $text );
1138 $popts->setInterfaceMessage( $interface );
1140 if ( is_string( $language ) ) {
1141 $language = Language::factory( $language );
1143 $popts->setTargetLanguage( $language );
1145 if ( !$title || !$title instanceof
Title ) {
1146 wfDebugLog(
'GlobalTitleFail', __METHOD__ .
' called by ' .
1152 # It's not uncommon having a null $wgTitle in scripts. See r80898
1153 # Create a ghost title in such case
1154 $title = Title::makeTitle(
NS_SPECIAL,
'Badtitle/title not set in ' . __METHOD__ );
1157 $this->mInParser =
true;
1158 $res =
$parser->parse( $text, $title, $popts, $linestart );
1159 $this->mInParser =
false;
1165 $this->mDisable =
true;
1169 $this->mDisable =
false;
1194 $langs = Language::fetchLanguageNames(
null,
'mw' );
1195 foreach ( array_keys( $langs ) as
$code ) {
1196 $this->wanCache->touchCheckKey( $this->
getCheckKey( $code ) );
1199 $this->mLoadedLanguages = [];
1209 $pieces = explode(
'/', $key );
1210 if ( count( $pieces ) < 2 ) {
1214 $lang = array_pop( $pieces );
1215 if ( !Language::fetchLanguageName(
$lang,
null,
'mw' ) ) {
1219 $message = implode(
'/', $pieces );
1221 return [ $message,
$lang ];
1236 if ( !isset( $this->mCache[
$code] ) ) {
1242 unset(
$cache[
'VERSION'] );
1243 unset(
$cache[
'EXPIRY'] );
1244 unset(
$cache[
'EXCESSIVE'] );
1263 if ( $msgText ===
null ) {
1279 return $this->wanCache->makeKey(
'messages',
$code );
1294 $msgText = $content->getWikitextForTransclusion();
1295 if ( $msgText ===
false || $msgText ===
null ) {
1298 LoggerFactory::getInstance(
'MessageCache' )->warning(
1299 __METHOD__ .
": message content doesn't provide wikitext "
1300 .
"(content model: " . $content->getModel() .
")" );
1316 return $this->wanCache->makeKey(
'messages-big', $hash, $title );
$wgLanguageCode
Site language code.
$wgUseLocalMessageCache
Set this to true to maintain a copy of the message cache on the local server.
$wgAdaptiveMessageCache
Instead of caching everything, only cache those messages which have been customised in the site conte...
$wgUseDatabaseMessages
Translation using MediaWiki: namespace.
$wgMaxMsgCacheEntrySize
Maximum entry size in the message cache, in bytes.
$wgParserConf
Parser configuration.
$wgMsgCacheExpiry
Expiry time for the message cache key.
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfGetMessageCacheStorage()
Get the cache object used by the message cache.
wfGetAllCallers( $limit=3)
Return a string consisting of callers in the stack.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
const MSG_CACHE_VERSION
MediaWiki message cache structure version.
if(! $wgRequest->checkUrlExtension()) if(isset($_SERVER[ 'PATH_INFO']) &&$_SERVER[ 'PATH_INFO'] !='') if(! $wgEnableAPI) $wgTitle
interface is intended to be more or less compatible with the PHP memcached client.
A BagOStuff object with no objects in it.
Message cache Performs various MediaWiki namespace-related functions.
getValidationHash( $code)
Get the md5 used to validate the local APC cache.
loadFromDBWithLock( $code, array &$where, $mode=null)
const LOCK_TTL
How long memcached locks last.
loadFromDB( $code, $mode=null)
Loads cacheable messages from the database.
getMessageForLang( $lang, $lckey, $useDB, &$alreadyTried)
Given a language, try and fetch messages from that language and its fallbacks.
$mExpiry
Lifetime for cache, used by object caching.
saveToLocalCache( $code, $cache)
Save the cache to APC.
getMessagePageName( $langcode, $uckey)
Get the message page name for a given language.
static $instance
Singleton instance.
saveToCaches(array $cache, $dest, $code=false)
Shortcut to update caches.
setValidationHash( $code, array $cache)
Set the md5 used to validate the local disk cache.
bool[] $mCacheVolatile
Map of (language code => boolean)
isCacheExpired( $cache)
Is the given cache array expired due to time passing or a version change?
getMsgFromNamespace( $title, $code)
Get a message from the MediaWiki namespace, with caching.
getReentrantScopedLock( $key, $timeout=self::WAIT_SEC)
const WAIT_SEC
How long to wait for memcached locks.
$mDisable
Should mean that database cannot be used, but check.
getLocalCache( $code)
Try to load the cache from APC.
static destroyInstance()
Destroy the singleton instance.
__construct(WANObjectCache $wanCache, BagOStuff $clusterCache, BagOStuff $serverCache, $useDB, $expiry)
load( $code, $mode=null)
Loads messages from caches or from database in this order: (1) local message cache (if $wgUseLocalMes...
transform( $message, $interface=false, $language=null, $title=null)
updateMessageOverride(Title $title, Content $content=null)
Purge message caches when a MediaWiki: page is created, updated, or deleted.
getMessageFromFallbackChain( $lang, $lckey, $useDB)
Given a language, try and fetch messages from that language.
$mLoadedLanguages
Variable for tracking which variables are already loaded.
isDisabled()
Whether DB/cache usage is disabled for determining messages.
getMessageTextFromContent(Content $content=null)
clear()
Clear all stored messages in global and local cache.
static singleton()
Get the signleton instance of this class.
getAllMessageKeys( $code)
Get all message keys stored in the message cache for a given language.
$mCache
Process local cache of loaded messages that are defined in MediaWiki namespace.
static normalizeKey( $key)
Normalize message key input.
parse( $text, $title=null, $linestart=true, $interface=false, $language=null)
ParserOptions $mParserOptions
Message cache has its own parser which it uses to transform messages.
replace( $title, $text)
Updates cache as necessary when message page is changed.
getParserOptions()
ParserOptions is lazy initialised.
bigMessageCacheKey( $hash, $title)
Set options of the Parser.
setAllowUnsafeRawHtml( $x)
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
static getMain()
Get the RequestContext object associated with the main request.
Represents a title within MediaWiki.
getDBkey()
Get the main part with underscores.
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
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 local content language as $wgContLang
do that in ParserLimitReportFormat instead $parser
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy: boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
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
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
namespace and then decline to actually register it file or subcat img or subcat $title
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place replace
processing should stop and the error should be shown to the user * false
Base interface for content objects.
you have access to all of the normal MediaWiki so you can get a DB use the cache
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy load
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a and VARBINARY columns should simply be TEXT The only exception is when VARBINARY is used to store true binary data
if(!isset( $args[0])) $lang