MediaWiki  1.33.0
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  'titlestr' => $this->title ? $this->title->getFullText() : null,
293  ] );
294  }
295 
301  public function unserialize( $serialized ) {
303  if ( !is_array( $data ) ) {
304  throw new InvalidArgumentException( __METHOD__ . ': Invalid serialized data' );
305  }
306 
307  $this->interface = $data['interface'];
308  $this->key = $data['key'];
309  $this->keysToTry = $data['keysToTry'];
310  $this->parameters = $data['parameters'];
311  $this->format = $data['format'];
312  $this->useDatabase = $data['useDatabase'];
313  $this->language = $data['language'] ? Language::factory( $data['language'] ) : false;
314 
315  if ( isset( $data['titlestr'] ) ) {
316  $this->title = Title::newFromText( $data['titlestr'] );
317  } elseif ( isset( $data['title'] ) && $data['title'] instanceof Title ) {
318  // Old serializations from before December 2018
319  $this->title = $data['title'];
320  } else {
321  $this->title = null; // Explicit for sanity
322  }
323  }
324 
331  public function isMultiKey() {
332  return count( $this->keysToTry ) > 1;
333  }
334 
341  public function getKeysToTry() {
342  return $this->keysToTry;
343  }
344 
356  public function getKey() {
357  return $this->key;
358  }
359 
367  public function getParams() {
368  return $this->parameters;
369  }
370 
379  public function getFormat() {
380  wfDeprecated( __METHOD__, '1.29' );
381  return $this->format;
382  }
383 
391  public function getLanguage() {
392  // Defaults to false which means current user language
393  return $this->language ?: RequestContext::getMain()->getLanguage();
394  }
395 
408  public static function newFromKey( $key /*...*/ ) {
409  $params = func_get_args();
410  array_shift( $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( /*...*/ ) {
461  $keys = func_get_args();
462  if ( func_num_args() == 1 ) {
463  if ( is_array( $keys[0] ) ) {
464  // Allow an array to be passed as the first argument instead
465  $keys = array_values( $keys[0] );
466  } else {
467  // Optimize a single string to not need special fallback handling
468  $keys = $keys[0];
469  }
470  }
471  return new self( $keys );
472  }
473 
484  public function getTitle() {
486 
487  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
488  $lang = $this->getLanguage();
489  $title = $this->key;
490  if (
491  !$lang->equals( $contLang )
492  && in_array( $this->key, (array)$wgForceUIMsgAsContentMsg )
493  ) {
494  $title .= '/' . $lang->getCode();
495  }
496 
497  return Title::makeTitle(
498  NS_MEDIAWIKI, $contLang->ucfirst( strtr( $title, ' ', '_' ) ) );
499  }
500 
511  public function params( /*...*/ ) {
512  $args = func_get_args();
513 
514  // If $args has only one entry and it's an array, then it's either a
515  // non-varargs call or it happens to be a call with just a single
516  // "special" parameter. Since the "special" parameters don't have any
517  // numeric keys, we'll test that to differentiate the cases.
518  if ( count( $args ) === 1 && isset( $args[0] ) && is_array( $args[0] ) ) {
519  if ( $args[0] === [] ) {
520  $args = [];
521  } else {
522  foreach ( $args[0] as $key => $value ) {
523  if ( is_int( $key ) ) {
524  $args = $args[0];
525  break;
526  }
527  }
528  }
529  }
530 
531  $this->parameters = array_merge( $this->parameters, array_values( $args ) );
532  return $this;
533  }
534 
548  public function rawParams( /*...*/ ) {
549  $params = func_get_args();
550  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
551  $params = $params[0];
552  }
553  foreach ( $params as $param ) {
554  $this->parameters[] = self::rawParam( $param );
555  }
556  return $this;
557  }
558 
570  public function numParams( /*...*/ ) {
571  $params = func_get_args();
572  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
573  $params = $params[0];
574  }
575  foreach ( $params as $param ) {
576  $this->parameters[] = self::numParam( $param );
577  }
578  return $this;
579  }
580 
592  public function durationParams( /*...*/ ) {
593  $params = func_get_args();
594  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
595  $params = $params[0];
596  }
597  foreach ( $params as $param ) {
598  $this->parameters[] = self::durationParam( $param );
599  }
600  return $this;
601  }
602 
614  public function expiryParams( /*...*/ ) {
615  $params = func_get_args();
616  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
617  $params = $params[0];
618  }
619  foreach ( $params as $param ) {
620  $this->parameters[] = self::expiryParam( $param );
621  }
622  return $this;
623  }
624 
636  public function timeperiodParams( /*...*/ ) {
637  $params = func_get_args();
638  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
639  $params = $params[0];
640  }
641  foreach ( $params as $param ) {
642  $this->parameters[] = self::timeperiodParam( $param );
643  }
644  return $this;
645  }
646 
658  public function sizeParams( /*...*/ ) {
659  $params = func_get_args();
660  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
661  $params = $params[0];
662  }
663  foreach ( $params as $param ) {
664  $this->parameters[] = self::sizeParam( $param );
665  }
666  return $this;
667  }
668 
680  public function bitrateParams( /*...*/ ) {
681  $params = func_get_args();
682  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
683  $params = $params[0];
684  }
685  foreach ( $params as $param ) {
686  $this->parameters[] = self::bitrateParam( $param );
687  }
688  return $this;
689  }
690 
704  public function plaintextParams( /*...*/ ) {
705  $params = func_get_args();
706  if ( isset( $params[0] ) && is_array( $params[0] ) ) {
707  $params = $params[0];
708  }
709  foreach ( $params as $param ) {
710  $this->parameters[] = self::plaintextParam( $param );
711  }
712  return $this;
713  }
714 
724  public function setContext( IContextSource $context ) {
725  $this->inLanguage( $context->getLanguage() );
726  $this->title( $context->getTitle() );
727  $this->interface = true;
728 
729  return $this;
730  }
731 
743  public function inLanguage( $lang ) {
744  $previousLanguage = $this->language;
745 
746  if ( $lang instanceof Language ) {
747  $this->language = $lang;
748  } elseif ( is_string( $lang ) ) {
749  if ( !$this->language instanceof Language || $this->language->getCode() != $lang ) {
750  $this->language = Language::factory( $lang );
751  }
752  } elseif ( $lang instanceof StubUserLang ) {
753  $this->language = false;
754  } else {
755  $type = gettype( $lang );
756  throw new MWException( __METHOD__ . " must be "
757  . "passed a String or Language object; $type given"
758  );
759  }
760 
761  if ( $this->language !== $previousLanguage ) {
762  // The language has changed. Clear the message cache.
763  $this->message = null;
764  }
765  $this->interface = false;
766  return $this;
767  }
768 
778  public function inContentLanguage() {
780  if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) {
781  return $this;
782  }
783 
784  $this->inLanguage( MediaWikiServices::getInstance()->getContentLanguage() );
785  return $this;
786  }
787 
798  public function setInterfaceMessageFlag( $interface ) {
799  $this->interface = (bool)$interface;
800  return $this;
801  }
802 
812  public function useDatabase( $useDatabase ) {
813  $this->useDatabase = (bool)$useDatabase;
814  $this->message = null;
815  return $this;
816  }
817 
827  public function title( $title ) {
828  $this->title = $title;
829  return $this;
830  }
831 
837  public function content() {
838  if ( !$this->content ) {
839  $this->content = new MessageContent( $this );
840  }
841 
842  return $this->content;
843  }
844 
856  public function toString( $format = null ) {
857  if ( $format === null ) {
858  $ex = new LogicException( __METHOD__ . ' using implicit format: ' . $this->format );
859  \MediaWiki\Logger\LoggerFactory::getInstance( 'message-format' )->warning(
860  $ex->getMessage(), [ 'exception' => $ex, 'format' => $this->format, 'key' => $this->key ] );
861  $format = $this->format;
862  }
863  $string = $this->fetchMessage();
864 
865  if ( $string === false ) {
866  // Err on the side of safety, ensure that the output
867  // is always html safe in the event the message key is
868  // missing, since in that case its highly likely the
869  // message key is user-controlled.
870  // '⧼' is used instead of '<' to side-step any
871  // double-escaping issues.
872  // (Keep synchronised with mw.Message#toString in JS.)
873  return '⧼' . htmlspecialchars( $this->key ) . '⧽';
874  }
875 
876  # Replace $* with a list of parameters for &uselang=qqx.
877  if ( strpos( $string, '$*' ) !== false ) {
878  $paramlist = '';
879  if ( $this->parameters !== [] ) {
880  $paramlist = ': $' . implode( ', $', range( 1, count( $this->parameters ) ) );
881  }
882  $string = str_replace( '$*', $paramlist, $string );
883  }
884 
885  # Replace parameters before text parsing
886  $string = $this->replaceParameters( $string, 'before', $format );
887 
888  # Maybe transform using the full parser
889  if ( $format === self::FORMAT_PARSE ) {
890  $string = $this->parseText( $string );
891  $string = Parser::stripOuterParagraph( $string );
892  } elseif ( $format === self::FORMAT_BLOCK_PARSE ) {
893  $string = $this->parseText( $string );
894  } elseif ( $format === self::FORMAT_TEXT ) {
895  $string = $this->transformText( $string );
896  } elseif ( $format === self::FORMAT_ESCAPED ) {
897  $string = $this->transformText( $string );
898  $string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false );
899  }
900 
901  # Raw parameter replacement
902  $string = $this->replaceParameters( $string, 'after', $format );
903 
904  return $string;
905  }
906 
916  public function __toString() {
917  // PHP doesn't allow __toString to throw exceptions and will
918  // trigger a fatal error if it does. So, catch any exceptions.
919 
920  try {
921  return $this->toString( self::FORMAT_PARSE );
922  } catch ( Exception $ex ) {
923  try {
924  trigger_error( "Exception caught in " . __METHOD__ . " (message " . $this->key . "): "
925  . $ex, E_USER_WARNING );
926  } catch ( Exception $ex ) {
927  // Doh! Cause a fatal error after all?
928  }
929 
930  return '⧼' . htmlspecialchars( $this->key ) . '⧽';
931  }
932  }
933 
941  public function parse() {
942  $this->format = self::FORMAT_PARSE;
943  return $this->toString( self::FORMAT_PARSE );
944  }
945 
953  public function text() {
954  $this->format = self::FORMAT_TEXT;
955  return $this->toString( self::FORMAT_TEXT );
956  }
957 
965  public function plain() {
966  $this->format = self::FORMAT_PLAIN;
967  return $this->toString( self::FORMAT_PLAIN );
968  }
969 
977  public function parseAsBlock() {
978  $this->format = self::FORMAT_BLOCK_PARSE;
979  return $this->toString( self::FORMAT_BLOCK_PARSE );
980  }
981 
990  public function escaped() {
991  $this->format = self::FORMAT_ESCAPED;
992  return $this->toString( self::FORMAT_ESCAPED );
993  }
994 
1002  public function exists() {
1003  return $this->fetchMessage() !== false;
1004  }
1005 
1014  public function isBlank() {
1015  $message = $this->fetchMessage();
1016  return $message === false || $message === '';
1017  }
1018 
1026  public function isDisabled() {
1027  $message = $this->fetchMessage();
1028  return $message === false || $message === '' || $message === '-';
1029  }
1030 
1038  public static function rawParam( $raw ) {
1039  return [ 'raw' => $raw ];
1040  }
1041 
1049  public static function numParam( $num ) {
1050  return [ 'num' => $num ];
1051  }
1052 
1060  public static function durationParam( $duration ) {
1061  return [ 'duration' => $duration ];
1062  }
1063 
1071  public static function expiryParam( $expiry ) {
1072  return [ 'expiry' => $expiry ];
1073  }
1074 
1082  public static function timeperiodParam( $period ) {
1083  return [ 'period' => $period ];
1084  }
1085 
1093  public static function sizeParam( $size ) {
1094  return [ 'size' => $size ];
1095  }
1096 
1104  public static function bitrateParam( $bitrate ) {
1105  return [ 'bitrate' => $bitrate ];
1106  }
1107 
1115  public static function plaintextParam( $plaintext ) {
1116  return [ 'plaintext' => $plaintext ];
1117  }
1118 
1126  public static function listParam( array $list, $type = 'text' ) {
1127  if ( !isset( self::$listTypeMap[$type] ) ) {
1128  throw new InvalidArgumentException(
1129  "Invalid type '$type'. Known types are: " . implode( ', ', array_keys( self::$listTypeMap ) )
1130  );
1131  }
1132  return [ 'list' => $list, 'type' => $type ];
1133  }
1134 
1146  protected function replaceParameters( $message, $type, $format ) {
1147  // A temporary marker for $1 parameters that is only valid
1148  // in non-attribute contexts. However if the entire message is escaped
1149  // then we don't want to use it because it will be mangled in all contexts
1150  // and its unnessary as ->escaped() messages aren't html.
1151  $marker = $format === self::FORMAT_ESCAPED ? '$' : '$\'"';
1152  $replacementKeys = [];
1153  foreach ( $this->parameters as $n => $param ) {
1154  list( $paramType, $value ) = $this->extractParam( $param, $format );
1155  if ( $type === 'before' ) {
1156  if ( $paramType === 'before' ) {
1157  $replacementKeys['$' . ( $n + 1 )] = $value;
1158  } else /* $paramType === 'after' */ {
1159  // To protect against XSS from replacing parameters
1160  // inside html attributes, we convert $1 to $'"1.
1161  // In the event that one of the parameters ends up
1162  // in an attribute, either the ' or the " will be
1163  // escaped, breaking the replacement and avoiding XSS.
1164  $replacementKeys['$' . ( $n + 1 )] = $marker . ( $n + 1 );
1165  }
1166  } elseif ( $paramType === 'after' ) {
1167  $replacementKeys[$marker . ( $n + 1 )] = $value;
1168  }
1169  }
1170  return strtr( $message, $replacementKeys );
1171  }
1172 
1183  protected function extractParam( $param, $format ) {
1184  if ( is_array( $param ) ) {
1185  if ( isset( $param['raw'] ) ) {
1186  return [ 'after', $param['raw'] ];
1187  } elseif ( isset( $param['num'] ) ) {
1188  // Replace number params always in before step for now.
1189  // No support for combined raw and num params
1190  return [ 'before', $this->getLanguage()->formatNum( $param['num'] ) ];
1191  } elseif ( isset( $param['duration'] ) ) {
1192  return [ 'before', $this->getLanguage()->formatDuration( $param['duration'] ) ];
1193  } elseif ( isset( $param['expiry'] ) ) {
1194  return [ 'before', $this->getLanguage()->formatExpiry( $param['expiry'] ) ];
1195  } elseif ( isset( $param['period'] ) ) {
1196  return [ 'before', $this->getLanguage()->formatTimePeriod( $param['period'] ) ];
1197  } elseif ( isset( $param['size'] ) ) {
1198  return [ 'before', $this->getLanguage()->formatSize( $param['size'] ) ];
1199  } elseif ( isset( $param['bitrate'] ) ) {
1200  return [ 'before', $this->getLanguage()->formatBitrate( $param['bitrate'] ) ];
1201  } elseif ( isset( $param['plaintext'] ) ) {
1202  return [ 'after', $this->formatPlaintext( $param['plaintext'], $format ) ];
1203  } elseif ( isset( $param['list'] ) ) {
1204  return $this->formatListParam( $param['list'], $param['type'], $format );
1205  } else {
1206  if ( !is_scalar( $param ) ) {
1207  $param = serialize( $param );
1208  }
1209  \MediaWiki\Logger\LoggerFactory::getInstance( 'Bug58676' )->warning(
1210  'Invalid parameter for message "{msgkey}": {param}',
1211  [
1212  'exception' => new Exception,
1213  'msgkey' => $this->getKey(),
1214  'param' => htmlspecialchars( $param ),
1215  ]
1216  );
1217 
1218  return [ 'before', '[INVALID]' ];
1219  }
1220  } elseif ( $param instanceof Message ) {
1221  // Match language, flags, etc. to the current message.
1222  $msg = clone $param;
1223  if ( $msg->language !== $this->language || $msg->useDatabase !== $this->useDatabase ) {
1224  // Cache depends on these parameters
1225  $msg->message = null;
1226  }
1227  $msg->interface = $this->interface;
1228  $msg->language = $this->language;
1229  $msg->useDatabase = $this->useDatabase;
1230  $msg->title = $this->title;
1231 
1232  // DWIM
1233  if ( $format === 'block-parse' ) {
1234  $format = 'parse';
1235  }
1236  $msg->format = $format;
1237 
1238  // Message objects should not be before parameters because
1239  // then they'll get double escaped. If the message needs to be
1240  // escaped, it'll happen right here when we call toString().
1241  return [ 'after', $msg->toString( $format ) ];
1242  } else {
1243  return [ 'before', $param ];
1244  }
1245  }
1246 
1256  protected function parseText( $string ) {
1257  $out = MessageCache::singleton()->parse(
1258  $string,
1259  $this->title,
1260  /*linestart*/true,
1261  $this->interface,
1262  $this->getLanguage()
1263  );
1264 
1265  return $out instanceof ParserOutput
1266  ? $out->getText( [
1267  'enableSectionEditLinks' => false,
1268  // Wrapping messages in an extra <div> is probably not expected. If
1269  // they're outside the content area they probably shouldn't be
1270  // targeted by CSS that's targeting the parser output, and if
1271  // they're inside they already are from the outer div.
1272  'unwrap' => true,
1273  ] )
1274  : $out;
1275  }
1276 
1286  protected function transformText( $string ) {
1287  return MessageCache::singleton()->transform(
1288  $string,
1289  $this->interface,
1290  $this->getLanguage(),
1291  $this->title
1292  );
1293  }
1294 
1303  protected function fetchMessage() {
1304  if ( $this->message === null ) {
1306 
1307  foreach ( $this->keysToTry as $key ) {
1308  $message = $cache->get( $key, $this->useDatabase, $this->getLanguage() );
1309  if ( $message !== false && $message !== '' ) {
1310  break;
1311  }
1312  }
1313 
1314  // NOTE: The constructor makes sure keysToTry isn't empty,
1315  // so we know that $key and $message are initialized.
1316  $this->key = $key;
1317  $this->message = $message;
1318  }
1319  return $this->message;
1320  }
1321 
1334  protected function formatPlaintext( $plaintext, $format ) {
1335  switch ( $format ) {
1336  case self::FORMAT_TEXT:
1337  case self::FORMAT_PLAIN:
1338  return $plaintext;
1339 
1340  case self::FORMAT_PARSE:
1341  case self::FORMAT_BLOCK_PARSE:
1342  case self::FORMAT_ESCAPED:
1343  default:
1344  return htmlspecialchars( $plaintext, ENT_QUOTES );
1345  }
1346  }
1347 
1356  protected function formatListParam( array $params, $listType, $format ) {
1357  if ( !isset( self::$listTypeMap[$listType] ) ) {
1358  $warning = 'Invalid list type for message "' . $this->getKey() . '": '
1359  . htmlspecialchars( $listType )
1360  . ' (params are ' . htmlspecialchars( serialize( $params ) ) . ')';
1361  trigger_error( $warning, E_USER_WARNING );
1362  $e = new Exception;
1363  wfDebugLog( 'Bug58676', $warning . "\n" . $e->getTraceAsString() );
1364  return [ 'before', '[INVALID]' ];
1365  }
1366  $func = self::$listTypeMap[$listType];
1367 
1368  // Handle an empty list sensibly
1369  if ( !$params ) {
1370  return [ 'before', $this->getLanguage()->$func( [] ) ];
1371  }
1372 
1373  // First, determine what kinds of list items we have
1374  $types = [];
1375  $vars = [];
1376  $list = [];
1377  foreach ( $params as $n => $p ) {
1378  list( $type, $value ) = $this->extractParam( $p, $format );
1379  $types[$type] = true;
1380  $list[] = $value;
1381  $vars[] = '$' . ( $n + 1 );
1382  }
1383 
1384  // Easy case: all are 'before' or 'after', so just join the
1385  // values and use the same type.
1386  if ( count( $types ) === 1 ) {
1387  return [ key( $types ), $this->getLanguage()->$func( $list ) ];
1388  }
1389 
1390  // Hard case: We need to process each value per its type, then
1391  // return the concatenated values as 'after'. We handle this by turning
1392  // the list into a RawMessage and processing that as a parameter.
1393  $vars = $this->getLanguage()->$func( $vars );
1394  return $this->extractParam( new RawMessage( $vars, $params ), $format );
1395  }
1396 }
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:306
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:2636
$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.
$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 When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:780
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:134
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:1043
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.
$data
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
Definition: generatePhpCharToUpperMappings.php:13
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:925
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1078
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:576
$vars
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Definition: hooks.txt:2220
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:114
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:2154
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2162
$value
$value
Definition: styleTest.css.php:49
StubUserLang
Stub object for the user language.
Definition: StubObject.php:178
title
title
Definition: parserTests.txt:245
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:430
IContextSource\getTitle
getTitle()
format
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1644
plain
either a plain
Definition: hooks.txt:2046
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:2154
$wgForceUIMsgAsContentMsg
$wgForceUIMsgAsContentMsg
When translating messages with wfMessage(), it is not always clear what should be considered UI messa...
Definition: DefaultSettings.php:3159
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:142
$args
if( $line===false) $args
Definition: cdb.php:64
Title
Represents a title within MediaWiki.
Definition: Title.php:40
$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:1985
$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:215
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:36
$type
$type
Definition: testCompression.php:48