177 'comma' =>
'commaList',
178 'semicolon' =>
'semicolonList',
179 'pipe' =>
'pipeList',
180 'text' =>
'listToText',
252 throw new InvalidArgumentException(
253 '$params must be empty if $key is a MessageSpecifier'
260 if ( !is_string(
$key ) && !is_array(
$key ) ) {
261 throw new InvalidArgumentException(
'$key must be a string or an array' );
266 if ( empty( $this->keysToTry ) ) {
267 throw new InvalidArgumentException(
'$key must not be an empty list' );
270 $this->
key = reset( $this->keysToTry );
272 $this->parameters = array_values(
$params );
285 'interface' => $this->interface,
286 'language' => $this->language ? $this->language->getCode() :
false,
288 'keysToTry' => $this->keysToTry,
289 'parameters' => $this->parameters,
290 'format' => $this->format,
291 'useDatabase' => $this->useDatabase,
292 'titlestr' => $this->
title ? $this->
title->getFullText() :
null,
303 if ( !is_array(
$data ) ) {
304 throw new InvalidArgumentException( __METHOD__ .
': Invalid serialized data' );
307 $this->
interface =
$data['interface'];
309 $this->keysToTry =
$data[
'keysToTry'];
310 $this->parameters =
$data[
'parameters'];
313 $this->language =
$data[
'language'] ? Language::factory(
$data[
'language'] ) :
false;
315 if ( isset(
$data[
'titlestr'] ) ) {
316 $this->
title = Title::newFromText(
$data[
'titlestr'] );
317 } elseif ( isset(
$data[
'title'] ) &&
$data[
'title'] instanceof
Title ) {
332 return count( $this->keysToTry ) > 1;
342 return $this->keysToTry;
368 return $this->parameters;
381 return $this->format;
393 return $this->language ?: RequestContext::getMain()->getLanguage();
429 if ( is_array(
$value ) ) {
438 } elseif ( is_string(
$value ) ) {
441 throw new InvalidArgumentException( __METHOD__ .
': invalid argument type '
461 $keys = func_get_args();
462 if ( func_num_args() == 1 ) {
463 if ( is_array(
$keys[0] ) ) {
471 return new self(
$keys );
487 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
491 !
$lang->equals( $contLang )
492 && in_array( $this->
key, (
array)$wgForceUIMsgAsContentMsg )
497 return Title::makeTitle(
512 $args = func_get_args();
518 if ( count(
$args ) === 1 && isset(
$args[0] ) && is_array(
$args[0] ) ) {
519 if (
$args[0] === [] ) {
523 if ( is_int(
$key ) ) {
531 $this->parameters = array_merge( $this->parameters, array_values(
$args ) );
554 $this->parameters[] = self::rawParam( $param );
576 $this->parameters[] = self::numParam( $param );
598 $this->parameters[] = self::durationParam( $param );
620 $this->parameters[] = self::expiryParam( $param );
642 $this->parameters[] = self::timeperiodParam( $param );
664 $this->parameters[] = self::sizeParam( $param );
686 $this->parameters[] = self::bitrateParam( $param );
710 $this->parameters[] = self::plaintextParam( $param );
727 $this->
interface =
true;
744 $previousLanguage = $this->language;
747 $this->language =
$lang;
748 } elseif ( is_string(
$lang ) ) {
750 $this->language = Language::factory(
$lang );
753 $this->language =
false;
757 .
"passed a String or Language object; $type given"
761 if ( $this->language !== $previousLanguage ) {
765 $this->
interface =
false;
780 if ( in_array( $this->
key, (
array)$wgForceUIMsgAsContentMsg ) ) {
784 $this->
inLanguage( MediaWikiServices::getInstance()->getContentLanguage() );
799 $this->
interface = (bool)$interface;
858 $ex =
new LogicException( __METHOD__ .
' using implicit format: ' . $this->
format );
859 \MediaWiki\Logger\LoggerFactory::getInstance(
'message-format' )->warning(
860 $ex->getMessage(), [
'exception' => $ex,
'format' => $this->format,
'key' => $this->key ] );
865 if ( $string ===
false ) {
873 return '⧼' . htmlspecialchars( $this->
key ) .
'⧽';
876 # Replace $* with a list of parameters for &uselang=qqx.
877 if ( strpos( $string,
'$*' ) !==
false ) {
879 if ( $this->parameters !== [] ) {
880 $paramlist =
': $' . implode(
', $', range( 1, count( $this->parameters ) ) );
882 $string = str_replace(
'$*', $paramlist, $string );
885 # Replace parameters before text parsing
888 # Maybe transform using the full parser
889 if (
$format === self::FORMAT_PARSE ) {
891 $string = Parser::stripOuterParagraph( $string );
892 } elseif (
$format === self::FORMAT_BLOCK_PARSE ) {
894 } elseif (
$format === self::FORMAT_TEXT ) {
896 } elseif (
$format === self::FORMAT_ESCAPED ) {
898 $string = htmlspecialchars( $string, ENT_QUOTES,
'UTF-8',
false );
901 # Raw parameter replacement
921 return $this->
toString( self::FORMAT_PARSE );
922 }
catch ( Exception $ex ) {
924 trigger_error(
"Exception caught in " . __METHOD__ .
" (message " . $this->
key .
"): "
925 . $ex, E_USER_WARNING );
926 }
catch ( Exception $ex ) {
930 return '⧼' . htmlspecialchars( $this->
key ) .
'⧽';
942 $this->
format = self::FORMAT_PARSE;
943 return $this->
toString( self::FORMAT_PARSE );
954 $this->
format = self::FORMAT_TEXT;
955 return $this->
toString( self::FORMAT_TEXT );
966 $this->
format = self::FORMAT_PLAIN;
967 return $this->
toString( self::FORMAT_PLAIN );
978 $this->
format = self::FORMAT_BLOCK_PARSE;
979 return $this->
toString( self::FORMAT_BLOCK_PARSE );
991 $this->
format = self::FORMAT_ESCAPED;
992 return $this->
toString( self::FORMAT_ESCAPED );
1039 return [
'raw' => $raw ];
1050 return [
'num' => $num ];
1061 return [
'duration' => $duration ];
1072 return [
'expiry' => $expiry ];
1083 return [
'period' => $period ];
1094 return [
'size' => $size ];
1105 return [
'bitrate' => $bitrate ];
1116 return [
'plaintext' => $plaintext ];
1127 if ( !isset( self::$listTypeMap[
$type] ) ) {
1128 throw new InvalidArgumentException(
1129 "Invalid type '$type'. Known types are: " . implode(
', ', array_keys( self::$listTypeMap ) )
1132 return [
'list' => $list,
'type' =>
$type ];
1151 $marker =
$format === self::FORMAT_ESCAPED ?
'$' :
'$\'"';
1152 $replacementKeys = [];
1153 foreach ( $this->parameters
as $n => $param ) {
1155 if (
$type ===
'before' ) {
1156 if ( $paramType ===
'before' ) {
1157 $replacementKeys[
'$' . ( $n + 1 )] =
$value;
1164 $replacementKeys[
'$' . ( $n + 1 )] = $marker . ( $n + 1 );
1166 } elseif ( $paramType ===
'after' ) {
1167 $replacementKeys[$marker . ( $n + 1 )] =
$value;
1170 return strtr(
$message, $replacementKeys );
1184 if ( is_array( $param ) ) {
1185 if ( isset( $param[
'raw'] ) ) {
1186 return [
'after', $param[
'raw'] ];
1187 } elseif ( isset( $param[
'num'] ) ) {
1190 return [
'before', $this->
getLanguage()->formatNum( $param[
'num'] ) ];
1191 } elseif ( isset( $param[
'duration'] ) ) {
1192 return [
'before', $this->
getLanguage()->formatDuration( $param[
'duration'] ) ];
1193 } elseif ( isset( $param[
'expiry'] ) ) {
1194 return [
'before', $this->
getLanguage()->formatExpiry( $param[
'expiry'] ) ];
1195 } elseif ( isset( $param[
'period'] ) ) {
1196 return [
'before', $this->
getLanguage()->formatTimePeriod( $param[
'period'] ) ];
1197 } elseif ( isset( $param[
'size'] ) ) {
1198 return [
'before', $this->
getLanguage()->formatSize( $param[
'size'] ) ];
1199 } elseif ( isset( $param[
'bitrate'] ) ) {
1200 return [
'before', $this->
getLanguage()->formatBitrate( $param[
'bitrate'] ) ];
1201 } elseif ( isset( $param[
'plaintext'] ) ) {
1203 } elseif ( isset( $param[
'list'] ) ) {
1206 if ( !is_scalar( $param ) ) {
1209 \MediaWiki\Logger\LoggerFactory::getInstance(
'Bug58676' )->warning(
1210 'Invalid parameter for message "{msgkey}": {param}',
1212 'exception' =>
new Exception,
1213 'msgkey' => $this->
getKey(),
1214 'param' => htmlspecialchars( $param ),
1218 return [
'before',
'[INVALID]' ];
1220 } elseif ( $param instanceof
Message ) {
1222 $msg = clone $param;
1223 if ( $msg->language !== $this->language || $msg->useDatabase !== $this->useDatabase ) {
1225 $msg->message =
null;
1227 $msg->interface = $this->interface;
1228 $msg->language = $this->language;
1229 $msg->useDatabase = $this->useDatabase;
1230 $msg->title = $this->title;
1233 if (
$format ===
'block-parse' ) {
1241 return [
'after', $msg->toString(
$format ) ];
1243 return [
'before', $param ];
1257 $out = MessageCache::singleton()->parse(
1267 'enableSectionEditLinks' =>
false,
1287 return MessageCache::singleton()->transform(
1304 if ( $this->
message ===
null ) {
1305 $cache = MessageCache::singleton();
1307 foreach ( $this->keysToTry
as $key ) {
1319 return $this->message;
1336 case self::FORMAT_TEXT:
1337 case self::FORMAT_PLAIN:
1340 case self::FORMAT_PARSE:
1341 case self::FORMAT_BLOCK_PARSE:
1342 case self::FORMAT_ESCAPED:
1344 return htmlspecialchars( $plaintext, ENT_QUOTES );
1357 if ( !isset( self::$listTypeMap[$listType] ) ) {
1358 $warning =
'Invalid list type for message "' . $this->
getKey() .
'": '
1359 . htmlspecialchars( $listType )
1361 trigger_error( $warning, E_USER_WARNING );
1363 wfDebugLog(
'Bug58676', $warning .
"\n" .
$e->getTraceAsString() );
1364 return [
'before',
'[INVALID]' ];
1366 $func = self::$listTypeMap[$listType];
1370 return [
'before', $this->
getLanguage()->$func( [] ) ];
1379 $types[
$type] =
true;
1381 $vars[] =
'$' . ( $n + 1 );
1386 if ( count( $types ) === 1 ) {
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
unserialize( $serialized)
$wgForceUIMsgAsContentMsg
When translating messages with wfMessage(), it is not always clear what should be considered UI messa...
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Internationalisation code.
getCode()
Get the internal language code for this language object.
Wrapper allowing us to handle a system message as a Content object.
The Message class provides methods which fulfil two basic services:
extractParam( $param, $format)
Extracts the parameter type and preprocessed the value if needed.
static listParam(array $list, $type='text')
timeperiodParams()
Add parameters that are time periods and will be passed through Language::formatTimePeriod before sub...
const FORMAT_TEXT
Transform {{..}} constructs but don't transform to HTML.
transformText( $string)
Wrapper for what ever method we use to {{-transform wikitext.
getParams()
Returns the message parameters.
durationParams()
Add parameters that are durations of time and will be passed through Language::formatDuration before ...
static bitrateParam( $bitrate)
static newFromKey( $key)
Factory function that is just wrapper for the real constructor.
numParams()
Add parameters that are numeric and will be passed through Language::formatNum before substitution.
static array $listTypeMap
Mapping from Message::listParam() types to Language methods.
isBlank()
Check whether a message does not exist, or is an empty string.
setInterfaceMessageFlag( $interface)
Allows manipulating the interface message flag directly.
parseAsBlock()
Returns the parsed message text which is always surrounded by a block element.
__construct( $key, $params=[], Language $language=null)
bool $useDatabase
Whether database can be used.
parse()
Fully parse the text from wikitext to HTML.
const FORMAT_PARSE
Use normal wikitext -> HTML parsing but strip the block-level wrapper.
__toString()
Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg: $foo = new Message( $k...
static newFallbackSequence()
Factory function accepting multiple message keys and returning a message instance for the first messa...
unserialize( $serialized)
const FORMAT_BLOCK_PARSE
Use normal wikitext -> HTML parsing (the result will be wrapped in a block-level HTML tag)
formatListParam(array $params, $listType, $format)
Formats a list of parameters as a concatenated string.
static timeperiodParam( $period)
array $parameters
List of parameters which will be substituted into the message.
static plaintextParam( $plaintext)
const FORMAT_PLAIN
Use message text as-is.
static durationParam( $duration)
const FORMAT_ESCAPED
Transform {{..}} constructs, HTML-escape the result.
inLanguage( $lang)
Request the message in any language that is supported.
replaceParameters( $message, $type, $format)
Substitutes any parameters into the message text.
string $key
The message key.
sizeParams()
Add parameters that are file sizes and will be passed through Language::formatSize before substitutio...
expiryParams()
Add parameters that are expiration times and will be passed through Language::formatExpiry before sub...
inContentLanguage()
Request the message in the wiki's content language, unless it is disabled for this message.
plain()
Returns the message text as-is, only parameters are substituted.
exists()
Check whether a message key has been defined currently.
plaintextParams()
Add parameters that are plaintext and will be passed through without the content being evaluated.
rawParams()
Add parameters that are substituted after parsing or escaping.
title( $title)
Set the Title object to use as context when transforming the message.
Language bool $language
In which language to get this message.
getFormat()
Returns the message format.
useDatabase( $useDatabase)
Enable or disable database use.
fetchMessage()
Wrapper for what ever method we use to get message contents.
content()
Returns the message as a Content object.
formatPlaintext( $plaintext, $format)
Formats a message parameter wrapped with 'plaintext'.
getTitle()
Get a title object for a mediawiki message, where it can be found in the mediawiki namespace.
bitrateParams()
Add parameters that are bitrates and will be passed through Language::formatBitrate before substituti...
parseText( $string)
Wrapper for what ever method we use to parse wikitext.
getKey()
Returns the message key.
isDisabled()
Check whether a message does not exist, is an empty string, or is "-".
escaped()
Returns the message text.
params()
Adds parameters to the parameter list of this message.
getLanguage()
Returns the Language of the Message.
string[] $keysToTry
List of keys to try when fetching the message.
setContext(IContextSource $context)
Set the language and the title from a context object.
toString( $format=null)
Returns the message parsed from wikitext to HTML.
Title $title
Title object to use as context.
text()
Returns the message text.
static newFromSpecifier( $value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...
bool $interface
In which language to get this message.
static expiryParam( $expiry)
getText( $options=[])
Get the output HTML.
Variant of the Message class.
Stub object for the user language.
Represents a title within MediaWiki.
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 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
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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 $out
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message key
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
namespace and then decline to actually register it file or subcat img or subcat $title
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
if the prop value should be in the metadata multi language array format
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a message
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
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
Base interface for content objects.
Interface for objects which can provide a MediaWiki context on request.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
foreach( $res as $row) $serialized
if(!isset( $args[0])) $lang