27use Wikimedia\RequestTimeout\RequestTimeout;
28use Wikimedia\Timestamp\ConvertibleTimestamp;
29use Wikimedia\Timestamp\TimestampFormat as TS;
44 $path =
"$wgExtensionDirectory/$ext/extension.json";
46 ExtensionRegistry::getInstance()->queue(
$path );
64 $registry = ExtensionRegistry::getInstance();
65 foreach ( $exts as $ext ) {
66 $registry->queue(
"$wgExtensionDirectory/$ext/extension.json" );
81 $path =
"$wgStyleDirectory/$skin/skin.json";
83 ExtensionRegistry::getInstance()->queue(
$path );
95 $registry = ExtensionRegistry::getInstance();
96 foreach ( $skins as $skin ) {
97 $registry->queue(
"$wgStyleDirectory/$skin/skin.json" );
113 return ArrayUtils::insertAfter( $array, $insert, $after );
126 if ( is_object( $objOrArray ) ) {
127 $objOrArray = get_object_vars( $objOrArray );
129 foreach ( $objOrArray as $key => $value ) {
130 if ( $recursive && ( is_object( $value ) || is_array( $value ) ) ) {
134 $array[$key] = $value;
153 $max = mt_getrandmax() + 1;
154 $rand = number_format( ( mt_rand() * $max + mt_rand() ) / $max / $max, 12,
'.',
'' );
170 for ( $n = 0; $n < $length; $n += 7 ) {
171 $str .= sprintf(
'%07x', mt_rand() & 0xfffffff );
173 return substr( $str, 0, $length );
212 if ( $needle ===
null ) {
213 $needle = [
'%3B',
'%40',
'%24',
'%21',
'%2A',
'%28',
'%29',
'%2C',
'%2F',
'%7E' ];
214 if ( !isset( $_SERVER[
'SERVER_SOFTWARE'] ) ||
215 !str_contains( $_SERVER[
'SERVER_SOFTWARE'],
'Microsoft-IIS/7' )
221 $s = urlencode( $s );
224 [
';',
'@',
'$',
'!',
'*',
'(',
')',
',',
'/',
'~',
':' ],
242 if ( $array2 !==
null ) {
247 foreach ( $array1 as $key => $value ) {
248 if ( $value !==
null && $value !==
false ) {
252 if ( $prefix !==
'' ) {
253 $key = $prefix .
"[$key]";
255 if ( is_array( $value ) ) {
257 foreach ( $value as $k => $v ) {
258 $cgi .= $firstTime ?
'' :
'&';
259 if ( is_array( $v ) ) {
262 $cgi .= urlencode( $key .
"[$k]" ) .
'=' . urlencode( $v );
267 if ( is_object( $value ) ) {
268 $value = $value->__toString();
270 $cgi .= urlencode( $key ) .
'=' . urlencode( $value );
287 if ( isset( $query[0] ) && $query[0] ==
'?' ) {
288 $query = substr( $query, 1 );
290 $bits = explode(
'&', $query );
292 foreach ( $bits as $bit ) {
296 if ( !str_contains( $bit,
'=' ) ) {
301 [ $key, $value ] = explode(
'=', $bit );
303 $key = urldecode( $key );
304 $value = urldecode( $value );
305 if ( str_contains( $key,
'[' ) ) {
306 $keys = array_reverse( explode(
'[', $key ) );
307 $key = array_pop( $keys );
309 foreach ( $keys as $k ) {
310 $k = substr( $k, 0, -1 );
311 $temp = [ $k => $temp ];
313 if ( isset( $ret[$key] ) && is_array( $ret[$key] ) ) {
314 $ret[$key] = array_merge( $ret[$key], $temp );
334 if ( is_array( $query ) ) {
337 if ( $query !=
'' ) {
340 $hashPos = strpos(
$url,
'#' );
341 if ( $hashPos !==
false ) {
342 $fragment = substr(
$url, $hashPos );
347 if ( !str_contains(
$url,
'?' ) ) {
355 if ( $fragment !==
false ) {
382function wfDebug( $text, $dest =
'all', array $context = [] ) {
389 $text = trim( $text );
394 $context[
'private'] = ( $dest ===
false || $dest ===
'private' );
396 $logger = LoggerFactory::getInstance(
'wfDebug' );
397 $logger->debug( $text, $context );
406 if ( $cache !==
null ) {
411 if ( ( isset( $_GET[
'action'] ) && $_GET[
'action'] ==
'raw' )
447 $logGroup, $text, $dest =
'all', array $context = []
449 $text = trim( $text );
451 $logger = LoggerFactory::getInstance( $logGroup );
452 $context[
'private'] = ( $dest ===
false || $dest ===
'private' );
453 $logger->info( $text, $context );
465 $logger = LoggerFactory::getInstance(
'wfLogDBError' );
466 $logger->error( trim( $text ), $context );
485function wfDeprecated( $function, $version =
false, $component =
false, $callerOffset = 2 ) {
486 if ( !is_string( $version ) && $version !==
false ) {
487 throw new InvalidArgumentException(
488 "MediaWiki version must either be a string or false. " .
489 "Example valid version: '1.33'"
493 MWDebug::deprecated( $function, $version, $component, $callerOffset + 1 );
516function wfDeprecatedMsg( $msg, $version =
false, $component =
false, $callerOffset = 2 ) {
517 MWDebug::deprecatedMsg( $msg, $version, $component,
518 $callerOffset ===
false ?
false : $callerOffset + 1 );
531function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) {
532 MWDebug::warning( $msg, $callerOffset + 1, $level,
'auto' );
544function wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) {
545 MWDebug::warning( $msg, $callerOffset + 1, $level,
'production' );
571 if ( is_array( $key ) ) {
575 $message = Message::newFromSpecifier( $key );
580 $message->params( ...$params );
599 return Message::newFallbackSequence( ...$keys );
611 # Fix windows line-endings
612 # Some messages are split with explode("\n", $msg)
613 $message = str_replace(
"\r",
'', $message );
616 if ( is_array( $args ) && $args ) {
617 if ( is_array( $args[0] ) ) {
618 $args = array_values( $args[0] );
620 $replacementKeys = [];
621 foreach ( $args as $n => $param ) {
622 $replacementKeys[
'$' . ( $n + 1 )] = $param;
624 $message = strtr( $message, $replacementKeys );
645 return php_uname(
'n' ) ?:
'unknown';
659 static $disabled =
null;
661 if ( $disabled ===
null ) {
662 $disabled = !function_exists(
'debug_backtrace' );
664 wfDebug(
"debug_backtrace() is disabled" );
672 return array_slice( debug_backtrace( DEBUG_BACKTRACE_PROVIDE_OBJECT, $limit + 1 ), 1 );
674 return array_slice( debug_backtrace(), 1 );
689 $frameFormat =
"%s line %s calls %s()\n";
692 $frameFormat =
"<li>%s line %s calls %s()</li>\n";
693 $traceFormat =
"<ul>\n%s</ul>\n";
696 $frames = array_map(
static function ( $frame ) use ( $frameFormat ) {
697 $file = !empty( $frame[
'file'] ) ? basename( $frame[
'file'] ) :
'-';
698 $line = $frame[
'line'] ??
'-';
699 $call = $frame[
'function'];
700 if ( !empty( $frame[
'class'] ) ) {
701 $call = $frame[
'class'] . $frame[
'type'] . $call;
703 return sprintf( $frameFormat, $file, $line, $call );
706 return sprintf( $traceFormat, implode(
'', $frames ) );
721 if ( isset( $backtrace[$level] ) ) {
736 $limit = $limit ? $limit + 1 : 0;
755 if ( !isset( $frame[
'function'] ) ) {
756 return 'NO_FUNCTION_GIVEN';
758 return isset( $frame[
'class'] ) && isset( $frame[
'type'] ) ?
759 $frame[
'class'] . $frame[
'type'] . $frame[
'function'] :
773 static $result =
null;
774 if ( $result ===
null || $force ) {
776 if ( isset( $_SERVER[
'HTTP_ACCEPT_ENCODING'] ) ) {
777 # @todo FIXME: We may want to disallow some broken browsers
780 '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
781 $_SERVER[
'HTTP_ACCEPT_ENCODING'],
785 if ( isset( $m[2] ) && ( $m[1] ==
'q' ) && ( $m[2] == 0 ) ) {
788 wfDebug(
"wfClientAcceptsGzip: client accepts gzip." );
808 static $repl =
null, $repl2 =
null, $repl3 =
null, $repl4 =
null;
809 if ( $repl ===
null || defined(
'MW_PHPUNIT_TEST' ) ) {
813 '"' =>
'"',
'&' =>
'&',
"'" =>
''',
'<' =>
'<',
814 '=' =>
'=',
'>' =>
'>',
'[' =>
'[',
']' =>
']',
815 '{' =>
'{',
'|' =>
'|',
'}' =>
'}',
818 "\n!" =>
"\n!",
"\r!" =>
"\r!",
819 "\n#" =>
"\n#",
"\r#" =>
"\r#",
820 "\n*" =>
"\n*",
"\r*" =>
"\r*",
821 "\n:" =>
"\n:",
"\r:" =>
"\r:",
822 "\n " =>
"\n ",
"\r " =>
"\r ",
823 "\n\n" =>
"\n ",
"\r\n" =>
" \n",
824 "\n\r" =>
"\n ",
"\r\r" =>
"\r ",
825 "\n\t" =>
"\n	",
"\r\t" =>
"\r	",
826 "\n----" =>
"\n----",
"\r----" =>
"\r----",
827 '__' =>
'__',
'://' =>
'://',
835 foreach ( $magicLinks as $magic ) {
836 $repl[
"$magic "] =
"$magic ";
837 $repl[
"$magic\t"] =
"$magic	";
838 $repl[
"$magic\r"] =
"$magic ";
839 $repl[
"$magic\n"] =
"$magic ";
840 $repl[
"$magic\f"] =
"$magic";
850 '+' =>
'+',
'-' =>
'-',
'_' =>
'_',
'~' =>
'~',
859 '_' =>
'_',
'~' =>
'~',
860 "\n" =>
" ",
"\r" =>
" ",
868 if ( substr( $prot, -1 ) ===
':' ) {
869 $repl2[] = preg_quote( substr( $prot, 0, -1 ),
'/' );
872 $repl2 = $repl2 ?
'/\b(' . implode(
'|', $repl2 ) .
'):/i' :
'/^(?!)/';
875 '@phan-var string $repl2';
876 '@phan-var string $repl3';
877 '@phan-var string $repl4';
879 $text = substr( strtr(
"\n$input", $repl ), 1 );
880 if ( $text ===
'' ) {
883 $first = strtr( $text[0], $repl3 );
884 if ( strlen( $text ) > 1 ) {
885 $text = $first . substr( $text, 1, -1 ) .
886 strtr( substr( $text, -1 ), $repl4 );
889 $text = strtr( $first, $repl4 );
891 $text = preg_replace( $repl2,
'$1:', $text );
907 if (
$source !==
null || $force ) {
923 $temp = (bool)( $dest & $bit );
924 if ( $state !==
null ) {
942 $s = str_replace(
"\n",
"<br />\n", var_export( $var,
true ) .
"\n" );
943 if ( headers_sent() ||
$wgOut ===
null || !is_object(
$wgOut ) ) {
959 HttpStatus::header( $code );
962 $wgOut->sendCacheControl();
965 \MediaWiki\Request\HeaderCallback::warnIfHeadersSent();
966 header(
'Content-type: text/html; charset=utf-8' );
967 ContentSecurityPolicy::sendRestrictiveHeader();
969 print
'<!DOCTYPE html>' .
970 '<html><head><title>' .
971 htmlspecialchars( $label ) .
972 '</title><meta name="color-scheme" content="light dark" /></head><body><h1>' .
973 htmlspecialchars( $label ) .
975 nl2br( htmlspecialchars( $desc ) ) .
976 "</p></body></html>\n";
977 header(
'Content-Length: ' . ob_get_length() );
1003 while ( $status = ob_get_status() ) {
1004 if ( isset( $status[
'flags'] ) ) {
1005 $flags = PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_REMOVABLE;
1006 $deletable = ( $status[
'flags'] & $flags ) === $flags;
1007 } elseif ( isset( $status[
'del'] ) ) {
1008 $deletable = $status[
'del'];
1011 $deletable = $status[
'type'] !== 0;
1013 if ( !$deletable ) {
1018 if ( $status[
'name'] ===
'MediaWikiIntegrationTestCase::wfResetOutputBuffersBarrier' ) {
1022 if ( !ob_end_clean() ) {
1027 if ( $resetGzipEncoding && $status[
'name'] ==
'ob_gzhandler' ) {
1030 header_remove(
'Content-Encoding' );
1047 $ret = ConvertibleTimestamp::convert( $outputtype, $ts );
1048 if ( $ret ===
false ) {
1049 if ( $outputtype instanceof TS ) {
1050 $outputtype = $outputtype->name;
1052 wfDebug(
"wfTimestamp() fed bogus time value: TYPE=$outputtype; VALUE=$ts" );
1066 if ( $ts ===
null ) {
1079 return ConvertibleTimestamp::now( TS::MW );
1100 return TempFSFile::getUsableTempDirectory();
1114 if ( FileBackend::isStoragePath( $dir ) ) {
1115 throw new LogicException( __FUNCTION__ .
" given storage path '$dir'." );
1117 if ( $caller !==
null ) {
1118 wfDebug(
"$caller: called wfMkdirParents($dir)" );
1120 if ( strval( $dir ) ===
'' ) {
1124 $dir = str_replace( [
'\\',
'/' ], DIRECTORY_SEPARATOR, $dir );
1134 $ok = is_dir( $dir ) || @mkdir( $dir, $mode,
true ) || is_dir( $dir );
1136 trigger_error( sprintf(
"failed to mkdir \"%s\" mode 0%o", $dir, $mode ), E_USER_WARNING );
1149 if ( is_dir( $dir ) ) {
1150 $objects = scandir( $dir );
1151 foreach ( $objects as $object ) {
1152 if ( $object !=
"." && $object !=
".." ) {
1153 if ( filetype( $dir .
'/' . $object ) ==
"dir" ) {
1156 unlink( $dir .
'/' . $object );
1173function wfPercent( $nr,
int $acc = 2,
bool $round =
true ) {
1175 $accForFormat = $acc >= 0 ? $acc : 0;
1176 $ret = sprintf(
"%.{$accForFormat}f", $nr );
1177 return $round ? round( (
float)$ret, $acc ) .
'%' :
"$ret%";
1220 $val = strtolower( $val );
1225 || preg_match(
"/^\s*[+-]?0*[1-9]/", $val );
1243 return Shell::escape( ...$args );
1271 $limits = [], $options = []
1274 if ( Shell::isDisabled() ) {
1277 return 'Unable to run external programs, proc_open() is disabled.';
1280 if ( is_array( $cmd ) ) {
1281 $cmd = Shell::escape( $cmd );
1284 $includeStderr = isset( $options[
'duplicateStderr'] ) && $options[
'duplicateStderr'];
1285 $profileMethod = $options[
'profileMethod'] ??
wfGetCaller();
1288 $result = Shell::command( [] )
1289 ->unsafeParams( (array)$cmd )
1290 ->environment( $environ )
1292 ->includeStderr( $includeStderr )
1293 ->profileMethod( $profileMethod )
1295 ->restrict( Shell::RESTRICT_NONE )
1302 $retval = $result->getExitCode();
1304 return $result->getStdout();
1326 return wfShellExec( $cmd, $retval, $environ, $limits,
1327 [
'duplicateStderr' =>
true,
'profileMethod' =>
wfGetCaller() ] );
1350 (
new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) )
1351 ->onWfShellWikiCmd( $script, $parameters, $options );
1352 $cmd = [ $options[
'php'] ??
$wgPhpCli ];
1353 if ( isset( $options[
'wrapper'] ) ) {
1354 $cmd[] = $options[
'wrapper'];
1358 return Shell::escape( array_merge( $cmd, $parameters ) );
1381 ?
string &$simplisticMergeAttempt,
1382 ?
string &$mergeLeftovers =
null
1386 # This check may also protect against code injection in
1387 # case of broken installations.
1391 if ( !$haveDiff3 ) {
1396 # Make temporary files
1398 $oldtextFile = fopen( $oldtextName = tempnam( $td,
'merge-old-' ),
'w' );
1399 $mytextFile = fopen( $mytextName = tempnam( $td,
'merge-mine-' ),
'w' );
1400 $yourtextFile = fopen( $yourtextName = tempnam( $td,
'merge-your-' ),
'w' );
1402 # NOTE: diff3 issues a warning to stderr if any of the files does not end with
1403 # a newline character. To avoid this, we normalize the trailing whitespace before
1404 # creating the diff.
1406 fwrite( $oldtextFile, rtrim( $old ) .
"\n" );
1407 fclose( $oldtextFile );
1408 fwrite( $mytextFile, rtrim( $mine ) .
"\n" );
1409 fclose( $mytextFile );
1410 fwrite( $yourtextFile, rtrim( $yours ) .
"\n" );
1411 fclose( $yourtextFile );
1413 # Check for a conflict
1414 $cmd = Shell::escape(
$wgDiff3,
'--text',
'--overlap-only', $mytextName,
1415 $oldtextName, $yourtextName );
1416 $handle = popen( $cmd,
'r' );
1418 $mergeLeftovers =
'';
1420 $data = fread( $handle, 8192 );
1421 if ( $data ===
false || $data ===
'' ) {
1424 $mergeLeftovers .= $data;
1428 $conflict = $mergeLeftovers !==
'';
1430 # Merge differences automatically where possible, preferring "my" text for conflicts.
1431 $cmd = Shell::escape(
$wgDiff3,
'--text',
'--ed',
'--merge', $mytextName,
1432 $oldtextName, $yourtextName );
1433 $handle = popen( $cmd,
'r' );
1434 $simplisticMergeAttempt =
'';
1436 $data = fread( $handle, 8192 );
1437 if ( $data ===
false || $data ===
'' ) {
1440 $simplisticMergeAttempt .= $data;
1443 unlink( $mytextName );
1444 unlink( $oldtextName );
1445 unlink( $yourtextName );
1447 if ( $simplisticMergeAttempt ===
'' && $old !==
'' && !$conflict ) {
1448 wfDebug(
"Unexpected null result from diff3. Command: $cmd" );
1467 if ( $suffix ==
'' ) {
1470 $encSuffix =
'(?:' . preg_quote( $suffix,
'#' ) .
')?';
1474 if ( preg_match(
"#([^/\\\\]*?){$encSuffix}[/\\\\]*$#",
$path,
$matches ) ) {
1492 $path = str_replace(
'/', DIRECTORY_SEPARATOR,
$path );
1493 $from = str_replace(
'/', DIRECTORY_SEPARATOR, $from );
1497 $from = rtrim( $from, DIRECTORY_SEPARATOR );
1499 $pieces = explode( DIRECTORY_SEPARATOR, dirname(
$path ) );
1500 $against = explode( DIRECTORY_SEPARATOR, $from );
1502 if ( $pieces[0] !== $against[0] ) {
1509 while ( count( $pieces ) && count( $against )
1510 && $pieces[0] == $against[0] ) {
1511 array_shift( $pieces );
1512 array_shift( $against );
1516 while ( count( $against ) ) {
1517 array_unshift( $pieces,
'..' );
1518 array_shift( $against );
1523 return implode( DIRECTORY_SEPARATOR, $pieces );
1537 if ( $script ===
'index' ) {
1539 } elseif ( $script ===
'load' ) {
1542 return "{$wgScriptPath}/{$script}.php";
1554 return $value ?
'true' :
'false';
1577 $name = preg_replace(
1578 "/[^" . Title::legalChars() .
"]" . $illegalFileChars .
"/",
1596 if ( $oldLimit != -1 ) {
1598 if ( $newLimit == -1 ) {
1599 wfDebug(
"Removing PHP's memory limit" );
1601 @ini_set(
'memory_limit', $newLimit );
1602 } elseif ( $newLimit > $oldLimit ) {
1603 wfDebug(
"Raising PHP's memory limit to $newLimit bytes" );
1605 @ini_set(
'memory_limit', $newLimit );
1619 $timeout = RequestTimeout::singleton();
1620 $timeLimit = $timeout->getWallTimeLimit();
1621 if ( $timeLimit !== INF ) {
1628 $timeLimit = (int)ini_get(
'max_execution_time' );
1634 ignore_user_abort(
true );
1647 $string = trim( $string ??
'' );
1648 if ( $string ===
'' ) {
1651 $last = substr( $string, -1 );
1652 $val = intval( $string );
1679 return in_array( $str, ExpiryDef::INFINITY_VALS );
1699 $multipliers = [ 1 ];
1707 if ( !$handler || !isset( $params[
'width'] ) ) {
1712 if ( isset( $params[
'page'] ) ) {
1713 $basicParams[
'page'] = $params[
'page'];
1719 foreach ( $multipliers as $multiplier ) {
1720 $thumbLimits = array_merge( $thumbLimits, array_map(
1721 static function ( $width ) use ( $multiplier ) {
1722 return round( $width * $multiplier );
1725 $imageLimits = array_merge( $imageLimits, array_map(
1726 static function ( $pair ) use ( $multiplier ) {
1728 round( $pair[0] * $multiplier ),
1729 round( $pair[1] * $multiplier ),
1736 if ( in_array( $params[
'width'], $thumbLimits ) ) {
1737 $normalParams = $basicParams + [
'width' => $params[
'width'] ];
1739 $handler->normaliseParams( $file, $normalParams );
1743 foreach ( $imageLimits as $pair ) {
1744 $normalParams = $basicParams + [
'width' => $pair[0],
'height' => $pair[1] ];
1747 $handler->normaliseParams( $file, $normalParams );
1749 if ( $normalParams[
'width'] == $params[
'width'] ) {
1760 foreach ( $params as $key => $value ) {
1761 if ( !isset( $normalParams[$key] ) || $normalParams[$key] != $value ) {
1784 return ArrayUtils::arrayPlus2d( $baseArray, $newValues );
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.
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.