29use Wikimedia\RequestTimeout\RequestTimeout;
30use Wikimedia\Timestamp\ConvertibleTimestamp;
31use Wikimedia\Timestamp\TimestampFormat as TS;
46 $path =
"$wgExtensionDirectory/$ext/extension.json";
48 ExtensionRegistry::getInstance()->queue(
$path );
66 $registry = ExtensionRegistry::getInstance();
67 foreach ( $exts as $ext ) {
68 $registry->queue(
"$wgExtensionDirectory/$ext/extension.json" );
83 $path =
"$wgStyleDirectory/$skin/skin.json";
85 ExtensionRegistry::getInstance()->queue(
$path );
97 $registry = ExtensionRegistry::getInstance();
98 foreach ( $skins as $skin ) {
99 $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 );
213 if ( $needle ===
null ) {
214 $needle = [
'%3B',
'%40',
'%24',
'%21',
'%2A',
'%28',
'%29',
'%2C',
'%2F',
'%7E' ];
215 if ( !isset( $_SERVER[
'SERVER_SOFTWARE'] ) ||
216 !str_contains( $_SERVER[
'SERVER_SOFTWARE'],
'Microsoft-IIS/7' )
222 $s = urlencode( $s );
225 [
';',
'@',
'$',
'!',
'*',
'(',
')',
',',
'/',
'~',
':' ],
243 if ( $array2 !==
null ) {
248 foreach ( $array1 as $key => $value ) {
249 if ( $value !==
null && $value !==
false ) {
253 if ( $prefix !==
'' ) {
254 $key = $prefix .
"[$key]";
256 if ( is_array( $value ) ) {
258 foreach ( $value as $k => $v ) {
259 $cgi .= $firstTime ?
'' :
'&';
260 if ( is_array( $v ) ) {
263 $cgi .= urlencode( $key .
"[$k]" ) .
'=' . urlencode( $v );
268 if ( is_object( $value ) ) {
269 $value = $value->__toString();
271 $cgi .= urlencode( $key ) .
'=' . urlencode( $value );
288 if ( isset( $query[0] ) && $query[0] ==
'?' ) {
289 $query = substr( $query, 1 );
291 $bits = explode(
'&', $query );
293 foreach ( $bits as $bit ) {
297 if ( !str_contains( $bit,
'=' ) ) {
302 [ $key, $value ] = explode(
'=', $bit );
304 $key = urldecode( $key );
305 $value = urldecode( $value );
306 if ( str_contains( $key,
'[' ) ) {
307 $keys = array_reverse( explode(
'[', $key ) );
308 $key = array_pop( $keys );
310 foreach ( $keys as $k ) {
311 $k = substr( $k, 0, -1 );
312 $temp = [ $k => $temp ];
314 if ( isset( $ret[$key] ) && is_array( $ret[$key] ) ) {
315 $ret[$key] = array_merge( $ret[$key], $temp );
335 if ( is_array( $query ) ) {
338 if ( $query !=
'' ) {
341 $hashPos = strpos(
$url,
'#' );
342 if ( $hashPos !==
false ) {
343 $fragment = substr(
$url, $hashPos );
348 if ( !str_contains(
$url,
'?' ) ) {
356 if ( $fragment !==
false ) {
373 if ( MediaWikiServices::hasInstance() ) {
374 $services = MediaWikiServices::getInstance();
375 if ( $services->hasService(
'UrlUtils' ) ) {
376 return $services->getUrlUtils();
414function wfDebug( $text, $dest =
'all', array $context = [] ) {
421 $text = trim( $text );
426 $context[
'private'] = ( $dest ===
false || $dest ===
'private' );
428 $logger = LoggerFactory::getInstance(
'wfDebug' );
429 $logger->debug( $text, $context );
438 if ( $cache !==
null ) {
443 if ( ( isset( $_GET[
'action'] ) && $_GET[
'action'] ==
'raw' )
479 $logGroup, $text, $dest =
'all', array $context = []
481 $text = trim( $text );
483 $logger = LoggerFactory::getInstance( $logGroup );
484 $context[
'private'] = ( $dest ===
false || $dest ===
'private' );
485 $logger->info( $text, $context );
497 $logger = LoggerFactory::getInstance(
'wfLogDBError' );
498 $logger->error( trim( $text ), $context );
517function wfDeprecated( $function, $version =
false, $component =
false, $callerOffset = 2 ) {
518 if ( !is_string( $version ) && $version !==
false ) {
519 throw new InvalidArgumentException(
520 "MediaWiki version must either be a string or false. " .
521 "Example valid version: '1.33'"
525 MWDebug::deprecated( $function, $version, $component, $callerOffset + 1 );
548function wfDeprecatedMsg( $msg, $version =
false, $component =
false, $callerOffset = 2 ) {
549 MWDebug::deprecatedMsg( $msg, $version, $component,
550 $callerOffset ===
false ?
false : $callerOffset + 1 );
563function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) {
564 MWDebug::warning( $msg, $callerOffset + 1, $level,
'auto' );
576function wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) {
577 MWDebug::warning( $msg, $callerOffset + 1, $level,
'production' );
603 if ( is_array( $key ) ) {
607 $message = Message::newFromSpecifier( $key );
612 $message->params( ...$params );
631 return Message::newFallbackSequence( ...$keys );
643 # Fix windows line-endings
644 # Some messages are split with explode("\n", $msg)
645 $message = str_replace(
"\r",
'', $message );
648 if ( is_array( $args ) && $args ) {
649 if ( is_array( $args[0] ) ) {
650 $args = array_values( $args[0] );
652 $replacementKeys = [];
653 foreach ( $args as $n => $param ) {
654 $replacementKeys[
'$' . ( $n + 1 )] = $param;
656 $message = strtr( $message, $replacementKeys );
677 return php_uname(
'n' ) ?:
'unknown';
691 static $disabled =
null;
693 if ( $disabled ===
null ) {
694 $disabled = !function_exists(
'debug_backtrace' );
696 wfDebug(
"debug_backtrace() is disabled" );
704 return array_slice( debug_backtrace( DEBUG_BACKTRACE_PROVIDE_OBJECT, $limit + 1 ), 1 );
706 return array_slice( debug_backtrace(), 1 );
721 $frameFormat =
"%s line %s calls %s()\n";
724 $frameFormat =
"<li>%s line %s calls %s()</li>\n";
725 $traceFormat =
"<ul>\n%s</ul>\n";
728 $frames = array_map(
static function ( $frame ) use ( $frameFormat ) {
729 $file = !empty( $frame[
'file'] ) ? basename( $frame[
'file'] ) :
'-';
730 $line = $frame[
'line'] ??
'-';
731 $call = $frame[
'function'];
732 if ( !empty( $frame[
'class'] ) ) {
733 $call = $frame[
'class'] . $frame[
'type'] . $call;
735 return sprintf( $frameFormat, $file, $line, $call );
738 return sprintf( $traceFormat, implode(
'', $frames ) );
753 if ( isset( $backtrace[$level] ) ) {
768 $limit = $limit ? $limit + 1 : 0;
787 if ( !isset( $frame[
'function'] ) ) {
788 return 'NO_FUNCTION_GIVEN';
790 return isset( $frame[
'class'] ) && isset( $frame[
'type'] ) ?
791 $frame[
'class'] . $frame[
'type'] . $frame[
'function'] :
805 static $result =
null;
806 if ( $result ===
null || $force ) {
808 if ( isset( $_SERVER[
'HTTP_ACCEPT_ENCODING'] ) ) {
809 # @todo FIXME: We may want to disallow some broken browsers
812 '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
813 $_SERVER[
'HTTP_ACCEPT_ENCODING'],
817 if ( isset( $m[2] ) && ( $m[1] ==
'q' ) && ( $m[2] == 0 ) ) {
820 wfDebug(
"wfClientAcceptsGzip: client accepts gzip." );
840 static $repl =
null, $repl2 =
null, $repl3 =
null, $repl4 =
null;
841 if ( $repl ===
null || defined(
'MW_PHPUNIT_TEST' ) ) {
845 '"' =>
'"',
'&' =>
'&',
"'" =>
''',
'<' =>
'<',
846 '=' =>
'=',
'>' =>
'>',
'[' =>
'[',
']' =>
']',
847 '{' =>
'{',
'|' =>
'|',
'}' =>
'}',
850 "\n!" =>
"\n!",
"\r!" =>
"\r!",
851 "\n#" =>
"\n#",
"\r#" =>
"\r#",
852 "\n*" =>
"\n*",
"\r*" =>
"\r*",
853 "\n:" =>
"\n:",
"\r:" =>
"\r:",
854 "\n " =>
"\n ",
"\r " =>
"\r ",
855 "\n\n" =>
"\n ",
"\r\n" =>
" \n",
856 "\n\r" =>
"\n ",
"\r\r" =>
"\r ",
857 "\n\t" =>
"\n	",
"\r\t" =>
"\r	",
858 "\n----" =>
"\n----",
"\r----" =>
"\r----",
859 '__' =>
'__',
'://' =>
'://',
867 foreach ( $magicLinks as $magic ) {
868 $repl[
"$magic "] =
"$magic ";
869 $repl[
"$magic\t"] =
"$magic	";
870 $repl[
"$magic\r"] =
"$magic ";
871 $repl[
"$magic\n"] =
"$magic ";
872 $repl[
"$magic\f"] =
"$magic";
882 '+' =>
'+',
'-' =>
'-',
'_' =>
'_',
'~' =>
'~',
891 '_' =>
'_',
'~' =>
'~',
892 "\n" =>
" ",
"\r" =>
" ",
900 if ( substr( $prot, -1 ) ===
':' ) {
901 $repl2[] = preg_quote( substr( $prot, 0, -1 ),
'/' );
904 $repl2 = $repl2 ?
'/\b(' . implode(
'|', $repl2 ) .
'):/i' :
'/^(?!)/';
907 '@phan-var string $repl2';
908 '@phan-var string $repl3';
909 '@phan-var string $repl4';
911 $text = substr( strtr(
"\n$input", $repl ), 1 );
912 if ( $text ===
'' ) {
915 $first = strtr( $text[0], $repl3 );
916 if ( strlen( $text ) > 1 ) {
917 $text = $first . substr( $text, 1, -1 ) .
918 strtr( substr( $text, -1 ), $repl4 );
921 $text = strtr( $first, $repl4 );
923 $text = preg_replace( $repl2,
'$1:', $text );
939 if (
$source !==
null || $force ) {
955 $temp = (bool)( $dest & $bit );
956 if ( $state !==
null ) {
974 $s = str_replace(
"\n",
"<br />\n", var_export( $var,
true ) .
"\n" );
975 if ( headers_sent() ||
$wgOut ===
null || !is_object(
$wgOut ) ) {
991 HttpStatus::header( $code );
994 $wgOut->sendCacheControl();
997 \MediaWiki\Request\HeaderCallback::warnIfHeadersSent();
998 header(
'Content-type: text/html; charset=utf-8' );
999 ContentSecurityPolicy::sendRestrictiveHeader();
1001 print
'<!DOCTYPE html>' .
1002 '<html><head><title>' .
1003 htmlspecialchars( $label ) .
1004 '</title><meta name="color-scheme" content="light dark" /></head><body><h1>' .
1005 htmlspecialchars( $label ) .
1007 nl2br( htmlspecialchars( $desc ) ) .
1008 "</p></body></html>\n";
1009 header(
'Content-Length: ' . ob_get_length() );
1035 while ( $status = ob_get_status() ) {
1036 if ( isset( $status[
'flags'] ) ) {
1037 $flags = PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_REMOVABLE;
1038 $deleteable = ( $status[
'flags'] & $flags ) === $flags;
1039 } elseif ( isset( $status[
'del'] ) ) {
1040 $deleteable = $status[
'del'];
1043 $deleteable = $status[
'type'] !== 0;
1045 if ( !$deleteable ) {
1050 if ( $status[
'name'] ===
'MediaWikiIntegrationTestCase::wfResetOutputBuffersBarrier' ) {
1054 if ( !ob_end_clean() ) {
1059 if ( $resetGzipEncoding && $status[
'name'] ==
'ob_gzhandler' ) {
1062 header_remove(
'Content-Encoding' );
1079 $ret = ConvertibleTimestamp::convert( $outputtype, $ts );
1080 if ( $ret ===
false ) {
1081 if ( $outputtype instanceof TS ) {
1082 $outputtype = $outputtype->name;
1084 wfDebug(
"wfTimestamp() fed bogus time value: TYPE=$outputtype; VALUE=$ts" );
1098 if ( $ts ===
null ) {
1111 return ConvertibleTimestamp::now( TS::MW );
1132 return TempFSFile::getUsableTempDirectory();
1146 if ( FileBackend::isStoragePath( $dir ) ) {
1147 throw new LogicException( __FUNCTION__ .
" given storage path '$dir'." );
1149 if ( $caller !==
null ) {
1150 wfDebug(
"$caller: called wfMkdirParents($dir)" );
1152 if ( strval( $dir ) ===
'' ) {
1156 $dir = str_replace( [
'\\',
'/' ], DIRECTORY_SEPARATOR, $dir );
1166 $ok = is_dir( $dir ) || @mkdir( $dir, $mode,
true ) || is_dir( $dir );
1168 trigger_error( sprintf(
"failed to mkdir \"%s\" mode 0%o", $dir, $mode ), E_USER_WARNING );
1181 if ( is_dir( $dir ) ) {
1182 $objects = scandir( $dir );
1183 foreach ( $objects as $object ) {
1184 if ( $object !=
"." && $object !=
".." ) {
1185 if ( filetype( $dir .
'/' . $object ) ==
"dir" ) {
1188 unlink( $dir .
'/' . $object );
1202function wfPercent( $nr,
int $acc = 2,
bool $round =
true ) {
1203 $accForFormat = $acc >= 0 ? $acc : 0;
1204 $ret = sprintf(
"%.{$accForFormat}f", $nr );
1205 return $round ? round( (
float)$ret, $acc ) .
'%' :
"$ret%";
1248 $val = strtolower( $val );
1253 || preg_match(
"/^\s*[+-]?0*[1-9]/", $val );
1270 return Shell::escape( ...$args );
1298 $limits = [], $options = []
1300 if ( Shell::isDisabled() ) {
1303 return 'Unable to run external programs, proc_open() is disabled.';
1306 if ( is_array( $cmd ) ) {
1307 $cmd = Shell::escape( $cmd );
1310 $includeStderr = isset( $options[
'duplicateStderr'] ) && $options[
'duplicateStderr'];
1311 $profileMethod = $options[
'profileMethod'] ??
wfGetCaller();
1314 $result = Shell::command( [] )
1315 ->unsafeParams( (array)$cmd )
1316 ->environment( $environ )
1318 ->includeStderr( $includeStderr )
1319 ->profileMethod( $profileMethod )
1321 ->restrict( Shell::RESTRICT_NONE )
1328 $retval = $result->getExitCode();
1330 return $result->getStdout();
1351 return wfShellExec( $cmd, $retval, $environ, $limits,
1352 [
'duplicateStderr' =>
true,
'profileMethod' =>
wfGetCaller() ] );
1374 (
new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) )
1375 ->onWfShellWikiCmd( $script, $parameters, $options );
1376 $cmd = [ $options[
'php'] ??
$wgPhpCli ];
1377 if ( isset( $options[
'wrapper'] ) ) {
1378 $cmd[] = $options[
'wrapper'];
1382 return Shell::escape( array_merge( $cmd, $parameters ) );
1405 ?
string &$simplisticMergeAttempt,
1406 ?
string &$mergeLeftovers =
null
1410 # This check may also protect against code injection in
1411 # case of broken installations.
1415 if ( !$haveDiff3 ) {
1420 # Make temporary files
1422 $oldtextFile = fopen( $oldtextName = tempnam( $td,
'merge-old-' ),
'w' );
1423 $mytextFile = fopen( $mytextName = tempnam( $td,
'merge-mine-' ),
'w' );
1424 $yourtextFile = fopen( $yourtextName = tempnam( $td,
'merge-your-' ),
'w' );
1426 # NOTE: diff3 issues a warning to stderr if any of the files does not end with
1427 # a newline character. To avoid this, we normalize the trailing whitespace before
1428 # creating the diff.
1430 fwrite( $oldtextFile, rtrim( $old ) .
"\n" );
1431 fclose( $oldtextFile );
1432 fwrite( $mytextFile, rtrim( $mine ) .
"\n" );
1433 fclose( $mytextFile );
1434 fwrite( $yourtextFile, rtrim( $yours ) .
"\n" );
1435 fclose( $yourtextFile );
1437 # Check for a conflict
1438 $cmd = Shell::escape(
$wgDiff3,
'--text',
'--overlap-only', $mytextName,
1439 $oldtextName, $yourtextName );
1440 $handle = popen( $cmd,
'r' );
1442 $mergeLeftovers =
'';
1444 $data = fread( $handle, 8192 );
1445 if ( $data ===
false || $data ===
'' ) {
1448 $mergeLeftovers .= $data;
1452 $conflict = $mergeLeftovers !==
'';
1454 # Merge differences automatically where possible, preferring "my" text for conflicts.
1455 $cmd = Shell::escape(
$wgDiff3,
'--text',
'--ed',
'--merge', $mytextName,
1456 $oldtextName, $yourtextName );
1457 $handle = popen( $cmd,
'r' );
1458 $simplisticMergeAttempt =
'';
1460 $data = fread( $handle, 8192 );
1461 if ( $data ===
false || $data ===
'' ) {
1464 $simplisticMergeAttempt .= $data;
1467 unlink( $mytextName );
1468 unlink( $oldtextName );
1469 unlink( $yourtextName );
1471 if ( $simplisticMergeAttempt ===
'' && $old !==
'' && !$conflict ) {
1472 wfDebug(
"Unexpected null result from diff3. Command: $cmd" );
1491 if ( $suffix ==
'' ) {
1494 $encSuffix =
'(?:' . preg_quote( $suffix,
'#' ) .
')?';
1498 if ( preg_match(
"#([^/\\\\]*?){$encSuffix}[/\\\\]*$#",
$path,
$matches ) ) {
1516 $path = str_replace(
'/', DIRECTORY_SEPARATOR,
$path );
1517 $from = str_replace(
'/', DIRECTORY_SEPARATOR, $from );
1521 $from = rtrim( $from, DIRECTORY_SEPARATOR );
1523 $pieces = explode( DIRECTORY_SEPARATOR, dirname(
$path ) );
1524 $against = explode( DIRECTORY_SEPARATOR, $from );
1526 if ( $pieces[0] !== $against[0] ) {
1533 while ( count( $pieces ) && count( $against )
1534 && $pieces[0] == $against[0] ) {
1535 array_shift( $pieces );
1536 array_shift( $against );
1540 while ( count( $against ) ) {
1541 array_unshift( $pieces,
'..' );
1542 array_shift( $against );
1547 return implode( DIRECTORY_SEPARATOR, $pieces );
1561 if ( $script ===
'index' ) {
1563 } elseif ( $script ===
'load' ) {
1566 return "{$wgScriptPath}/{$script}.php";
1578 return $value ?
'true' :
'false';
1601 $name = preg_replace(
1602 "/[^" . Title::legalChars() .
"]" . $illegalFileChars .
"/",
1620 if ( $oldLimit != -1 ) {
1622 if ( $newLimit == -1 ) {
1623 wfDebug(
"Removing PHP's memory limit" );
1625 @ini_set(
'memory_limit', $newLimit );
1626 } elseif ( $newLimit > $oldLimit ) {
1627 wfDebug(
"Raising PHP's memory limit to $newLimit bytes" );
1629 @ini_set(
'memory_limit', $newLimit );
1643 $timeout = RequestTimeout::singleton();
1644 $timeLimit = $timeout->getWallTimeLimit();
1645 if ( $timeLimit !== INF ) {
1652 $timeLimit = (int)ini_get(
'max_execution_time' );
1658 ignore_user_abort(
true );
1671 $string = trim( $string ??
'' );
1672 if ( $string ===
'' ) {
1675 $last = substr( $string, -1 );
1676 $val = intval( $string );
1703 return in_array( $str, ExpiryDef::INFINITY_VALS );
1723 $multipliers = [ 1 ];
1731 if ( !$handler || !isset( $params[
'width'] ) ) {
1736 if ( isset( $params[
'page'] ) ) {
1737 $basicParams[
'page'] = $params[
'page'];
1743 foreach ( $multipliers as $multiplier ) {
1744 $thumbLimits = array_merge( $thumbLimits, array_map(
1745 static function ( $width ) use ( $multiplier ) {
1746 return round( $width * $multiplier );
1749 $imageLimits = array_merge( $imageLimits, array_map(
1750 static function ( $pair ) use ( $multiplier ) {
1752 round( $pair[0] * $multiplier ),
1753 round( $pair[1] * $multiplier ),
1760 if ( in_array( $params[
'width'], $thumbLimits ) ) {
1761 $normalParams = $basicParams + [
'width' => $params[
'width'] ];
1763 $handler->normaliseParams( $file, $normalParams );
1767 foreach ( $imageLimits as $pair ) {
1768 $normalParams = $basicParams + [
'width' => $pair[0],
'height' => $pair[1] ];
1771 $handler->normaliseParams( $file, $normalParams );
1773 if ( $normalParams[
'width'] == $params[
'width'] ) {
1784 foreach ( $params as $key => $value ) {
1785 if ( !isset( $normalParams[$key] ) || $normalParams[$key] != $value ) {
1807 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' $wgOut
Handle sending Content-Security-Policy headers.
$wgScript
Config variable stub for the Script setting, for use by phpdoc and IDEs.
$wgInternalServer
Config variable stub for the InternalServer 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.
$wgCanonicalServer
Config variable stub for the CanonicalServer setting, for use by phpdoc and IDEs.
$wgServer
Config variable stub for the Server setting, for use by phpdoc and IDEs.
$wgHttpsPort
Config variable stub for the HttpsPort setting, for use by phpdoc and IDEs.