MediaWiki  1.32.5
Message.php
Go to the documentation of this file.
1 <?php
24 
160 class Message implements MessageSpecifier, Serializable {
162  const FORMAT_PLAIN = 'plain';
164  const FORMAT_BLOCK_PARSE = 'block-parse';
166  const FORMAT_PARSE = 'parse';
168  const FORMAT_TEXT = 'text';
170  const FORMAT_ESCAPED = 'escaped';
171 
176  protected static $listTypeMap = [
177  'comma' => 'commaList',
178  'semicolon' => 'semicolonList',
179  'pipe' => 'pipeList',
180  'text' => 'listToText',
181  ];
182 
189  protected $interface = true;
190 
196  protected $language = false;
197 
202  protected $key;
203 
207  protected $keysToTry;
208 
212  protected $parameters = [];
213 
218  protected $format = 'parse';
219 
223  protected $useDatabase = true;
224 
228  protected $title = null;
229 
233  protected $content = null;
234 
238  protected $message;
239 
249  public function __construct( $key, $params = [], Language $language = null ) {
250  if ( $key instanceof MessageSpecifier ) {
251  if ( $params ) {
252  throw new InvalidArgumentException(
253  '$params must be empty if $key is a MessageSpecifier'
254  );
255  }
256  $params = $key->getParams();
257  $key = $key->getKey();
258  }
259 
260  if ( !is_string( $key ) && !is_array( $key ) ) {
261  throw new InvalidArgumentException( '$key must be a string or an array' );
262  }
263 
264  $this->keysToTry = (array)$key;
265 
266  if ( empty( $this->keysToTry ) ) {
267  throw new InvalidArgumentException( '$key must not be an empty list' );
268  }
269 
270  $this->key = reset( $this->keysToTry );
271 
272  $this->parameters = array_values( $params );
273  // User language is only resolved in getLanguage(). This helps preserve the
274  // semantic intent of "user language" across serialize() and unserialize().
275  $this->language = $language ?: false;
276  }
277 
283  public function serialize() {
284  return serialize( [
285  'interface' => $this->interface,
286  'language' => $this->language ? $this->language->getCode() : false,
287  'key' => $this->key,
288  'keysToTry' => $this->keysToTry,
289  'parameters' => $this->parameters,
290  'format' => $this->format,
291  'useDatabase' => $this->useDatabase,
292  'title' => $this->title,
293  ] );
294  }
295 
301  public function unserialize( $serialized ) {
302  $data = unserialize( $serialized );
303  $this->interface = $data['interface'];
304  $this->key = $data['key'];
305  $this->keysToTry = $data['keysToTry'];
306  $this->parameters = $data['parameters'];
307  $this->format = $data['format'];
308  $this->useDatabase = $data['useDatabase'];
309  $this->language = $data['language'] ? Language::factory( $data['language'] ) : false;
310  $this->title = $data['title'];
311  }
312 
319  public function isMultiKey() {
320  return count( $this->keysToTry ) > 1;
321  }
322 
329  public function getKeysToTry() {
330  return $this->keysToTry;
331  }
332 
344  public function getKey() {
345  return $this->key;
346  }
347 
355  public function getParams() {
356  return $this->parameters;
357  }
358 
367  public function getFormat() {
368  wfDeprecated( __METHOD__, '1.29' );
369  return $this->format;
370  }
371 
379  public function getLanguage() {
380  // Defaults to false which means current user language
381  return $this->language ?: RequestContext::getMain()->getLanguage();
382  }
383 
396  public static function newFromKey( $key /*...*/ ) {
397  $params = func_get_args();
398  array_shift( $params );
399  return new self( $key, $params );
400  }
401 
415  public static function newFromSpecifier( $value ) {
416  $params = [];
417  if ( is_array( $value ) ) {
418  $params = $value;
419  $value = array_shift( $params );
420  }
421 
422  if ( $value instanceof Message ) { // Message, RawMessage, ApiMessage, etc
423  $message = clone $value;
424  } elseif ( $value instanceof MessageSpecifier ) {
425  $message = new Message( $value );
426  } elseif ( is_string( $value ) ) {
427  $message = new Message( $value, $params );
428  } else {
429  throw new InvalidArgumentException( __METHOD__ . ': invalid argument type '
430  . gettype( $value ) );
431  }
432 
433  return $message;
434  }
435 
448  public static function newFallbackSequence( /*...*/ ) {
449  $keys = func_get_args();
450  if ( func_num_args() == 1 ) {
451  if ( is_array( $keys[0] ) ) {
452  // Allow an array to be passed as the first argument instead
453  $keys = array_values( $keys[0] );
454  } else {
455  // Optimize a single string to not need special fallback handling
456  $keys = $keys[0];
457  }
458  }
459  return new self( $keys );
460  }
461 
472  public function getTitle() {
474 
475  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
476  $lang = $this->getLanguage();
477  $title = $this->key;
478  if (
479  !$lang->equals( $contLang )
480  && in_array( $this->key, (array)$wgForceUIMsgAsContentMsg )
481  ) {
482  $title .= '/' . $lang->getCode();
483  }
484 
485  return Title::makeTitle(
486  NS_MEDIAWIKI, $contLang->ucfirst( strtr( $title, ' ', '_' ) ) );
487  }
488 
499  public function params( /*...*/ ) {
500  $args = func_get_args();
501 
502  // If $args has only one entry and it's an array, then it's either a
503  // non-varargs call or it happens to be a call with just a single
504  // "special" parameter. Since the "special" parameters don't have any
505  // numeric keys, we'll test that to differentiate the cases.
506  if ( count( $args ) === 1 && isset( $args[0] ) && is_array( $args[0] ) ) {
507  if ( $args[0] === [] ) {
508  $args = [];
509  } else {
510  foreach ( $args[0] as $key => $value ) {
511  if ( is_int( $key ) ) {
512  $args = $args[0];
513  break;
514  }
515  }
516  }
517  }
518 
519  $this->parameters = array_merge( $this->parameters, array_values( $args ) );
520  return $this;
521  }
522 
536  public function rawParams( /*...*/ ) {
537  $params = func_get_args();
538  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
539  $params = $params[0];
540  }
541  foreach ( $params as $param ) {
542  $this->parameters[] = self::rawParam( $param );
543  }
544  return $this;
545  }
546 
558  public function numParams( /*...*/ ) {
559  $params = func_get_args();
560  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
561  $params = $params[0];
562  }
563  foreach ( $params as $param ) {
564  $this->parameters[] = self::numParam( $param );
565  }
566  return $this;
567  }
568 
580  public function durationParams( /*...*/ ) {
581  $params = func_get_args();
582  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
583  $params = $params[0];
584  }
585  foreach ( $params as $param ) {
586  $this->parameters[] = self::durationParam( $param );
587  }
588  return $this;
589  }
590 
602  public function expiryParams( /*...*/ ) {
603  $params = func_get_args();
604  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
605  $params = $params[0];
606  }
607  foreach ( $params as $param ) {
608  $this->parameters[] = self::expiryParam( $param );
609  }
610  return $this;
611  }
612 
624  public function timeperiodParams( /*...*/ ) {
625  $params = func_get_args();
626  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
627  $params = $params[0];
628  }
629  foreach ( $params as $param ) {
630  $this->parameters[] = self::timeperiodParam( $param );
631  }
632  return $this;
633  }
634 
646  public function sizeParams( /*...*/ ) {
647  $params = func_get_args();
648  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
649  $params = $params[0];
650  }
651  foreach ( $params as $param ) {
652  $this->parameters[] = self::sizeParam( $param );
653  }
654  return $this;
655  }
656 
668  public function bitrateParams( /*...*/ ) {
669  $params = func_get_args();
670  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
671  $params = $params[0];
672  }
673  foreach ( $params as $param ) {
674  $this->parameters[] = self::bitrateParam( $param );
675  }
676  return $this;
677  }
678 
692  public function plaintextParams( /*...*/ ) {
693  $params = func_get_args();
694  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
695  $params = $params[0];
696  }
697  foreach ( $params as $param ) {
698  $this->parameters[] = self::plaintextParam( $param );
699  }
700  return $this;
701  }
702 
712  public function setContext( IContextSource $context ) {
713  $this->inLanguage( $context->getLanguage() );
714  $this->title( $context->getTitle() );
715  $this->interface = true;
716 
717  return $this;
718  }
719 
731  public function inLanguage( $lang ) {
732  $previousLanguage = $this->language;
733 
734  if ( $lang instanceof Language ) {
735  $this->language = $lang;
736  } elseif ( is_string( $lang ) ) {
737  if ( !$this->language instanceof Language || $this->language->getCode() != $lang ) {
738  $this->language = Language::factory( $lang );
739  }
740  } elseif ( $lang instanceof StubUserLang ) {
741  $this->language = false;
742  } else {
743  $type = gettype( $lang );
744  throw new MWException( __METHOD__ . " must be "
745  . "passed a String or Language object; $type given"
746  );
747  }
748 
749  if ( $this->language !== $previousLanguage ) {
750  // The language has changed. Clear the message cache.
751  $this->message = null;
752  }
753  $this->interface = false;
754  return $this;
755  }
756 
766  public function inContentLanguage() {
768  if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) {
769  return $this;
770  }
771 
772  $this->inLanguage( MediaWikiServices::getInstance()->getContentLanguage() );
773  return $this;
774  }
775 
786  public function setInterfaceMessageFlag( $interface ) {
787  $this->interface = (bool)$interface;
788  return $this;
789  }
790 
800  public function useDatabase( $useDatabase ) {
801  $this->useDatabase = (bool)$useDatabase;
802  $this->message = null;
803  return $this;
804  }
805 
815  public function title( $title ) {
816  $this->title = $title;
817  return $this;
818  }
819 
825  public function content() {
826  if ( !$this->content ) {
827  $this->content = new MessageContent( $this );
828  }
829 
830  return $this->content;
831  }
832 
844  public function toString( $format = null ) {
845  if ( $format === null ) {
846  $ex = new LogicException( __METHOD__ . ' using implicit format: ' . $this->format );
847  \MediaWiki\Logger\LoggerFactory::getInstance( 'message-format' )->warning(
848  $ex->getMessage(), [ 'exception' => $ex, 'format' => $this->format, 'key' => $this->key ] );
849  $format = $this->format;
850  }
851  $string = $this->fetchMessage();
852 
853  if ( $string === false ) {
854  // Err on the side of safety, ensure that the output
855  // is always html safe in the event the message key is
856  // missing, since in that case its highly likely the
857  // message key is user-controlled.
858  // '⧼' is used instead of '<' to side-step any
859  // double-escaping issues.
860  // (Keep synchronised with mw.Message#toString in JS.)
861  return '⧼' . htmlspecialchars( $this->key ) . '⧽';
862  }
863 
864  # Replace $* with a list of parameters for &uselang=qqx.
865  if ( strpos( $string, '$*' ) !== false ) {
866  $paramlist = '';
867  if ( $this->parameters !== [] ) {
868  $paramlist = ': $' . implode( ', $', range( 1, count( $this->parameters ) ) );
869  }
870  $string = str_replace( '$*', $paramlist, $string );
871  }
872 
873  # Replace parameters before text parsing
874  $string = $this->replaceParameters( $string, 'before', $format );
875 
876  # Maybe transform using the full parser
877  if ( $format === self::FORMAT_PARSE ) {
878  $string = $this->parseText( $string );
879  $string = Parser::stripOuterParagraph( $string );
880  } elseif ( $format === self::FORMAT_BLOCK_PARSE ) {
881  $string = $this->parseText( $string );
882  } elseif ( $format === self::FORMAT_TEXT ) {
883  $string = $this->transformText( $string );
884  } elseif ( $format === self::FORMAT_ESCAPED ) {
885  $string = $this->transformText( $string );
886  $string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false );
887  }
888 
889  # Raw parameter replacement
890  $string = $this->replaceParameters( $string, 'after', $format );
891 
892  return $string;
893  }
894 
904  public function __toString() {
905  // PHP doesn't allow __toString to throw exceptions and will
906  // trigger a fatal error if it does. So, catch any exceptions.
907 
908  try {
909  return $this->toString( self::FORMAT_PARSE );
910  } catch ( Exception $ex ) {
911  try {
912  trigger_error( "Exception caught in " . __METHOD__ . " (message " . $this->key . "): "
913  . $ex, E_USER_WARNING );
914  } catch ( Exception $ex ) {
915  // Doh! Cause a fatal error after all?
916  }
917 
918  return '⧼' . htmlspecialchars( $this->key ) . '⧽';
919  }
920  }
921 
929  public function parse() {
930  $this->format = self::FORMAT_PARSE;
931  return $this->toString( self::FORMAT_PARSE );
932  }
933 
941  public function text() {
942  $this->format = self::FORMAT_TEXT;
943  return $this->toString( self::FORMAT_TEXT );
944  }
945 
953  public function plain() {
954  $this->format = self::FORMAT_PLAIN;
955  return $this->toString( self::FORMAT_PLAIN );
956  }
957 
965  public function parseAsBlock() {
966  $this->format = self::FORMAT_BLOCK_PARSE;
967  return $this->toString( self::FORMAT_BLOCK_PARSE );
968  }
969 
978  public function escaped() {
979  $this->format = self::FORMAT_ESCAPED;
980  return $this->toString( self::FORMAT_ESCAPED );
981  }
982 
990  public function exists() {
991  return $this->fetchMessage() !== false;
992  }
993 
1002  public function isBlank() {
1003  $message = $this->fetchMessage();
1004  return $message === false || $message === '';
1005  }
1006 
1014  public function isDisabled() {
1015  $message = $this->fetchMessage();
1016  return $message === false || $message === '' || $message === '-';
1017  }
1018 
1026  public static function rawParam( $raw ) {
1027  return [ 'raw' => $raw ];
1028  }
1029 
1037  public static function numParam( $num ) {
1038  return [ 'num' => $num ];
1039  }
1040 
1048  public static function durationParam( $duration ) {
1049  return [ 'duration' => $duration ];
1050  }
1051 
1059  public static function expiryParam( $expiry ) {
1060  return [ 'expiry' => $expiry ];
1061  }
1062 
1070  public static function timeperiodParam( $period ) {
1071  return [ 'period' => $period ];
1072  }
1073 
1081  public static function sizeParam( $size ) {
1082  return [ 'size' => $size ];
1083  }
1084 
1092  public static function bitrateParam( $bitrate ) {
1093  return [ 'bitrate' => $bitrate ];
1094  }
1095 
1103  public static function plaintextParam( $plaintext ) {
1104  return [ 'plaintext' => $plaintext ];
1105  }
1106 
1114  public static function listParam( array $list, $type = 'text' ) {
1115  if ( !isset( self::$listTypeMap[$type] ) ) {
1116  throw new InvalidArgumentException(
1117  "Invalid type '$type'. Known types are: " . implode( ', ', array_keys( self::$listTypeMap ) )
1118  );
1119  }
1120  return [ 'list' => $list, 'type' => $type ];
1121  }
1122 
1134  protected function replaceParameters( $message, $type, $format ) {
1135  // A temporary marker for $1 parameters that is only valid
1136  // in non-attribute contexts. However if the entire message is escaped
1137  // then we don't want to use it because it will be mangled in all contexts
1138  // and its unnessary as ->escaped() messages aren't html.
1139  $marker = $format === self::FORMAT_ESCAPED ? '$' : '$\'"';
1140  $replacementKeys = [];
1141  foreach ( $this->parameters as $n => $param ) {
1142  list( $paramType, $value ) = $this->extractParam( $param, $format );
1143  if ( $type === 'before' ) {
1144  if ( $paramType === 'before' ) {
1145  $replacementKeys['$' . ( $n + 1 )] = $value;
1146  } else /* $paramType === 'after' */ {
1147  // To protect against XSS from replacing parameters
1148  // inside html attributes, we convert $1 to $'"1.
1149  // In the event that one of the parameters ends up
1150  // in an attribute, either the ' or the " will be
1151  // escaped, breaking the replacement and avoiding XSS.
1152  $replacementKeys['$' . ( $n + 1 )] = $marker . ( $n + 1 );
1153  }
1154  } else {
1155  if ( $paramType === 'after' ) {
1156  $replacementKeys[$marker . ( $n + 1 )] = $value;
1157  }
1158  }
1159  }
1160  $message = strtr( $message, $replacementKeys );
1161  return $message;
1162  }
1163 
1174  protected function extractParam( $param, $format ) {
1175  if ( is_array( $param ) ) {
1176  if ( isset( $param['raw'] ) ) {
1177  return [ 'after', $param['raw'] ];
1178  } elseif ( isset( $param['num'] ) ) {
1179  // Replace number params always in before step for now.
1180  // No support for combined raw and num params
1181  return [ 'before', $this->getLanguage()->formatNum( $param['num'] ) ];
1182  } elseif ( isset( $param['duration'] ) ) {
1183  return [ 'before', $this->getLanguage()->formatDuration( $param['duration'] ) ];
1184  } elseif ( isset( $param['expiry'] ) ) {
1185  return [ 'before', $this->getLanguage()->formatExpiry( $param['expiry'] ) ];
1186  } elseif ( isset( $param['period'] ) ) {
1187  return [ 'before', $this->getLanguage()->formatTimePeriod( $param['period'] ) ];
1188  } elseif ( isset( $param['size'] ) ) {
1189  return [ 'before', $this->getLanguage()->formatSize( $param['size'] ) ];
1190  } elseif ( isset( $param['bitrate'] ) ) {
1191  return [ 'before', $this->getLanguage()->formatBitrate( $param['bitrate'] ) ];
1192  } elseif ( isset( $param['plaintext'] ) ) {
1193  return [ 'after', $this->formatPlaintext( $param['plaintext'], $format ) ];
1194  } elseif ( isset( $param['list'] ) ) {
1195  return $this->formatListParam( $param['list'], $param['type'], $format );
1196  } else {
1197  if ( !is_scalar( $param ) ) {
1198  $param = serialize( $param );
1199  }
1200  \MediaWiki\Logger\LoggerFactory::getInstance( 'Bug58676' )->warning(
1201  'Invalid parameter for message "{msgkey}": {param}',
1202  [
1203  'exception' => new Exception,
1204  'msgkey' => $this->getKey(),
1205  'param' => htmlspecialchars( $param ),
1206  ]
1207  );
1208 
1209  return [ 'before', '[INVALID]' ];
1210  }
1211  } elseif ( $param instanceof Message ) {
1212  // Match language, flags, etc. to the current message.
1213  $msg = clone $param;
1214  if ( $msg->language !== $this->language || $msg->useDatabase !== $this->useDatabase ) {
1215  // Cache depends on these parameters
1216  $msg->message = null;
1217  }
1218  $msg->interface = $this->interface;
1219  $msg->language = $this->language;
1220  $msg->useDatabase = $this->useDatabase;
1221  $msg->title = $this->title;
1222 
1223  // DWIM
1224  if ( $format === 'block-parse' ) {
1225  $format = 'parse';
1226  }
1227  $msg->format = $format;
1228 
1229  // Message objects should not be before parameters because
1230  // then they'll get double escaped. If the message needs to be
1231  // escaped, it'll happen right here when we call toString().
1232  return [ 'after', $msg->toString( $format ) ];
1233  } else {
1234  return [ 'before', $param ];
1235  }
1236  }
1237 
1247  protected function parseText( $string ) {
1248  $out = MessageCache::singleton()->parse(
1249  $string,
1250  $this->title,
1251  /*linestart*/true,
1252  $this->interface,
1253  $this->getLanguage()
1254  );
1255 
1256  return $out instanceof ParserOutput
1257  ? $out->getText( [
1258  'enableSectionEditLinks' => false,
1259  // Wrapping messages in an extra <div> is probably not expected. If
1260  // they're outside the content area they probably shouldn't be
1261  // targeted by CSS that's targeting the parser output, and if
1262  // they're inside they already are from the outer div.
1263  'unwrap' => true,
1264  ] )
1265  : $out;
1266  }
1267 
1277  protected function transformText( $string ) {
1278  return MessageCache::singleton()->transform(
1279  $string,
1280  $this->interface,
1281  $this->getLanguage(),
1282  $this->title
1283  );
1284  }
1285 
1294  protected function fetchMessage() {
1295  if ( $this->message === null ) {
1297 
1298  foreach ( $this->keysToTry as $key ) {
1299  $message = $cache->get( $key, $this->useDatabase, $this->getLanguage() );
1300  if ( $message !== false && $message !== '' ) {
1301  break;
1302  }
1303  }
1304 
1305  // NOTE: The constructor makes sure keysToTry isn't empty,
1306  // so we know that $key and $message are initialized.
1307  $this->key = $key;
1308  $this->message = $message;
1309  }
1310  return $this->message;
1311  }
1312 
1325  protected function formatPlaintext( $plaintext, $format ) {
1326  switch ( $format ) {
1327  case self::FORMAT_TEXT:
1328  case self::FORMAT_PLAIN:
1329  return $plaintext;
1330 
1331  case self::FORMAT_PARSE:
1332  case self::FORMAT_BLOCK_PARSE:
1333  case self::FORMAT_ESCAPED:
1334  default:
1335  return htmlspecialchars( $plaintext, ENT_QUOTES );
1336  }
1337  }
1338 
1347  protected function formatListParam( array $params, $listType, $format ) {
1348  if ( !isset( self::$listTypeMap[$listType] ) ) {
1349  $warning = 'Invalid list type for message "' . $this->getKey() . '": '
1350  . htmlspecialchars( $listType )
1351  . ' (params are ' . htmlspecialchars( serialize( $params ) ) . ')';
1352  trigger_error( $warning, E_USER_WARNING );
1353  $e = new Exception;
1354  wfDebugLog( 'Bug58676', $warning . "\n" . $e->getTraceAsString() );
1355  return [ 'before', '[INVALID]' ];
1356  }
1357  $func = self::$listTypeMap[$listType];
1358 
1359  // Handle an empty list sensibly
1360  if ( !$params ) {
1361  return [ 'before', $this->getLanguage()->$func( [] ) ];
1362  }
1363 
1364  // First, determine what kinds of list items we have
1365  $types = [];
1366  $vars = [];
1367  $list = [];
1368  foreach ( $params as $n => $p ) {
1369  list( $type, $value ) = $this->extractParam( $p, $format );
1370  $types[$type] = true;
1371  $list[] = $value;
1372  $vars[] = '$' . ( $n + 1 );
1373  }
1374 
1375  // Easy case: all are 'before' or 'after', so just join the
1376  // values and use the same type.
1377  if ( count( $types ) === 1 ) {
1378  return [ key( $types ), $this->getLanguage()->$func( $list ) ];
1379  }
1380 
1381  // Hard case: We need to process each value per its type, then
1382  // return the concatenated values as 'after'. We handle this by turning
1383  // the list into a RawMessage and processing that as a parameter.
1384  $vars = $this->getLanguage()->$func( $vars );
1385  return $this->extractParam( new RawMessage( $vars, $params ), $format );
1386  }
1387 }
ParserOutput
Definition: ParserOutput.php:25
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
content
per default it will return the text for text based content
Definition: contenthandler.txt:104
$context
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
Definition: hooks.txt:2683
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
captcha-old.count
count
Definition: captcha-old.py:249
MediaWiki\Logger\LoggerFactory\getInstance
static getInstance( $channel)
Get a named logger instance from the currently configured logger factory.
Definition: LoggerFactory.php:92
MessageSpecifier\getKey
getKey()
Returns the message key.
MessageSpecifier
Definition: MessageSpecifier.php:21
$serialized
foreach( $res as $row) $serialized
Definition: testCompression.php:81
$params
$params
Definition: styleTest.css.php:44
serialize
serialize()
Definition: ApiMessageTrait.php:131
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:1082
php
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:35
MessageSpecifier\getParams
getParams()
Returns the message parameters.
MWException
MediaWiki exception.
Definition: MWException.php:26
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1118
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:545
$vars
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Definition: hooks.txt:2278
array
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))
list
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
MessageCache\singleton
static singleton()
Get the signleton instance of this class.
Definition: MessageCache.php:120
key
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
Definition: hooks.txt:2213
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2221
$value
$value
Definition: styleTest.css.php:49
StubUserLang
Stub object for the user language.
Definition: StubObject.php:178
title
title
Definition: parserTests.txt:239
language
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of either verbatim or with modifications and or translated into another language(Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:434
IContextSource\getTitle
getTitle()
format
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1683
plain
either a plain
Definition: hooks.txt:2105
message
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
Definition: hooks.txt:2213
$wgForceUIMsgAsContentMsg
$wgForceUIMsgAsContentMsg
When translating messages with wfMessage(), it is not always clear what should be considered UI messa...
Definition: DefaultSettings.php:3185
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
Content
Base interface for content objects.
Definition: Content.php:34
text
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
Definition: All_system_messages.txt:1267
unserialize
unserialize( $serialized)
Definition: ApiMessageTrait.php:139
$args
if( $line===false) $args
Definition: cdb.php:64
Title
Represents a title within MediaWiki.
Definition: Title.php:39
$cache
$cache
Definition: mcc.php:33
MessageContent
Wrapper allowing us to handle a system message as a Content object.
Definition: MessageContent.php:36
as
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
Definition: distributors.txt:9
$keys
$keys
Definition: testCompression.php:67
true
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:2044
$content
$content
Definition: pageupdater.txt:72
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:214
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:72
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
RawMessage
Variant of the Message class.
Definition: RawMessage.php:34
Language
Internationalisation code.
Definition: Language.php:35
$out
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:813
$type
$type
Definition: testCompression.php:48