11use MediaWiki\FileRepo\File\File;
15use MediaWiki\Message\Message;
18use MediaWiki\Shell\Shell;
19use MediaWiki\Title\Title;
20use Wikimedia\ArrayUtils\ArrayUtils;
21use Wikimedia\FileBackend\FileBackend;
22use Wikimedia\FileBackend\FSFile\TempFSFile;
25use Wikimedia\Message\MessageParam;
26use Wikimedia\Message\MessageSpecifier;
28use Wikimedia\RequestTimeout\RequestTimeout;
29use Wikimedia\Timestamp\ConvertibleTimestamp;
30use Wikimedia\Timestamp\TimestampFormat as TS;
45 $path =
"$wgExtensionDirectory/$ext/extension.json";
47 ExtensionRegistry::getInstance()->queue(
$path );
65 $registry = ExtensionRegistry::getInstance();
66 foreach ( $exts as $ext ) {
67 $registry->queue(
"$wgExtensionDirectory/$ext/extension.json" );
82 $path =
"$wgStyleDirectory/$skin/skin.json";
84 ExtensionRegistry::getInstance()->queue(
$path );
96 $registry = ExtensionRegistry::getInstance();
97 foreach ( $skins as $skin ) {
98 $registry->queue(
"$wgStyleDirectory/$skin/skin.json" );
114 return ArrayUtils::insertAfter( $array, $insert, $after );
127 if ( is_object( $objOrArray ) ) {
128 $objOrArray = get_object_vars( $objOrArray );
130 foreach ( $objOrArray as $key => $value ) {
131 if ( $recursive && ( is_object( $value ) || is_array( $value ) ) ) {
135 $array[$key] = $value;
154 $max = mt_getrandmax() + 1;
155 $rand = number_format( ( mt_rand() * $max + mt_rand() ) / $max / $max, 12,
'.',
'' );
171 for ( $n = 0; $n < $length; $n += 7 ) {
172 $str .= sprintf(
'%07x', mt_rand() & 0xfffffff );
174 return substr( $str, 0, $length );
203 [
'%3B',
'%40',
'%24',
'%21',
'%2A',
'%28',
'%29',
'%2C',
'%2F',
'%7E',
'%3A' ],
204 [
';',
'@',
'$',
'!',
'*',
'(',
')',
',',
'/',
'~',
':' ],
220 if ( $array2 !==
null ) {
225 foreach ( $array1 as $key => $value ) {
226 if ( $value !==
null && $value !==
false ) {
230 if ( $prefix !==
'' ) {
231 $key = $prefix .
"[$key]";
233 if ( is_array( $value ) ) {
235 foreach ( $value as $k => $v ) {
236 $cgi .= $firstTime ?
'' :
'&';
237 if ( is_array( $v ) ) {
240 $cgi .= urlencode( $key .
"[$k]" ) .
'=' . urlencode( $v );
245 if ( is_object( $value ) ) {
246 $value = $value->__toString();
248 $cgi .= urlencode( $key ) .
'=' . urlencode( $value );
265 if ( isset( $query[0] ) && $query[0] ==
'?' ) {
266 $query = substr( $query, 1 );
268 $bits = explode(
'&', $query );
270 foreach ( $bits as $bit ) {
274 if ( !str_contains( $bit,
'=' ) ) {
279 [ $key, $value ] = explode(
'=', $bit );
281 $key = urldecode( $key );
282 $value = urldecode( $value );
283 if ( str_contains( $key,
'[' ) ) {
284 $keys = array_reverse( explode(
'[', $key ) );
285 $key = array_pop( $keys );
287 foreach ( $keys as $k ) {
288 $k = substr( $k, 0, -1 );
289 $temp = [ $k => $temp ];
291 if ( isset( $ret[$key] ) && is_array( $ret[$key] ) ) {
292 $ret[$key] = array_merge( $ret[$key], $temp );
312 if ( is_array( $query ) ) {
315 if ( $query !=
'' ) {
318 $hashPos = strpos(
$url,
'#' );
319 if ( $hashPos !==
false ) {
320 $fragment = substr(
$url, $hashPos );
325 if ( !str_contains(
$url,
'?' ) ) {
333 if ( $fragment !==
false ) {
360function wfDebug( $text, $dest =
'all', array $context = [] ) {
367 $text = trim( $text );
372 $context[
'private'] = ( $dest ===
false || $dest ===
'private' );
374 $logger = LoggerFactory::getInstance(
'wfDebug' );
375 $logger->debug( $text, $context );
384 if ( $cache !==
null ) {
389 if ( ( isset( $_GET[
'action'] ) && $_GET[
'action'] ==
'raw' )
425 $logGroup, $text, $dest =
'all', array $context = []
427 $text = trim( $text );
429 $logger = LoggerFactory::getInstance( $logGroup );
430 $context[
'private'] = ( $dest ===
false || $dest ===
'private' );
431 $logger->info( $text, $context );
443 $logger = LoggerFactory::getInstance(
'wfLogDBError' );
444 $logger->error( trim( $text ), $context );
463function wfDeprecated( $function, $version =
false, $component =
false, $callerOffset = 2 ) {
464 if ( !is_string( $version ) && $version !==
false ) {
465 throw new InvalidArgumentException(
466 "MediaWiki version must either be a string or false. " .
467 "Example valid version: '1.33'"
471 MWDebug::deprecated( $function, $version, $component, $callerOffset + 1 );
494function wfDeprecatedMsg( $msg, $version =
false, $component =
false, $callerOffset = 2 ) {
495 MWDebug::deprecatedMsg( $msg, $version, $component,
496 $callerOffset ===
false ?
false : $callerOffset + 1 );
509function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) {
510 MWDebug::warning( $msg, $callerOffset + 1, $level,
'auto' );
522function wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) {
523 MWDebug::warning( $msg, $callerOffset + 1, $level,
'production' );
549 if ( is_array( $key ) ) {
553 $message = Message::newFromSpecifier( $key );
558 $message->params( ...$params );
577 return Message::newFallbackSequence( ...$keys );
589 # Fix windows line-endings
590 # Some messages are split with explode("\n", $msg)
591 $message = str_replace(
"\r",
'', $message );
594 if ( is_array( $args ) && $args ) {
595 if ( is_array( $args[0] ) ) {
596 $args = array_values( $args[0] );
598 $replacementKeys = [];
599 foreach ( $args as $n => $param ) {
600 $replacementKeys[
'$' . ( $n + 1 )] = $param;
602 $message = strtr( $message, $replacementKeys );
623 return php_uname(
'n' ) ?:
'unknown';
637 static $disabled =
null;
639 if ( $disabled ===
null ) {
640 $disabled = !function_exists(
'debug_backtrace' );
642 wfDebug(
"debug_backtrace() is disabled" );
650 return array_slice( debug_backtrace( DEBUG_BACKTRACE_PROVIDE_OBJECT, $limit + 1 ), 1 );
652 return array_slice( debug_backtrace(), 1 );
667 $frameFormat =
"%s line %s calls %s()\n";
670 $frameFormat =
"<li>%s line %s calls %s()</li>\n";
671 $traceFormat =
"<ul>\n%s</ul>\n";
674 $frames = array_map(
static function ( $frame ) use ( $frameFormat ) {
675 $file = !empty( $frame[
'file'] ) ? basename( $frame[
'file'] ) :
'-';
676 $line = $frame[
'line'] ??
'-';
677 $call = $frame[
'function'];
678 if ( !empty( $frame[
'class'] ) ) {
679 $call = $frame[
'class'] . $frame[
'type'] . $call;
681 return sprintf( $frameFormat, $file, $line, $call );
684 return sprintf( $traceFormat, implode(
'', $frames ) );
699 if ( isset( $backtrace[$level] ) ) {
714 $limit = $limit ? $limit + 1 : 0;
733 if ( !isset( $frame[
'function'] ) ) {
734 return 'NO_FUNCTION_GIVEN';
736 return isset( $frame[
'class'] ) && isset( $frame[
'type'] ) ?
737 $frame[
'class'] . $frame[
'type'] . $frame[
'function'] :
751 static $result =
null;
752 if ( $result ===
null || $force ) {
754 if ( isset( $_SERVER[
'HTTP_ACCEPT_ENCODING'] ) ) {
755 # @todo FIXME: We may want to disallow some broken browsers
758 '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
759 $_SERVER[
'HTTP_ACCEPT_ENCODING'],
763 if ( isset( $m[2] ) && ( $m[1] ==
'q' ) && ( $m[2] == 0 ) ) {
766 wfDebug(
"wfClientAcceptsGzip: client accepts gzip." );
786 static $repl =
null, $repl2 =
null, $repl3 =
null, $repl4 =
null;
787 if ( $repl ===
null || defined(
'MW_PHPUNIT_TEST' ) ) {
791 '"' =>
'"',
'&' =>
'&',
"'" =>
''',
'<' =>
'<',
792 '=' =>
'=',
'>' =>
'>',
'[' =>
'[',
']' =>
']',
793 '{' =>
'{',
'|' =>
'|',
'}' =>
'}',
796 "\n!" =>
"\n!",
"\r!" =>
"\r!",
797 "\n#" =>
"\n#",
"\r#" =>
"\r#",
798 "\n*" =>
"\n*",
"\r*" =>
"\r*",
799 "\n:" =>
"\n:",
"\r:" =>
"\r:",
800 "\n " =>
"\n ",
"\r " =>
"\r ",
801 "\n\n" =>
"\n ",
"\r\n" =>
" \n",
802 "\n\r" =>
"\n ",
"\r\r" =>
"\r ",
803 "\n\t" =>
"\n	",
"\r\t" =>
"\r	",
804 "\n----" =>
"\n----",
"\r----" =>
"\r----",
805 '__' =>
'__',
'://' =>
'://',
813 foreach ( $magicLinks as $magic ) {
814 $repl[
"$magic "] =
"$magic ";
815 $repl[
"$magic\t"] =
"$magic	";
816 $repl[
"$magic\r"] =
"$magic ";
817 $repl[
"$magic\n"] =
"$magic ";
818 $repl[
"$magic\f"] =
"$magic";
828 '+' =>
'+',
'-' =>
'-',
'_' =>
'_',
'~' =>
'~',
837 '_' =>
'_',
'~' =>
'~',
838 "\n" =>
" ",
"\r" =>
" ",
846 if ( substr( $prot, -1 ) ===
':' ) {
847 $repl2[] = preg_quote( substr( $prot, 0, -1 ),
'/' );
850 $repl2 = $repl2 ?
'/\b(' . implode(
'|', $repl2 ) .
'):/i' :
'/^(?!)/';
853 '@phan-var string $repl2';
854 '@phan-var string $repl3';
855 '@phan-var string $repl4';
857 $text = substr( strtr(
"\n$input", $repl ), 1 );
858 if ( $text ===
'' ) {
861 $first = strtr( $text[0], $repl3 );
862 if ( strlen( $text ) > 1 ) {
863 $text = $first . substr( $text, 1, -1 ) .
864 strtr( substr( $text, -1 ), $repl4 );
867 $text = strtr( $first, $repl4 );
869 $text = preg_replace( $repl2,
'$1:', $text );
885 if (
$source !==
null || $force ) {
901 $temp = (bool)( $dest & $bit );
902 if ( $state !==
null ) {
920 $s = str_replace(
"\n",
"<br />\n", var_export( $var,
true ) .
"\n" );
921 if ( HttpHeader::headersSent() ||
$wgOut ===
null || !is_object(
$wgOut ) ) {
937 HttpStatus::header( $code );
940 $wgOut->sendCacheControl();
944 HttpHeader::send(
'Content-type: text/html; charset=utf-8' );
945 ContentSecurityPolicy::sendRestrictiveHeader();
947 print
'<!DOCTYPE html>' .
948 '<html><head><title>' .
949 htmlspecialchars( $label ) .
950 '</title><meta name="color-scheme" content="light dark" /></head><body><h1>' .
951 htmlspecialchars( $label ) .
953 nl2br( htmlspecialchars( $desc ) ) .
954 "</p></body></html>\n";
955 HttpHeader::send(
'Content-Length: ' . ob_get_length() );
982 if ( defined(
'MW_PHPUNIT_TEST' ) ) {
986 while ( $status = ob_get_status() ) {
987 if ( isset( $status[
'flags'] ) ) {
988 $flags = PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_REMOVABLE;
989 $deletable = ( $status[
'flags'] & $flags ) === $flags;
990 } elseif ( isset( $status[
'del'] ) ) {
991 $deletable = $status[
'del'];
994 $deletable = $status[
'type'] !== 0;
1001 if ( !ob_end_clean() ) {
1006 if ( $resetGzipEncoding && $status[
'name'] ==
'ob_gzhandler' ) {
1009 header_remove(
'Content-Encoding' );
1026 $ret = ConvertibleTimestamp::convert( $outputtype, $ts );
1027 if ( $ret ===
false ) {
1028 if ( $outputtype instanceof TS ) {
1029 $outputtype = $outputtype->name;
1031 wfDebug(
"wfTimestamp() fed bogus time value: TYPE=$outputtype; VALUE=$ts" );
1045 if ( $ts ===
null ) {
1058 return ConvertibleTimestamp::now( TS::MW );
1079 return TempFSFile::getUsableTempDirectory();
1093 if ( FileBackend::isStoragePath( $dir ) ) {
1094 throw new LogicException( __FUNCTION__ .
" given storage path '$dir'." );
1096 if ( $caller !==
null ) {
1097 wfDebug(
"$caller: called wfMkdirParents($dir)" );
1099 if ( strval( $dir ) ===
'' ) {
1103 $dir = str_replace( [
'\\',
'/' ], DIRECTORY_SEPARATOR, $dir );
1113 $ok = is_dir( $dir ) || @mkdir( $dir, $mode,
true ) || is_dir( $dir );
1115 trigger_error( sprintf(
"failed to mkdir \"%s\" mode 0%o", $dir, $mode ), E_USER_WARNING );
1128 if ( is_dir( $dir ) ) {
1129 $objects = scandir( $dir );
1130 foreach ( $objects as $object ) {
1131 if ( $object !=
"." && $object !=
".." ) {
1132 if ( filetype( $dir .
'/' . $object ) ==
"dir" ) {
1135 unlink( $dir .
'/' . $object );
1152function wfPercent( $nr,
int $acc = 2,
bool $round =
true ) {
1154 $accForFormat = $acc >= 0 ? $acc : 0;
1155 $ret = sprintf(
"%.{$accForFormat}f", $nr );
1156 return $round ? round( (
float)$ret, $acc ) .
'%' :
"$ret%";
1199 $val = strtolower( $val );
1204 || preg_match(
"/^\s*[+-]?0*[1-9]/", $val );
1222 return Shell::escape( ...$args );
1250 $limits = [], $options = []
1253 if ( Shell::isDisabled() ) {
1256 return 'Unable to run external programs, proc_open() is disabled.';
1259 if ( is_array( $cmd ) ) {
1260 $cmd = Shell::escape( $cmd );
1263 $includeStderr = isset( $options[
'duplicateStderr'] ) && $options[
'duplicateStderr'];
1264 $profileMethod = $options[
'profileMethod'] ??
wfGetCaller();
1267 $result = Shell::command( [] )
1268 ->unsafeParams( (array)$cmd )
1269 ->environment( $environ )
1271 ->includeStderr( $includeStderr )
1272 ->profileMethod( $profileMethod )
1274 ->restrict( Shell::RESTRICT_NONE )
1276 }
catch ( ProcOpenError ) {
1281 $retval = $result->getExitCode();
1283 return $result->getStdout();
1305 return wfShellExec( $cmd, $retval, $environ, $limits,
1306 [
'duplicateStderr' =>
true,
'profileMethod' =>
wfGetCaller() ] );
1329 (
new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) )
1330 ->onWfShellWikiCmd( $script, $parameters, $options );
1331 $cmd = [ $options[
'php'] ??
$wgPhpCli ];
1332 if ( isset( $options[
'wrapper'] ) ) {
1333 $cmd[] = $options[
'wrapper'];
1337 return Shell::escape( array_merge( $cmd, $parameters ) );
1360 ?
string &$simplisticMergeAttempt,
1361 ?
string &$mergeLeftovers =
null
1365 # This check may also protect against code injection in
1366 # case of broken installations.
1370 if ( !$haveDiff3 ) {
1375 # Make temporary files
1377 $oldtextFile = fopen( $oldtextName = tempnam( $td,
'merge-old-' ),
'w' );
1378 $mytextFile = fopen( $mytextName = tempnam( $td,
'merge-mine-' ),
'w' );
1379 $yourtextFile = fopen( $yourtextName = tempnam( $td,
'merge-your-' ),
'w' );
1381 # NOTE: diff3 issues a warning to stderr if any of the files does not end with
1382 # a newline character. To avoid this, we normalize the trailing whitespace before
1383 # creating the diff.
1385 fwrite( $oldtextFile, rtrim( $old ) .
"\n" );
1386 fclose( $oldtextFile );
1387 fwrite( $mytextFile, rtrim( $mine ) .
"\n" );
1388 fclose( $mytextFile );
1389 fwrite( $yourtextFile, rtrim( $yours ) .
"\n" );
1390 fclose( $yourtextFile );
1392 # Check for a conflict
1393 $cmd = Shell::escape(
$wgDiff3,
'--text',
'--overlap-only', $mytextName,
1394 $oldtextName, $yourtextName );
1395 $handle = popen( $cmd,
'r' );
1397 $mergeLeftovers =
'';
1399 $data = fread( $handle, 8192 );
1400 if ( $data ===
false || $data ===
'' ) {
1403 $mergeLeftovers .= $data;
1407 $conflict = $mergeLeftovers !==
'';
1409 # Merge differences automatically where possible, preferring "my" text for conflicts.
1410 $cmd = Shell::escape(
$wgDiff3,
'--text',
'--ed',
'--merge', $mytextName,
1411 $oldtextName, $yourtextName );
1412 $handle = popen( $cmd,
'r' );
1413 $simplisticMergeAttempt =
'';
1415 $data = fread( $handle, 8192 );
1416 if ( $data ===
false || $data ===
'' ) {
1419 $simplisticMergeAttempt .= $data;
1422 unlink( $mytextName );
1423 unlink( $oldtextName );
1424 unlink( $yourtextName );
1426 if ( $simplisticMergeAttempt ===
'' && $old !==
'' && !$conflict ) {
1427 wfDebug(
"Unexpected null result from diff3. Command: $cmd" );
1446 if ( $suffix ==
'' ) {
1449 $encSuffix =
'(?:' . preg_quote( $suffix,
'#' ) .
')?';
1453 if ( preg_match(
"#([^/\\\\]*?){$encSuffix}[/\\\\]*$#",
$path, $matches ) ) {
1471 $path = str_replace(
'/', DIRECTORY_SEPARATOR,
$path );
1472 $from = str_replace(
'/', DIRECTORY_SEPARATOR, $from );
1476 $from = rtrim( $from, DIRECTORY_SEPARATOR );
1478 $pieces = explode( DIRECTORY_SEPARATOR, dirname(
$path ) );
1479 $against = explode( DIRECTORY_SEPARATOR, $from );
1481 if ( $pieces[0] !== $against[0] ) {
1488 while ( count( $pieces ) && count( $against )
1489 && $pieces[0] == $against[0] ) {
1490 array_shift( $pieces );
1491 array_shift( $against );
1495 while ( count( $against ) ) {
1496 array_unshift( $pieces,
'..' );
1497 array_shift( $against );
1502 return implode( DIRECTORY_SEPARATOR, $pieces );
1516 if ( $script ===
'index' ) {
1518 } elseif ( $script ===
'load' ) {
1521 return "{$wgScriptPath}/{$script}.php";
1533 return $value ?
'true' :
'false';
1556 $name = preg_replace(
1557 "/[^" . Title::legalChars() .
"]" . $illegalFileChars .
"/",
1575 if ( $oldLimit != -1 ) {
1577 if ( $newLimit == -1 ) {
1578 wfDebug(
"Removing PHP's memory limit" );
1580 @ini_set(
'memory_limit', $newLimit );
1581 } elseif ( $newLimit > $oldLimit ) {
1582 wfDebug(
"Raising PHP's memory limit to $newLimit bytes" );
1584 @ini_set(
'memory_limit', $newLimit );
1598 $timeout = RequestTimeout::singleton();
1599 $timeLimit = $timeout->getWallTimeLimit();
1600 if ( $timeLimit !== INF ) {
1607 $timeLimit = (int)ini_get(
'max_execution_time' );
1613 ignore_user_abort(
true );
1626 $string = trim( $string ??
'' );
1627 if ( $string ===
'' ) {
1630 $last = substr( $string, -1 );
1631 $val = intval( $string );
1658 return in_array( $str, ExpiryDef::INFINITY_VALS );
1678 $multipliers = [ 1 ];
1686 if ( !$handler || !isset( $params[
'width'] ) ) {
1691 if ( isset( $params[
'page'] ) ) {
1692 $basicParams[
'page'] = $params[
'page'];
1698 foreach ( $multipliers as $multiplier ) {
1699 $thumbLimits = array_merge( $thumbLimits, array_map(
1700 static function ( $width ) use ( $multiplier ) {
1701 return round( $width * $multiplier );
1704 $imageLimits = array_merge( $imageLimits, array_map(
1705 static function ( $pair ) use ( $multiplier ) {
1707 round( $pair[0] * $multiplier ),
1708 round( $pair[1] * $multiplier ),
1715 if ( in_array( $params[
'width'], $thumbLimits ) ) {
1716 $normalParams = $basicParams + [
'width' => $params[
'width'] ];
1718 $handler->normaliseParams( $file, $normalParams );
1722 foreach ( $imageLimits as $pair ) {
1723 $normalParams = $basicParams + [
'width' => $pair[0],
'height' => $pair[1] ];
1726 $handler->normaliseParams( $file, $normalParams );
1728 if ( $normalParams[
'width'] == $params[
'width'] ) {
1739 foreach ( $params as $key => $value ) {
1740 if ( !isset( $normalParams[$key] ) || $normalParams[$key] != $value ) {
1763 return ArrayUtils::arrayPlus2d( $baseArray, $newValues );
1771 LoggerFactory::getInstance(
'unserialize' )->error(
'Could not unserialize class {class}', [
1772 'class' => $className,
1773 'exception' => new RuntimeException( __FUNCTION__ ),
wfIsWindows()
Check if the operating system is Windows.
wfThumbIsStandard(File $file, array $params)
Returns true if these thumbnail parameters match one that MediaWiki requests from file description pa...
wfVarDump( $var)
A wrapper around the PHP function var_export().
wfTimestampOrNull( $outputtype=TS::UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfRandom()
Get a random decimal value in the domain of [0, 1), in a way not likely to give duplicate values for ...
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
wfTempDir()
Tries to get the system directory for temporary files.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfRandomString( $length=32)
Get a random string containing a number of pseudo-random hex characters.
wfBaseName( $path, $suffix='')
Return the final portion of a pathname.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfClientAcceptsGzip( $force=false)
Whether the client accept gzip encoding.
wfEscapeShellArg(... $args)
Locale-independent version of escapeshellarg().
wfLogDBError( $text, array $context=[])
Log for database errors.
wfLoadSkins(array $skins)
Load multiple skins at once.
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
wfRecursiveRemoveDir( $dir)
Remove a directory and all its content.
wfLoadExtension( $ext, $path=null)
Load an extension.
wfMemoryLimit( $newLimit)
Raise PHP's memory limit (if needed).
wfSetBit(&$dest, $bit, $state=true)
As for wfSetVar except setting a bit.
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
wfShorthandToInteger(?string $string='', int $default=-1)
Converts shorthand byte notation to integer form.
wfBacktrace( $raw=null)
Get a debug backtrace as a string.
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
wfShellExec( $cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
wfIsDebugRawPage()
Returns true if debug logging should be suppressed if $wgDebugRawPage = false.
wfHostname()
Get host name of the current machine, for use in error reporting.
wfShellWikiCmd( $script, array $parameters=[], array $options=[])
Generate a shell-escaped command line string to run a MediaWiki cli script.
wfPercent( $nr, int $acc=2, bool $round=true)
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
wfShellExecWithStderr( $cmd, &$retval=null, $environ=[], $limits=[])
Execute a shell command, returning both stdout and stderr.
wfGetNull()
Get a platform-independent path to the null file, e.g.
wfRelativePath( $path, $from)
Generate a relative path name to the given file.
wfHttpError( $code, $label, $desc)
Provide a simple HTTP error.
wfMessageFallback(... $keys)
This function accepts multiple message keys and returns a message instance for the first message whic...
wfMerge(string $old, string $mine, string $yours, ?string &$simplisticMergeAttempt, ?string &$mergeLeftovers=null)
wfMerge attempts to merge differences between three texts.
wfGetAllCallers( $limit=3)
Return a string consisting of callers in the stack.
wfArrayPlus2d(array $baseArray, array $newValues)
Merges two (possibly) 2 dimensional arrays into the target array ($baseArray).
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
wfTransactionalTimeLimit()
Raise the request time limit to $wgTransactionalTimeLimit.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfObjectToArray( $objOrArray, $recursive=true)
Recursively converts the parameter (an object) to an array with the same data.
wfLoadSkin( $skin, $path=null)
Load a skin.
wfMsgReplaceArgs( $message, $args)
Replace message parameter keys on the given formatted output.
wfStringToBool( $val)
Convert string value to boolean, when the following are interpreted as true:
wfTimestamp( $outputtype=TS::UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDebugBacktrace( $limit=0)
Safety wrapper for debug_backtrace().
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfStripIllegalFilenameChars( $name)
Replace all invalid characters with '-'.
wfFormatStackFrame( $frame)
Return a string representation of frame.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
wfScript( $script='index')
Get the URL path to a MediaWiki entry point.
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
wfIsInfinity( $str)
Determine input string is represents as infinity.
wfUnserializeMissingClass(string $className)
Logs missing classes when unserializing.
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
wfLoadExtensions(array $exts)
Load multiple extensions at once.
wfBoolToStr( $value)
Convenience function converts boolean values into "true" or "false" (string) values.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
wfArrayInsertAfter(array $array, array $insert, $after)
Insert an array into another array after the specified key.
wfResetOutputBuffers( $resetGzipEncoding=true)
Clear away any user-level output buffers, discarding contents.
if(MW_ENTRY_POINT==='index') if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli') global $wgOut
Handle sending Content-Security-Policy headers.
$wgScript
Config variable stub for the Script setting, for use by phpdoc and IDEs.
$wgThumbLimits
Config variable stub for the ThumbLimits setting, for use by phpdoc and IDEs.
$wgDebugLogPrefix
Config variable stub for the DebugLogPrefix setting, for use by phpdoc and IDEs.
$wgPhpCli
Config variable stub for the PhpCli setting, for use by phpdoc and IDEs.
$wgOverrideHostname
Config variable stub for the OverrideHostname setting, for use by phpdoc and IDEs.
$wgImageLimits
Config variable stub for the ImageLimits setting, for use by phpdoc and IDEs.
$wgTmpDirectory
Config variable stub for the TmpDirectory setting, for use by phpdoc and IDEs.
$wgStyleDirectory
Config variable stub for the StyleDirectory setting, for use by phpdoc and IDEs.
$wgTransactionalTimeLimit
Config variable stub for the TransactionalTimeLimit setting, for use by phpdoc and IDEs.
$wgIllegalFileChars
Config variable stub for the IllegalFileChars setting, for use by phpdoc and IDEs.
$wgDirectoryMode
Config variable stub for the DirectoryMode setting, for use by phpdoc and IDEs.
$wgDiff3
Config variable stub for the Diff3 setting, for use by phpdoc and IDEs.
$wgUrlProtocols
Config variable stub for the UrlProtocols setting, for use by phpdoc and IDEs.
$wgResponsiveImages
Config variable stub for the ResponsiveImages setting, for use by phpdoc and IDEs.
$wgDebugRawPage
Config variable stub for the DebugRawPage setting, for use by phpdoc and IDEs.
$wgEnableMagicLinks
Config variable stub for the EnableMagicLinks setting, for use by phpdoc and IDEs.
$wgScriptPath
Config variable stub for the ScriptPath setting, for use by phpdoc and IDEs.
$wgExtensionDirectory
Config variable stub for the ExtensionDirectory setting, for use by phpdoc and IDEs.
$wgLoadScript
Config variable stub for the LoadScript setting, for use by phpdoc and IDEs.