MediaWiki REL1_28
Message.php
Go to the documentation of this file.
1<?php
159class Message implements MessageSpecifier, Serializable {
160
167 protected $interface = true;
168
174 protected $language = false;
175
180 protected $key;
181
185 protected $keysToTry;
186
190 protected $parameters = [];
191
203 protected $format = 'parse';
204
208 protected $useDatabase = true;
209
213 protected $title = null;
214
218 protected $content = null;
219
223 protected $message;
224
234 public function __construct( $key, $params = [], Language $language = null ) {
235 if ( $key instanceof MessageSpecifier ) {
236 if ( $params ) {
237 throw new InvalidArgumentException(
238 '$params must be empty if $key is a MessageSpecifier'
239 );
240 }
241 $params = $key->getParams();
242 $key = $key->getKey();
243 }
244
245 if ( !is_string( $key ) && !is_array( $key ) ) {
246 throw new InvalidArgumentException( '$key must be a string or an array' );
247 }
248
249 $this->keysToTry = (array)$key;
250
251 if ( empty( $this->keysToTry ) ) {
252 throw new InvalidArgumentException( '$key must not be an empty list' );
253 }
254
255 $this->key = reset( $this->keysToTry );
256
257 $this->parameters = array_values( $params );
258 // User language is only resolved in getLanguage(). This helps preserve the
259 // semantic intent of "user language" across serialize() and unserialize().
260 $this->language = $language ?: false;
261 }
262
268 public function serialize() {
269 return serialize( [
270 'interface' => $this->interface,
271 'language' => $this->language ? $this->language->getCode() : false,
272 'key' => $this->key,
273 'keysToTry' => $this->keysToTry,
274 'parameters' => $this->parameters,
275 'format' => $this->format,
276 'useDatabase' => $this->useDatabase,
277 'title' => $this->title,
278 ] );
279 }
280
286 public function unserialize( $serialized ) {
287 $data = unserialize( $serialized );
288 $this->interface = $data['interface'];
289 $this->key = $data['key'];
290 $this->keysToTry = $data['keysToTry'];
291 $this->parameters = $data['parameters'];
292 $this->format = $data['format'];
293 $this->useDatabase = $data['useDatabase'];
294 $this->language = $data['language'] ? Language::factory( $data['language'] ) : false;
295 $this->title = $data['title'];
296 }
297
304 public function isMultiKey() {
305 return count( $this->keysToTry ) > 1;
306 }
307
314 public function getKeysToTry() {
315 return $this->keysToTry;
316 }
317
329 public function getKey() {
330 return $this->key;
331 }
332
340 public function getParams() {
341 return $this->parameters;
342 }
343
351 public function getFormat() {
352 return $this->format;
353 }
354
362 public function getLanguage() {
363 // Defaults to false which means current user language
364 return $this->language ?: RequestContext::getMain()->getLanguage();
365 }
366
379 public static function newFromKey( $key /*...*/ ) {
380 $params = func_get_args();
381 array_shift( $params );
382 return new self( $key, $params );
383 }
384
398 public static function newFromSpecifier( $value ) {
399 $params = [];
400 if ( is_array( $value ) ) {
401 $params = $value;
402 $value = array_shift( $params );
403 }
404
405 if ( $value instanceof Message ) { // Message, RawMessage, ApiMessage, etc
406 $message = clone( $value );
407 } elseif ( $value instanceof MessageSpecifier ) {
408 $message = new Message( $value );
409 } elseif ( is_string( $value ) ) {
410 $message = new Message( $value, $params );
411 } else {
412 throw new InvalidArgumentException( __METHOD__ . ': invalid argument type '
413 . gettype( $value ) );
414 }
415
416 return $message;
417 }
418
431 public static function newFallbackSequence( /*...*/ ) {
432 $keys = func_get_args();
433 if ( func_num_args() == 1 ) {
434 if ( is_array( $keys[0] ) ) {
435 // Allow an array to be passed as the first argument instead
436 $keys = array_values( $keys[0] );
437 } else {
438 // Optimize a single string to not need special fallback handling
439 $keys = $keys[0];
440 }
441 }
442 return new self( $keys );
443 }
444
455 public function getTitle() {
457
458 $title = $this->key;
459 if (
460 !$this->language->equals( $wgContLang )
461 && in_array( $this->key, (array)$wgForceUIMsgAsContentMsg )
462 ) {
463 $code = $this->language->getCode();
464 $title .= '/' . $code;
465 }
466
467 return Title::makeTitle( NS_MEDIAWIKI, $wgContLang->ucfirst( strtr( $title, ' ', '_' ) ) );
468 }
469
480 public function params( /*...*/ ) {
481 $args = func_get_args();
482 if ( isset( $args[0] ) && is_array( $args[0] ) ) {
483 $args = $args[0];
484 }
485 $args_values = array_values( $args );
486 $this->parameters = array_merge( $this->parameters, $args_values );
487 return $this;
488 }
489
503 public function rawParams( /*...*/ ) {
504 $params = func_get_args();
505 if ( isset( $params[0] ) && is_array( $params[0] ) ) {
506 $params = $params[0];
507 }
508 foreach ( $params as $param ) {
509 $this->parameters[] = self::rawParam( $param );
510 }
511 return $this;
512 }
513
525 public function numParams( /*...*/ ) {
526 $params = func_get_args();
527 if ( isset( $params[0] ) && is_array( $params[0] ) ) {
528 $params = $params[0];
529 }
530 foreach ( $params as $param ) {
531 $this->parameters[] = self::numParam( $param );
532 }
533 return $this;
534 }
535
547 public function durationParams( /*...*/ ) {
548 $params = func_get_args();
549 if ( isset( $params[0] ) && is_array( $params[0] ) ) {
550 $params = $params[0];
551 }
552 foreach ( $params as $param ) {
553 $this->parameters[] = self::durationParam( $param );
554 }
555 return $this;
556 }
557
569 public function expiryParams( /*...*/ ) {
570 $params = func_get_args();
571 if ( isset( $params[0] ) && is_array( $params[0] ) ) {
572 $params = $params[0];
573 }
574 foreach ( $params as $param ) {
575 $this->parameters[] = self::expiryParam( $param );
576 }
577 return $this;
578 }
579
591 public function timeperiodParams( /*...*/ ) {
592 $params = func_get_args();
593 if ( isset( $params[0] ) && is_array( $params[0] ) ) {
594 $params = $params[0];
595 }
596 foreach ( $params as $param ) {
597 $this->parameters[] = self::timeperiodParam( $param );
598 }
599 return $this;
600 }
601
613 public function sizeParams( /*...*/ ) {
614 $params = func_get_args();
615 if ( isset( $params[0] ) && is_array( $params[0] ) ) {
616 $params = $params[0];
617 }
618 foreach ( $params as $param ) {
619 $this->parameters[] = self::sizeParam( $param );
620 }
621 return $this;
622 }
623
635 public function bitrateParams( /*...*/ ) {
636 $params = func_get_args();
637 if ( isset( $params[0] ) && is_array( $params[0] ) ) {
638 $params = $params[0];
639 }
640 foreach ( $params as $param ) {
641 $this->parameters[] = self::bitrateParam( $param );
642 }
643 return $this;
644 }
645
659 public function plaintextParams( /*...*/ ) {
660 $params = func_get_args();
661 if ( isset( $params[0] ) && is_array( $params[0] ) ) {
662 $params = $params[0];
663 }
664 foreach ( $params as $param ) {
665 $this->parameters[] = self::plaintextParam( $param );
666 }
667 return $this;
668 }
669
679 public function setContext( IContextSource $context ) {
680 $this->inLanguage( $context->getLanguage() );
681 $this->title( $context->getTitle() );
682 $this->interface = true;
683
684 return $this;
685 }
686
698 public function inLanguage( $lang ) {
699 if ( $lang instanceof Language ) {
700 $this->language = $lang;
701 } elseif ( is_string( $lang ) ) {
702 if ( !$this->language instanceof Language || $this->language->getCode() != $lang ) {
703 $this->language = Language::factory( $lang );
704 }
705 } elseif ( $lang instanceof StubUserLang ) {
706 $this->language = false;
707 } else {
708 $type = gettype( $lang );
709 throw new MWException( __METHOD__ . " must be "
710 . "passed a String or Language object; $type given"
711 );
712 }
713 $this->message = null;
714 $this->interface = false;
715 return $this;
716 }
717
727 public function inContentLanguage() {
729 if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) {
730 return $this;
731 }
732
734 $this->inLanguage( $wgContLang );
735 return $this;
736 }
737
748 public function setInterfaceMessageFlag( $interface ) {
749 $this->interface = (bool)$interface;
750 return $this;
751 }
752
762 public function useDatabase( $useDatabase ) {
763 $this->useDatabase = (bool)$useDatabase;
764 return $this;
765 }
766
776 public function title( $title ) {
777 $this->title = $title;
778 return $this;
779 }
780
786 public function content() {
787 if ( !$this->content ) {
788 $this->content = new MessageContent( $this );
789 }
790
791 return $this->content;
792 }
793
801 public function toString() {
802 $string = $this->fetchMessage();
803
804 if ( $string === false ) {
805 // Err on the side of safety, ensure that the output
806 // is always html safe in the event the message key is
807 // missing, since in that case its highly likely the
808 // message key is user-controlled.
809 // '⧼' is used instead of '<' to side-step any
810 // double-escaping issues.
811 return '⧼' . htmlspecialchars( $this->key ) . '⧽';
812 }
813
814 # Replace $* with a list of parameters for &uselang=qqx.
815 if ( strpos( $string, '$*' ) !== false ) {
816 $paramlist = '';
817 if ( $this->parameters !== [] ) {
818 $paramlist = ': $' . implode( ', $', range( 1, count( $this->parameters ) ) );
819 }
820 $string = str_replace( '$*', $paramlist, $string );
821 }
822
823 # Replace parameters before text parsing
824 $string = $this->replaceParameters( $string, 'before' );
825
826 # Maybe transform using the full parser
827 if ( $this->format === 'parse' ) {
828 $string = $this->parseText( $string );
829 $string = Parser::stripOuterParagraph( $string );
830 } elseif ( $this->format === 'block-parse' ) {
831 $string = $this->parseText( $string );
832 } elseif ( $this->format === 'text' ) {
833 $string = $this->transformText( $string );
834 } elseif ( $this->format === 'escaped' ) {
835 $string = $this->transformText( $string );
836 $string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false );
837 }
838
839 # Raw parameter replacement
840 $string = $this->replaceParameters( $string, 'after' );
841
842 return $string;
843 }
844
854 public function __toString() {
855 if ( $this->format !== 'parse' ) {
856 $ex = new LogicException( __METHOD__ . ' using implicit format: ' . $this->format );
857 \MediaWiki\Logger\LoggerFactory::getInstance( 'message-format' )->warning(
858 $ex->getMessage(), [ 'exception' => $ex, 'format' => $this->format, 'key' => $this->key ] );
859 }
860
861 // PHP doesn't allow __toString to throw exceptions and will
862 // trigger a fatal error if it does. So, catch any exceptions.
863
864 try {
865 return $this->toString();
866 } catch ( Exception $ex ) {
867 try {
868 trigger_error( "Exception caught in " . __METHOD__ . " (message " . $this->key . "): "
869 . $ex, E_USER_WARNING );
870 } catch ( Exception $ex ) {
871 // Doh! Cause a fatal error after all?
872 }
873
874 if ( $this->format === 'plain' || $this->format === 'text' ) {
875 return '<' . $this->key . '>';
876 }
877 return '&lt;' . htmlspecialchars( $this->key ) . '&gt;';
878 }
879 }
880
888 public function parse() {
889 $this->format = 'parse';
890 return $this->toString();
891 }
892
900 public function text() {
901 $this->format = 'text';
902 return $this->toString();
903 }
904
912 public function plain() {
913 $this->format = 'plain';
914 return $this->toString();
915 }
916
924 public function parseAsBlock() {
925 $this->format = 'block-parse';
926 return $this->toString();
927 }
928
937 public function escaped() {
938 $this->format = 'escaped';
939 return $this->toString();
940 }
941
949 public function exists() {
950 return $this->fetchMessage() !== false;
951 }
952
961 public function isBlank() {
962 $message = $this->fetchMessage();
963 return $message === false || $message === '';
964 }
965
973 public function isDisabled() {
974 $message = $this->fetchMessage();
975 return $message === false || $message === '' || $message === '-';
976 }
977
985 public static function rawParam( $raw ) {
986 return [ 'raw' => $raw ];
987 }
988
996 public static function numParam( $num ) {
997 return [ 'num' => $num ];
998 }
999
1007 public static function durationParam( $duration ) {
1008 return [ 'duration' => $duration ];
1009 }
1010
1018 public static function expiryParam( $expiry ) {
1019 return [ 'expiry' => $expiry ];
1020 }
1021
1029 public static function timeperiodParam( $period ) {
1030 return [ 'period' => $period ];
1031 }
1032
1040 public static function sizeParam( $size ) {
1041 return [ 'size' => $size ];
1042 }
1043
1051 public static function bitrateParam( $bitrate ) {
1052 return [ 'bitrate' => $bitrate ];
1053 }
1054
1062 public static function plaintextParam( $plaintext ) {
1063 return [ 'plaintext' => $plaintext ];
1064 }
1065
1076 protected function replaceParameters( $message, $type = 'before' ) {
1077 // A temporary marker for $1 parameters that is only valid
1078 // in non-attribute contexts. However if the entire message is escaped
1079 // then we don't want to use it because it will be mangled in all contexts
1080 // and its unnessary as ->escaped() messages aren't html.
1081 $marker = $this->format === 'escaped' ? '$' : '$\'"';
1082 $replacementKeys = [];
1083 foreach ( $this->parameters as $n => $param ) {
1084 list( $paramType, $value ) = $this->extractParam( $param );
1085 if ( $type === 'before' ) {
1086 if ( $paramType === 'before' ) {
1087 $replacementKeys['$' . ( $n + 1 )] = $value;
1088 } else /* $paramType === 'after' */ {
1089 // To protect against XSS from replacing parameters
1090 // inside html attributes, we convert $1 to $'"1.
1091 // In the event that one of the parameters ends up
1092 // in an attribute, either the ' or the " will be
1093 // escaped, breaking the replacement and avoiding XSS.
1094 $replacementKeys['$' . ( $n + 1 )] = $marker . ( $n + 1 );
1095 }
1096 } else {
1097 if ( $paramType === 'after' ) {
1098 $replacementKeys[$marker . ( $n + 1 )] = $value;
1099 }
1100 }
1101 }
1102 $message = strtr( $message, $replacementKeys );
1103 return $message;
1104 }
1105
1115 protected function extractParam( $param ) {
1116 if ( is_array( $param ) ) {
1117 if ( isset( $param['raw'] ) ) {
1118 return [ 'after', $param['raw'] ];
1119 } elseif ( isset( $param['num'] ) ) {
1120 // Replace number params always in before step for now.
1121 // No support for combined raw and num params
1122 return [ 'before', $this->getLanguage()->formatNum( $param['num'] ) ];
1123 } elseif ( isset( $param['duration'] ) ) {
1124 return [ 'before', $this->getLanguage()->formatDuration( $param['duration'] ) ];
1125 } elseif ( isset( $param['expiry'] ) ) {
1126 return [ 'before', $this->getLanguage()->formatExpiry( $param['expiry'] ) ];
1127 } elseif ( isset( $param['period'] ) ) {
1128 return [ 'before', $this->getLanguage()->formatTimePeriod( $param['period'] ) ];
1129 } elseif ( isset( $param['size'] ) ) {
1130 return [ 'before', $this->getLanguage()->formatSize( $param['size'] ) ];
1131 } elseif ( isset( $param['bitrate'] ) ) {
1132 return [ 'before', $this->getLanguage()->formatBitrate( $param['bitrate'] ) ];
1133 } elseif ( isset( $param['plaintext'] ) ) {
1134 return [ 'after', $this->formatPlaintext( $param['plaintext'] ) ];
1135 } else {
1136 $warning = 'Invalid parameter for message "' . $this->getKey() . '": ' .
1137 htmlspecialchars( serialize( $param ) );
1138 trigger_error( $warning, E_USER_WARNING );
1139 $e = new Exception;
1140 wfDebugLog( 'Bug58676', $warning . "\n" . $e->getTraceAsString() );
1141
1142 return [ 'before', '[INVALID]' ];
1143 }
1144 } elseif ( $param instanceof Message ) {
1145 // Message objects should not be before parameters because
1146 // then they'll get double escaped. If the message needs to be
1147 // escaped, it'll happen right here when we call toString().
1148 return [ 'after', $param->toString() ];
1149 } else {
1150 return [ 'before', $param ];
1151 }
1152 }
1153
1163 protected function parseText( $string ) {
1164 $out = MessageCache::singleton()->parse(
1165 $string,
1166 $this->title,
1167 /*linestart*/true,
1168 $this->interface,
1169 $this->getLanguage()
1170 );
1171
1172 return $out instanceof ParserOutput ? $out->getText() : $out;
1173 }
1174
1184 protected function transformText( $string ) {
1185 return MessageCache::singleton()->transform(
1186 $string,
1187 $this->interface,
1188 $this->getLanguage(),
1189 $this->title
1190 );
1191 }
1192
1201 protected function fetchMessage() {
1202 if ( $this->message === null ) {
1204
1205 foreach ( $this->keysToTry as $key ) {
1206 $message = $cache->get( $key, $this->useDatabase, $this->getLanguage() );
1207 if ( $message !== false && $message !== '' ) {
1208 break;
1209 }
1210 }
1211
1212 // NOTE: The constructor makes sure keysToTry isn't empty,
1213 // so we know that $key and $message are initialized.
1214 $this->key = $key;
1215 $this->message = $message;
1216 }
1217 return $this->message;
1218 }
1219
1231 protected function formatPlaintext( $plaintext ) {
1232 switch ( $this->format ) {
1233 case 'text':
1234 case 'plain':
1235 return $plaintext;
1236
1237 case 'parse':
1238 case 'block-parse':
1239 case 'escaped':
1240 default:
1241 return htmlspecialchars( $plaintext, ENT_QUOTES );
1242
1243 }
1244 }
1245}
1246
1260class RawMessage extends Message {
1261
1273 public function __construct( $text, $params = [] ) {
1274 if ( !is_string( $text ) ) {
1275 throw new InvalidArgumentException( '$text must be a string' );
1276 }
1277
1278 parent::__construct( $text, $params );
1279
1280 // The key is the message.
1281 $this->message = $text;
1282 }
1283
1289 public function fetchMessage() {
1290 // Just in case the message is unset somewhere.
1291 if ( $this->message === null ) {
1292 $this->message = $this->key;
1293 }
1294
1295 return $this->message;
1296 }
1297
1298}
serialize()
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.
if( $line===false) $args
Definition cdb.php:64
Internationalisation code.
Definition Language.php:35
getCode()
Get the internal language code for this language object.
MediaWiki exception.
static singleton()
Get the signleton instance of this class.
Wrapper allowing us to handle a system message as a Content object.
The Message class provides methods which fulfil two basic services:
Definition Message.php:159
timeperiodParams()
Add parameters that are time periods and will be passed through Language::formatTimePeriod before sub...
Definition Message.php:591
transformText( $string)
Wrapper for what ever method we use to {{-transform wikitext.
Definition Message.php:1184
static rawParam( $raw)
Definition Message.php:985
getParams()
Returns the message parameters.
Definition Message.php:340
durationParams()
Add parameters that are durations of time and will be passed through Language::formatDuration before ...
Definition Message.php:547
static bitrateParam( $bitrate)
Definition Message.php:1051
static newFromKey( $key)
Factory function that is just wrapper for the real constructor.
Definition Message.php:379
numParams()
Add parameters that are numeric and will be passed through Language::formatNum before substitution.
Definition Message.php:525
replaceParameters( $message, $type='before')
Substitutes any parameters into the message text.
Definition Message.php:1076
isMultiKey()
Definition Message.php:304
isBlank()
Check whether a message does not exist, or is an empty string.
Definition Message.php:961
setInterfaceMessageFlag( $interface)
Allows manipulating the interface message flag directly.
Definition Message.php:748
parseAsBlock()
Returns the parsed message text which is always surrounded by a block element.
Definition Message.php:924
__construct( $key, $params=[], Language $language=null)
Definition Message.php:234
bool $useDatabase
Whether database can be used.
Definition Message.php:208
getKeysToTry()
Definition Message.php:314
parse()
Fully parse the text from wikitext to HTML.
Definition Message.php:888
formatPlaintext( $plaintext)
Formats a message parameter wrapped with 'plaintext'.
Definition Message.php:1231
__toString()
Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg: $foo = new Message( $k...
Definition Message.php:854
static newFallbackSequence()
Factory function accepting multiple message keys and returning a message instance for the first messa...
Definition Message.php:431
unserialize( $serialized)
Definition Message.php:286
static sizeParam( $size)
Definition Message.php:1040
static timeperiodParam( $period)
Definition Message.php:1029
array $parameters
List of parameters which will be substituted into the message.
Definition Message.php:190
static plaintextParam( $plaintext)
Definition Message.php:1062
static durationParam( $duration)
Definition Message.php:1007
inLanguage( $lang)
Request the message in any language that is supported.
Definition Message.php:698
string $key
The message key.
Definition Message.php:180
sizeParams()
Add parameters that are file sizes and will be passed through Language::formatSize before substitutio...
Definition Message.php:613
static numParam( $num)
Definition Message.php:996
expiryParams()
Add parameters that are expiration times and will be passed through Language::formatExpiry before sub...
Definition Message.php:569
inContentLanguage()
Request the message in the wiki's content language, unless it is disabled for this message.
Definition Message.php:727
plain()
Returns the message text as-is, only parameters are substituted.
Definition Message.php:912
exists()
Check whether a message key has been defined currently.
Definition Message.php:949
plaintextParams()
Add parameters that are plaintext and will be passed through without the content being evaluated.
Definition Message.php:659
rawParams()
Add parameters that are substituted after parsing or escaping.
Definition Message.php:503
toString()
Returns the message parsed from wikitext to HTML.
Definition Message.php:801
title( $title)
Set the Title object to use as context when transforming the message.
Definition Message.php:776
Language bool $language
In which language to get this message.
Definition Message.php:174
getFormat()
Returns the message format.
Definition Message.php:351
useDatabase( $useDatabase)
Enable or disable database use.
Definition Message.php:762
fetchMessage()
Wrapper for what ever method we use to get message contents.
Definition Message.php:1201
content()
Returns the message as a Content object.
Definition Message.php:786
getTitle()
Get a title object for a mediawiki message, where it can be found in the mediawiki namespace.
Definition Message.php:455
bitrateParams()
Add parameters that are bitrates and will be passed through Language::formatBitrate before substituti...
Definition Message.php:635
parseText( $string)
Wrapper for what ever method we use to parse wikitext.
Definition Message.php:1163
getKey()
Returns the message key.
Definition Message.php:329
isDisabled()
Check whether a message does not exist, is an empty string, or is "-".
Definition Message.php:973
escaped()
Returns the message text.
Definition Message.php:937
params()
Adds parameters to the parameter list of this message.
Definition Message.php:480
extractParam( $param)
Extracts the parameter type and preprocessed the value if needed.
Definition Message.php:1115
getLanguage()
Returns the Language of the Message.
Definition Message.php:362
string $format
Format for the message.
Definition Message.php:203
string $message
Definition Message.php:223
string[] $keysToTry
List of keys to try when fetching the message.
Definition Message.php:185
serialize()
Definition Message.php:268
setContext(IContextSource $context)
Set the language and the title from a context object.
Definition Message.php:679
Title $title
Title object to use as context.
Definition Message.php:213
text()
Returns the message text.
Definition Message.php:900
static newFromSpecifier( $value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...
Definition Message.php:398
bool $interface
In which language to get this message.
Definition Message.php:167
static expiryParam( $expiry)
Definition Message.php:1018
Variant of the Message class.
Definition Message.php:1260
fetchMessage()
Fetch the message (in this case, the key).
Definition Message.php:1289
__construct( $text, $params=[])
Call the parent constructor, then store the key as the message.
Definition Message.php:1273
static getMain()
Static methods.
Stub object for the user language.
Represents a title within MediaWiki.
Definition Title.php:36
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
Definition deferred.txt:11
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
Definition design.txt:57
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
Definition design.txt:26
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
const NS_MEDIAWIKI
Definition Defines.php:64
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' 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 one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition hooks.txt:2568
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:986
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 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
Definition hooks.txt:2097
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
Definition hooks.txt:1094
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
Definition hooks.txt:1950
if the prop value should be in the metadata multi language array format
Definition hooks.txt:1620
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 $out
Definition hooks.txt:886
processing should stop and the error should be shown to the user * false
Definition hooks.txt:189
returning false will NOT prevent logging $e
Definition hooks.txt:2110
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
Definition hooks.txt:887
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
Definition injection.txt:37
Base interface for content objects.
Definition Content.php:34
Interface for objects which can provide a MediaWiki context on request.
$context
Definition load.php:50
$cache
Definition mcc.php:33
$params
foreach( $res as $row) $serialized
if(!isset( $args[0])) $lang