MediaWiki  1.34.0
Message.php
Go to the documentation of this file.
1 <?php
26 
162 class Message implements MessageSpecifier, Serializable {
164  const FORMAT_PLAIN = 'plain';
166  const FORMAT_BLOCK_PARSE = 'block-parse';
168  const FORMAT_PARSE = 'parse';
170  const FORMAT_TEXT = 'text';
172  const FORMAT_ESCAPED = 'escaped';
173 
178  protected static $listTypeMap = [
179  'comma' => 'commaList',
180  'semicolon' => 'semicolonList',
181  'pipe' => 'pipeList',
182  'text' => 'listToText',
183  ];
184 
191  protected $interface = true;
192 
198  protected $language = false;
199 
204  protected $key;
205 
209  protected $keysToTry;
210 
214  protected $parameters = [];
215 
220  protected $format = 'parse';
221 
225  protected $useDatabase = true;
226 
230  protected $title = null;
231 
235  protected $content = null;
236 
240  protected $message;
241 
251  public function __construct( $key, $params = [], Language $language = null ) {
252  if ( $key instanceof MessageSpecifier ) {
253  if ( $params ) {
254  throw new InvalidArgumentException(
255  '$params must be empty if $key is a MessageSpecifier'
256  );
257  }
258  $params = $key->getParams();
259  $key = $key->getKey();
260  }
261 
262  if ( !is_string( $key ) && !is_array( $key ) ) {
263  throw new InvalidArgumentException( '$key must be a string or an array' );
264  }
265 
266  $this->keysToTry = (array)$key;
267 
268  if ( empty( $this->keysToTry ) ) {
269  throw new InvalidArgumentException( '$key must not be an empty list' );
270  }
271 
272  $this->key = reset( $this->keysToTry );
273 
274  $this->parameters = array_values( $params );
275  // User language is only resolved in getLanguage(). This helps preserve the
276  // semantic intent of "user language" across serialize() and unserialize().
277  $this->language = $language ?: false;
278  }
279 
285  public function serialize() {
286  return serialize( [
287  'interface' => $this->interface,
288  'language' => $this->language ? $this->language->getCode() : false,
289  'key' => $this->key,
290  'keysToTry' => $this->keysToTry,
291  'parameters' => $this->parameters,
292  'format' => $this->format,
293  'useDatabase' => $this->useDatabase,
294  'titlestr' => $this->title ? $this->title->getFullText() : null,
295  ] );
296  }
297 
303  public function unserialize( $serialized ) {
304  $data = unserialize( $serialized );
305  if ( !is_array( $data ) ) {
306  throw new InvalidArgumentException( __METHOD__ . ': Invalid serialized data' );
307  }
308 
309  $this->interface = $data['interface'];
310  $this->key = $data['key'];
311  $this->keysToTry = $data['keysToTry'];
312  $this->parameters = $data['parameters'];
313  $this->format = $data['format'];
314  $this->useDatabase = $data['useDatabase'];
315  $this->language = $data['language'] ? Language::factory( $data['language'] ) : false;
316 
317  if ( isset( $data['titlestr'] ) ) {
318  $this->title = Title::newFromText( $data['titlestr'] );
319  } elseif ( isset( $data['title'] ) && $data['title'] instanceof Title ) {
320  // Old serializations from before December 2018
321  $this->title = $data['title'];
322  } else {
323  $this->title = null; // Explicit for sanity
324  }
325  }
326 
333  public function isMultiKey() {
334  return count( $this->keysToTry ) > 1;
335  }
336 
343  public function getKeysToTry() {
344  return $this->keysToTry;
345  }
346 
358  public function getKey() {
359  return $this->key;
360  }
361 
369  public function getParams() {
370  return $this->parameters;
371  }
372 
381  public function getFormat() {
382  wfDeprecated( __METHOD__, '1.29' );
383  return $this->format;
384  }
385 
393  public function getLanguage() {
394  // Defaults to false which means current user language
395  return $this->language ?: RequestContext::getMain()->getLanguage();
396  }
397 
410  public static function newFromKey( $key, ...$params ) {
411  return new self( $key, $params );
412  }
413 
427  public static function newFromSpecifier( $value ) {
428  $params = [];
429  if ( is_array( $value ) ) {
430  $params = $value;
431  $value = array_shift( $params );
432  }
433 
434  if ( $value instanceof Message ) { // Message, RawMessage, ApiMessage, etc
435  $message = clone $value;
436  } elseif ( $value instanceof MessageSpecifier ) {
437  $message = new Message( $value );
438  } elseif ( is_string( $value ) ) {
439  $message = new Message( $value, $params );
440  } else {
441  throw new InvalidArgumentException( __METHOD__ . ': invalid argument type '
442  . gettype( $value ) );
443  }
444 
445  return $message;
446  }
447 
460  public static function newFallbackSequence( ...$keys ) {
461  if ( func_num_args() == 1 ) {
462  if ( is_array( $keys[0] ) ) {
463  // Allow an array to be passed as the first argument instead
464  $keys = array_values( $keys[0] );
465  } else {
466  // Optimize a single string to not need special fallback handling
467  $keys = $keys[0];
468  }
469  }
470  return new self( $keys );
471  }
472 
483  public function getTitle() {
485 
486  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
487  $lang = $this->getLanguage();
488  $title = $this->key;
489  if (
490  !$lang->equals( $contLang )
491  && in_array( $this->key, (array)$wgForceUIMsgAsContentMsg )
492  ) {
493  $title .= '/' . $lang->getCode();
494  }
495 
496  return Title::makeTitle(
497  NS_MEDIAWIKI, $contLang->ucfirst( strtr( $title, ' ', '_' ) ) );
498  }
499 
510  public function params( ...$args ) {
511  // If $args has only one entry and it's an array, then it's either a
512  // non-varargs call or it happens to be a call with just a single
513  // "special" parameter. Since the "special" parameters don't have any
514  // numeric keys, we'll test that to differentiate the cases.
515  if ( count( $args ) === 1 && isset( $args[0] ) && is_array( $args[0] ) ) {
516  if ( $args[0] === [] ) {
517  $args = [];
518  } else {
519  foreach ( $args[0] as $key => $value ) {
520  if ( is_int( $key ) ) {
521  $args = $args[0];
522  break;
523  }
524  }
525  }
526  }
527 
528  $this->parameters = array_merge( $this->parameters, array_values( $args ) );
529  return $this;
530  }
531 
545  public function rawParams( ...$params ) {
546  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
547  $params = $params[0];
548  }
549  foreach ( $params as $param ) {
550  $this->parameters[] = self::rawParam( $param );
551  }
552  return $this;
553  }
554 
566  public function numParams( ...$params ) {
567  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
568  $params = $params[0];
569  }
570  foreach ( $params as $param ) {
571  $this->parameters[] = self::numParam( $param );
572  }
573  return $this;
574  }
575 
587  public function durationParams( ...$params ) {
588  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
589  $params = $params[0];
590  }
591  foreach ( $params as $param ) {
592  $this->parameters[] = self::durationParam( $param );
593  }
594  return $this;
595  }
596 
608  public function expiryParams( ...$params ) {
609  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
610  $params = $params[0];
611  }
612  foreach ( $params as $param ) {
613  $this->parameters[] = self::expiryParam( $param );
614  }
615  return $this;
616  }
617 
629  public function timeperiodParams( ...$params ) {
630  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
631  $params = $params[0];
632  }
633  foreach ( $params as $param ) {
634  $this->parameters[] = self::timeperiodParam( $param );
635  }
636  return $this;
637  }
638 
650  public function sizeParams( ...$params ) {
651  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
652  $params = $params[0];
653  }
654  foreach ( $params as $param ) {
655  $this->parameters[] = self::sizeParam( $param );
656  }
657  return $this;
658  }
659 
671  public function bitrateParams( ...$params ) {
672  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
673  $params = $params[0];
674  }
675  foreach ( $params as $param ) {
676  $this->parameters[] = self::bitrateParam( $param );
677  }
678  return $this;
679  }
680 
694  public function plaintextParams( ...$params ) {
695  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
696  $params = $params[0];
697  }
698  foreach ( $params as $param ) {
699  $this->parameters[] = self::plaintextParam( $param );
700  }
701  return $this;
702  }
703 
713  public function setContext( IContextSource $context ) {
714  $this->inLanguage( $context->getLanguage() );
715  $this->title( $context->getTitle() );
716  $this->interface = true;
717 
718  return $this;
719  }
720 
732  public function inLanguage( $lang ) {
733  $previousLanguage = $this->language;
734 
735  if ( $lang instanceof Language ) {
736  $this->language = $lang;
737  } elseif ( is_string( $lang ) ) {
738  if ( !$this->language instanceof Language || $this->language->getCode() != $lang ) {
739  $this->language = Language::factory( $lang );
740  }
741  } elseif ( $lang instanceof StubUserLang ) {
742  $this->language = false;
743  } else {
744  $type = gettype( $lang );
745  throw new MWException( __METHOD__ . " must be "
746  . "passed a String or Language object; $type given"
747  );
748  }
749 
750  if ( $this->language !== $previousLanguage ) {
751  // The language has changed. Clear the message cache.
752  $this->message = null;
753  }
754  $this->interface = false;
755  return $this;
756  }
757 
767  public function inContentLanguage() {
769  if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) {
770  return $this;
771  }
772 
773  $this->inLanguage( MediaWikiServices::getInstance()->getContentLanguage() );
774  return $this;
775  }
776 
787  public function setInterfaceMessageFlag( $interface ) {
788  $this->interface = (bool)$interface;
789  return $this;
790  }
791 
801  public function useDatabase( $useDatabase ) {
802  $this->useDatabase = (bool)$useDatabase;
803  $this->message = null;
804  return $this;
805  }
806 
816  public function title( $title ) {
817  $this->title = $title;
818  return $this;
819  }
820 
826  public function content() {
827  if ( !$this->content ) {
828  $this->content = new MessageContent( $this );
829  }
830 
831  return $this->content;
832  }
833 
845  public function toString( $format = null ) {
846  if ( $format === null ) {
847  $ex = new LogicException( __METHOD__ . ' using implicit format: ' . $this->format );
848  LoggerFactory::getInstance( 'message-format' )->warning(
849  $ex->getMessage(), [ 'exception' => $ex, 'format' => $this->format, 'key' => $this->key ] );
850  $format = $this->format;
851  }
852  $string = $this->fetchMessage();
853 
854  if ( $string === false ) {
855  // Err on the side of safety, ensure that the output
856  // is always html safe in the event the message key is
857  // missing, since in that case its highly likely the
858  // message key is user-controlled.
859  // '⧼' is used instead of '<' to side-step any
860  // double-escaping issues.
861  // (Keep synchronised with mw.Message#toString in JS.)
862  return '⧼' . htmlspecialchars( $this->key ) . '⧽';
863  }
864 
865  # Replace $* with a list of parameters for &uselang=qqx.
866  if ( strpos( $string, '$*' ) !== false ) {
867  $paramlist = '';
868  if ( $this->parameters !== [] ) {
869  $paramlist = ': $' . implode( ', $', range( 1, count( $this->parameters ) ) );
870  }
871  $string = str_replace( '$*', $paramlist, $string );
872  }
873 
874  # Replace parameters before text parsing
875  $string = $this->replaceParameters( $string, 'before', $format );
876 
877  # Maybe transform using the full parser
878  if ( $format === self::FORMAT_PARSE ) {
879  $string = $this->parseText( $string );
880  $string = Parser::stripOuterParagraph( $string );
881  } elseif ( $format === self::FORMAT_BLOCK_PARSE ) {
882  $string = $this->parseText( $string );
883  } elseif ( $format === self::FORMAT_TEXT ) {
884  $string = $this->transformText( $string );
885  } elseif ( $format === self::FORMAT_ESCAPED ) {
886  $string = $this->transformText( $string );
887  $string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false );
888  }
889 
890  # Raw parameter replacement
891  $string = $this->replaceParameters( $string, 'after', $format );
892 
893  return $string;
894  }
895 
905  public function __toString() {
906  // PHP doesn't allow __toString to throw exceptions and will
907  // trigger a fatal error if it does. So, catch any exceptions.
908 
909  try {
910  return $this->toString( self::FORMAT_PARSE );
911  } catch ( Exception $ex ) {
912  try {
913  trigger_error( "Exception caught in " . __METHOD__ . " (message " . $this->key . "): "
914  . $ex, E_USER_WARNING );
915  } catch ( Exception $ex ) {
916  // Doh! Cause a fatal error after all?
917  }
918 
919  return '⧼' . htmlspecialchars( $this->key ) . '⧽';
920  }
921  }
922 
930  public function parse() {
931  $this->format = self::FORMAT_PARSE;
932  return $this->toString( self::FORMAT_PARSE );
933  }
934 
942  public function text() {
943  $this->format = self::FORMAT_TEXT;
944  return $this->toString( self::FORMAT_TEXT );
945  }
946 
954  public function plain() {
955  $this->format = self::FORMAT_PLAIN;
956  return $this->toString( self::FORMAT_PLAIN );
957  }
958 
966  public function parseAsBlock() {
967  $this->format = self::FORMAT_BLOCK_PARSE;
968  return $this->toString( self::FORMAT_BLOCK_PARSE );
969  }
970 
979  public function escaped() {
980  $this->format = self::FORMAT_ESCAPED;
981  return $this->toString( self::FORMAT_ESCAPED );
982  }
983 
991  public function exists() {
992  return $this->fetchMessage() !== false;
993  }
994 
1003  public function isBlank() {
1004  $message = $this->fetchMessage();
1005  return $message === false || $message === '';
1006  }
1007 
1015  public function isDisabled() {
1016  $message = $this->fetchMessage();
1017  return $message === false || $message === '' || $message === '-';
1018  }
1019 
1027  public static function rawParam( $raw ) {
1028  return [ 'raw' => $raw ];
1029  }
1030 
1038  public static function numParam( $num ) {
1039  return [ 'num' => $num ];
1040  }
1041 
1049  public static function durationParam( $duration ) {
1050  return [ 'duration' => $duration ];
1051  }
1052 
1060  public static function expiryParam( $expiry ) {
1061  return [ 'expiry' => $expiry ];
1062  }
1063 
1071  public static function timeperiodParam( $period ) {
1072  return [ 'period' => $period ];
1073  }
1074 
1082  public static function sizeParam( $size ) {
1083  return [ 'size' => $size ];
1084  }
1085 
1093  public static function bitrateParam( $bitrate ) {
1094  return [ 'bitrate' => $bitrate ];
1095  }
1096 
1104  public static function plaintextParam( $plaintext ) {
1105  return [ 'plaintext' => $plaintext ];
1106  }
1107 
1115  public static function listParam( array $list, $type = 'text' ) {
1116  if ( !isset( self::$listTypeMap[$type] ) ) {
1117  throw new InvalidArgumentException(
1118  "Invalid type '$type'. Known types are: " . implode( ', ', array_keys( self::$listTypeMap ) )
1119  );
1120  }
1121  return [ 'list' => $list, 'type' => $type ];
1122  }
1123 
1135  protected function replaceParameters( $message, $type, $format ) {
1136  // A temporary marker for $1 parameters that is only valid
1137  // in non-attribute contexts. However if the entire message is escaped
1138  // then we don't want to use it because it will be mangled in all contexts
1139  // and its unnessary as ->escaped() messages aren't html.
1140  $marker = $format === self::FORMAT_ESCAPED ? '$' : '$\'"';
1141  $replacementKeys = [];
1142  foreach ( $this->parameters as $n => $param ) {
1143  list( $paramType, $value ) = $this->extractParam( $param, $format );
1144  if ( $type === 'before' ) {
1145  if ( $paramType === 'before' ) {
1146  $replacementKeys['$' . ( $n + 1 )] = $value;
1147  } else /* $paramType === 'after' */ {
1148  // To protect against XSS from replacing parameters
1149  // inside html attributes, we convert $1 to $'"1.
1150  // In the event that one of the parameters ends up
1151  // in an attribute, either the ' or the " will be
1152  // escaped, breaking the replacement and avoiding XSS.
1153  $replacementKeys['$' . ( $n + 1 )] = $marker . ( $n + 1 );
1154  }
1155  } elseif ( $paramType === 'after' ) {
1156  $replacementKeys[$marker . ( $n + 1 )] = $value;
1157  }
1158  }
1159  return strtr( $message, $replacementKeys );
1160  }
1161 
1172  protected function extractParam( $param, $format ) {
1173  if ( is_array( $param ) ) {
1174  if ( isset( $param['raw'] ) ) {
1175  return [ 'after', $param['raw'] ];
1176  } elseif ( isset( $param['num'] ) ) {
1177  // Replace number params always in before step for now.
1178  // No support for combined raw and num params
1179  return [ 'before', $this->getLanguage()->formatNum( $param['num'] ) ];
1180  } elseif ( isset( $param['duration'] ) ) {
1181  return [ 'before', $this->getLanguage()->formatDuration( $param['duration'] ) ];
1182  } elseif ( isset( $param['expiry'] ) ) {
1183  return [ 'before', $this->getLanguage()->formatExpiry( $param['expiry'] ) ];
1184  } elseif ( isset( $param['period'] ) ) {
1185  return [ 'before', $this->getLanguage()->formatTimePeriod( $param['period'] ) ];
1186  } elseif ( isset( $param['size'] ) ) {
1187  return [ 'before', $this->getLanguage()->formatSize( $param['size'] ) ];
1188  } elseif ( isset( $param['bitrate'] ) ) {
1189  return [ 'before', $this->getLanguage()->formatBitrate( $param['bitrate'] ) ];
1190  } elseif ( isset( $param['plaintext'] ) ) {
1191  return [ 'after', $this->formatPlaintext( $param['plaintext'], $format ) ];
1192  } elseif ( isset( $param['list'] ) ) {
1193  return $this->formatListParam( $param['list'], $param['type'], $format );
1194  } else {
1195  if ( !is_scalar( $param ) ) {
1196  $param = serialize( $param );
1197  }
1198  LoggerFactory::getInstance( 'Bug58676' )->warning(
1199  'Invalid parameter for message "{msgkey}": {param}',
1200  [
1201  'exception' => new Exception,
1202  'msgkey' => $this->getKey(),
1203  'param' => htmlspecialchars( $param ),
1204  ]
1205  );
1206 
1207  return [ 'before', '[INVALID]' ];
1208  }
1209  } elseif ( $param instanceof Message ) {
1210  // Match language, flags, etc. to the current message.
1211  $msg = clone $param;
1212  if ( $msg->language !== $this->language || $msg->useDatabase !== $this->useDatabase ) {
1213  // Cache depends on these parameters
1214  $msg->message = null;
1215  }
1216  $msg->interface = $this->interface;
1217  $msg->language = $this->language;
1218  $msg->useDatabase = $this->useDatabase;
1219  $msg->title = $this->title;
1220 
1221  // DWIM
1222  if ( $format === 'block-parse' ) {
1223  $format = 'parse';
1224  }
1225  $msg->format = $format;
1226 
1227  // Message objects should not be before parameters because
1228  // then they'll get double escaped. If the message needs to be
1229  // escaped, it'll happen right here when we call toString().
1230  return [ 'after', $msg->toString( $format ) ];
1231  } else {
1232  return [ 'before', $param ];
1233  }
1234  }
1235 
1245  protected function parseText( $string ) {
1246  $out = MessageCache::singleton()->parse(
1247  $string,
1248  $this->title,
1249  /*linestart*/true,
1250  $this->interface,
1251  $this->getLanguage()
1252  );
1253 
1254  return $out instanceof ParserOutput
1255  ? $out->getText( [
1256  'enableSectionEditLinks' => false,
1257  // Wrapping messages in an extra <div> is probably not expected. If
1258  // they're outside the content area they probably shouldn't be
1259  // targeted by CSS that's targeting the parser output, and if
1260  // they're inside they already are from the outer div.
1261  'unwrap' => true,
1262  ] )
1263  : $out;
1264  }
1265 
1275  protected function transformText( $string ) {
1276  return MessageCache::singleton()->transform(
1277  $string,
1278  $this->interface,
1279  $this->getLanguage(),
1280  $this->title
1281  );
1282  }
1283 
1292  protected function fetchMessage() {
1293  if ( $this->message === null ) {
1295 
1296  foreach ( $this->keysToTry as $key ) {
1297  $message = $cache->get( $key, $this->useDatabase, $this->getLanguage() );
1298  if ( $message !== false && $message !== '' ) {
1299  break;
1300  }
1301  }
1302 
1303  // NOTE: The constructor makes sure keysToTry isn't empty,
1304  // so we know that $key and $message are initialized.
1305  $this->key = $key;
1306  $this->message = $message;
1307  }
1308  return $this->message;
1309  }
1310 
1323  protected function formatPlaintext( $plaintext, $format ) {
1324  switch ( $format ) {
1325  case self::FORMAT_TEXT:
1326  case self::FORMAT_PLAIN:
1327  return $plaintext;
1328 
1329  case self::FORMAT_PARSE:
1330  case self::FORMAT_BLOCK_PARSE:
1331  case self::FORMAT_ESCAPED:
1332  default:
1333  return htmlspecialchars( $plaintext, ENT_QUOTES );
1334  }
1335  }
1336 
1345  protected function formatListParam( array $params, $listType, $format ) {
1346  if ( !isset( self::$listTypeMap[$listType] ) ) {
1347  $warning = 'Invalid list type for message "' . $this->getKey() . '": '
1348  . htmlspecialchars( $listType )
1349  . ' (params are ' . htmlspecialchars( serialize( $params ) ) . ')';
1350  trigger_error( $warning, E_USER_WARNING );
1351  $e = new Exception;
1352  wfDebugLog( 'Bug58676', $warning . "\n" . $e->getTraceAsString() );
1353  return [ 'before', '[INVALID]' ];
1354  }
1355  $func = self::$listTypeMap[$listType];
1356 
1357  // Handle an empty list sensibly
1358  if ( !$params ) {
1359  return [ 'before', $this->getLanguage()->$func( [] ) ];
1360  }
1361 
1362  // First, determine what kinds of list items we have
1363  $types = [];
1364  $vars = [];
1365  $list = [];
1366  foreach ( $params as $n => $p ) {
1367  list( $type, $value ) = $this->extractParam( $p, $format );
1368  $types[$type] = true;
1369  $list[] = $value;
1370  $vars[] = '$' . ( $n + 1 );
1371  }
1372 
1373  // Easy case: all are 'before' or 'after', so just join the
1374  // values and use the same type.
1375  if ( count( $types ) === 1 ) {
1376  return [ key( $types ), $this->getLanguage()->$func( $list ) ];
1377  }
1378 
1379  // Hard case: We need to process each value per its type, then
1380  // return the concatenated values as 'after'. We handle this by turning
1381  // the list into a RawMessage and processing that as a parameter.
1382  $vars = $this->getLanguage()->$func( $vars );
1383  return $this->extractParam( new RawMessage( $vars, $params ), $format );
1384  }
1385 }
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:316
ParserOutput
Definition: ParserOutput.php:25
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
true
return true
Definition: router.php:92
MessageSpecifier\getKey
getKey()
Returns the message key.
MessageSpecifier
Definition: MessageSpecifier.php:21
$serialized
foreach( $res as $row) $serialized
Definition: testCompression.php:81
Message
serialize
serialize()
Definition: ApiMessageTrait.php:138
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1007
MessageSpecifier\getParams
getParams()
Returns the message parameters.
MWException
MediaWiki exception.
Definition: MWException.php:26
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1044
MediaWiki\Logger\LoggerFactory
PSR-3 logger instance factory.
Definition: LoggerFactory.php:45
$title
$title
Definition: testCompression.php:34
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:586
MessageCache\singleton
static singleton()
Get the singleton instance of this class.
Definition: MessageCache.php:114
$content
$content
Definition: router.php:78
Language\getCode
getCode()
Get the internal language code for this language object.
Definition: Language.php:4291
StubUserLang
Stub object for the user language.
Definition: StubUserLang.php:24
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:431
$wgForceUIMsgAsContentMsg
$wgForceUIMsgAsContentMsg
When translating messages with wfMessage(), it is not always clear what should be considered UI messa...
Definition: DefaultSettings.php:3190
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
$context
$context
Definition: load.php:45
Content
Base interface for content objects.
Definition: Content.php:34
unserialize
unserialize( $serialized)
Definition: ApiMessageTrait.php:146
$args
if( $line===false) $args
Definition: cdb.php:64
Title
Represents a title within MediaWiki.
Definition: Title.php:42
$cache
$cache
Definition: mcc.php:33
MessageContent
Wrapper allowing us to handle a system message as a Content object.
Definition: MessageContent.php:36
getTitle
getTitle()
Definition: RevisionSearchResultTrait.php:74
$keys
$keys
Definition: testCompression.php:67
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:217
ParserOutput\getText
getText( $options=[])
Get the output HTML.
Definition: ParserOutput.php:323
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:68
RawMessage
Variant of the Message class.
Definition: RawMessage.php:34
Language
Internationalisation code.
Definition: Language.php:37
$type
$type
Definition: testCompression.php:48