35use Wikimedia\AtEase\AtEase;
39use Wikimedia\RequestTimeout\RequestTimeout;
54 $path =
"$wgExtensionDirectory/$ext/extension.json";
56 ExtensionRegistry::getInstance()->queue(
$path );
74 $registry = ExtensionRegistry::getInstance();
75 foreach ( $exts as $ext ) {
76 $registry->queue(
"$wgExtensionDirectory/$ext/extension.json" );
91 $path =
"$wgStyleDirectory/$skin/skin.json";
93 ExtensionRegistry::getInstance()->queue(
$path );
105 $registry = ExtensionRegistry::getInstance();
106 foreach ( $skins as $skin ) {
107 $registry->queue(
"$wgStyleDirectory/$skin/skin.json" );
122 $comparator =
static function ( $a, $b ):
int {
123 if ( is_string( $a ) && is_string( $b ) ) {
124 return strcmp( $a, $b );
126 if ( !is_array( $a ) && !is_array( $b ) ) {
127 throw new InvalidArgumentException(
128 'This function assumes that array elements are all strings or all arrays'
131 if ( count( $a ) !== count( $b ) ) {
132 return count( $a ) <=> count( $b );
136 while ( key( $a ) !==
null && key( $b ) !==
null ) {
137 $valueA = current( $a );
138 $valueB = current( $b );
139 $cmp = strcmp( $valueA, $valueB );
149 return array_udiff( $arr1, $arr2, $comparator );
175 foreach ( $args as $errors ) {
176 foreach ( $errors as
$params ) {
181 # @todo FIXME: Sometimes get nested arrays for $params,
182 # which leads to E_NOTICEs
183 $spec = implode(
"\t",
$params );
184 $out[$spec] = $originalParams;
187 return array_values( $out );
201 $keys = array_keys( $array );
202 $offsetByKey = array_flip( $keys );
204 if ( !\array_key_exists( $after, $offsetByKey ) ) {
207 $offset = $offsetByKey[$after];
210 $before = array_slice( $array, 0, $offset + 1,
true );
211 $after = array_slice( $array, $offset + 1, count( $array ) - $offset,
true );
213 $output = $before + $insert + $after;
228 if ( is_object( $objOrArray ) ) {
229 $objOrArray = get_object_vars( $objOrArray );
231 foreach ( $objOrArray as $key => $value ) {
232 if ( $recursive && ( is_object( $value ) || is_array( $value ) ) ) {
236 $array[$key] = $value;
255 $max = mt_getrandmax() + 1;
256 $rand = number_format( ( mt_rand() * $max + mt_rand() ) / $max / $max, 12,
'.',
'' );
272 for ( $n = 0; $n < $length; $n += 7 ) {
273 $str .= sprintf(
'%07x', mt_rand() & 0xfffffff );
275 return substr( $str, 0, $length );
314 if ( $needle ===
null ) {
315 $needle = [
'%3B',
'%40',
'%24',
'%21',
'%2A',
'%28',
'%29',
'%2C',
'%2F',
'%7E' ];
316 if ( !isset( $_SERVER[
'SERVER_SOFTWARE'] ) ||
317 !str_contains( $_SERVER[
'SERVER_SOFTWARE'],
'Microsoft-IIS/7' )
323 $s = urlencode( $s );
326 [
';',
'@',
'$',
'!',
'*',
'(',
')',
',',
'/',
'~',
':' ],
344 if ( $array2 !==
null ) {
349 foreach ( $array1 as $key => $value ) {
350 if ( $value !==
null && $value !==
false ) {
354 if ( $prefix !==
'' ) {
355 $key = $prefix .
"[$key]";
357 if ( is_array( $value ) ) {
359 foreach ( $value as $k => $v ) {
360 $cgi .= $firstTime ?
'' :
'&';
361 if ( is_array( $v ) ) {
364 $cgi .= urlencode( $key .
"[$k]" ) .
'=' . urlencode( $v );
369 if ( is_object( $value ) ) {
370 $value = $value->__toString();
372 $cgi .= urlencode( $key ) .
'=' . urlencode( $value );
389 if ( isset( $query[0] ) && $query[0] ==
'?' ) {
390 $query = substr( $query, 1 );
392 $bits = explode(
'&', $query );
394 foreach ( $bits as $bit ) {
398 if ( strpos( $bit,
'=' ) ===
false ) {
403 [ $key, $value ] = explode(
'=', $bit );
405 $key = urldecode( $key );
406 $value = urldecode( $value );
407 if ( strpos( $key,
'[' ) !==
false ) {
408 $keys = array_reverse( explode(
'[', $key ) );
409 $key = array_pop( $keys );
411 foreach ( $keys as $k ) {
412 $k = substr( $k, 0, -1 );
413 $temp = [ $k => $temp ];
415 if ( isset( $ret[$key] ) && is_array( $ret[$key] ) ) {
416 $ret[$key] = array_merge( $ret[$key], $temp );
436 if ( is_array( $query ) ) {
439 if ( $query !=
'' ) {
442 $hashPos = strpos(
$url,
'#' );
443 if ( $hashPos !==
false ) {
444 $fragment = substr(
$url, $hashPos );
449 if ( strpos(
$url,
'?' ) ===
false ) {
457 if ( $fragment !==
false ) {
473 if ( MediaWikiServices::hasInstance() ) {
474 $services = MediaWikiServices::getInstance();
475 if ( $services->hasService(
'UrlUtils' ) ) {
476 return $services->getUrlUtils();
553 return UrlUtils::assemble( (array)$urlParts );
567 return $includeProtocolRelative ?
wfGetUrlUtils()->validProtocols() :
659function wfDebug( $text, $dest =
'all', array $context = [] ) {
666 $text = trim( $text );
671 $context[
'private'] = ( $dest ===
false || $dest ===
'private' );
673 $logger = LoggerFactory::getInstance(
'wfDebug' );
674 $logger->debug( $text, $context );
683 if ( $cache !==
null ) {
688 if ( ( isset( $_GET[
'action'] ) && $_GET[
'action'] ==
'raw' )
724 $logGroup, $text, $dest =
'all', array $context = []
726 $text = trim( $text );
728 $logger = LoggerFactory::getInstance( $logGroup );
729 $context[
'private'] = ( $dest ===
false || $dest ===
'private' );
730 $logger->info( $text, $context );
742 $logger = LoggerFactory::getInstance(
'wfLogDBError' );
743 $logger->error( trim( $text ), $context );
762function wfDeprecated( $function, $version =
false, $component =
false, $callerOffset = 2 ) {
763 if ( !is_string( $version ) && $version !==
false ) {
764 throw new InvalidArgumentException(
765 "MediaWiki version must either be a string or false. " .
766 "Example valid version: '1.33'"
770 MWDebug::deprecated( $function, $version, $component, $callerOffset + 1 );
793function wfDeprecatedMsg( $msg, $version =
false, $component =
false, $callerOffset = 2 ) {
794 MWDebug::deprecatedMsg( $msg, $version, $component,
795 $callerOffset ===
false ?
false : $callerOffset + 1 );
808function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) {
809 MWDebug::warning( $msg, $callerOffset + 1, $level,
'auto' );
821function wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) {
822 MWDebug::warning( $msg, $callerOffset + 1, $level,
'production' );
847 if ( is_array( $key ) ) {
851 $message = Message::newFromSpecifier( $key );
856 $message->params( ...
$params );
875 return Message::newFallbackSequence( ...$keys );
887 # Fix windows line-endings
888 # Some messages are split with explode("\n", $msg)
889 $message = str_replace(
"\r",
'', $message );
892 if ( is_array( $args ) && $args ) {
893 if ( is_array( $args[0] ) ) {
894 $args = array_values( $args[0] );
896 $replacementKeys = [];
897 foreach ( $args as $n => $param ) {
898 $replacementKeys[
'$' . ( $n + 1 )] = $param;
900 $message = strtr( $message, $replacementKeys );
921 return php_uname(
'n' ) ?:
'unknown';
935 static $disabled =
null;
937 if ( $disabled ===
null ) {
938 $disabled = !function_exists(
'debug_backtrace' );
940 wfDebug(
"debug_backtrace() is disabled" );
948 return array_slice( debug_backtrace( DEBUG_BACKTRACE_PROVIDE_OBJECT, $limit + 1 ), 1 );
950 return array_slice( debug_backtrace(), 1 );
965 $frameFormat =
"%s line %s calls %s()\n";
968 $frameFormat =
"<li>%s line %s calls %s()</li>\n";
969 $traceFormat =
"<ul>\n%s</ul>\n";
972 $frames = array_map(
static function ( $frame ) use ( $frameFormat ) {
973 $file = !empty( $frame[
'file'] ) ? basename( $frame[
'file'] ) :
'-';
974 $line = $frame[
'line'] ??
'-';
975 $call = $frame[
'function'];
976 if ( !empty( $frame[
'class'] ) ) {
977 $call = $frame[
'class'] . $frame[
'type'] . $call;
979 return sprintf( $frameFormat, $file, $line, $call );
982 return sprintf( $traceFormat, implode(
'', $frames ) );
997 if ( isset( $backtrace[$level] ) ) {
1013 if ( !$limit || $limit > count( $trace ) - 1 ) {
1014 $limit = count( $trace ) - 1;
1016 $trace = array_slice( $trace, -$limit - 1, $limit );
1017 return implode(
'/', array_map(
'wfFormatStackFrame', $trace ) );
1033 if ( !isset( $frame[
'function'] ) ) {
1034 return 'NO_FUNCTION_GIVEN';
1036 return isset( $frame[
'class'] ) && isset( $frame[
'type'] ) ?
1037 $frame[
'class'] . $frame[
'type'] . $frame[
'function'] :
1051 static $result =
null;
1052 if ( $result ===
null || $force ) {
1054 if ( isset( $_SERVER[
'HTTP_ACCEPT_ENCODING'] ) ) {
1055 # @todo FIXME: We may want to disallow some broken browsers
1058 '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
1059 $_SERVER[
'HTTP_ACCEPT_ENCODING'],
1063 if ( isset( $m[2] ) && ( $m[1] ==
'q' ) && ( $m[2] == 0 ) ) {
1066 wfDebug(
"wfClientAcceptsGzip: client accepts gzip." );
1086 static $repl =
null, $repl2 =
null, $repl3 =
null, $repl4 =
null;
1087 if ( $repl ===
null || defined(
'MW_PARSER_TEST' ) || defined(
'MW_PHPUNIT_TEST' ) ) {
1091 '"' =>
'"',
'&' =>
'&',
"'" =>
''',
'<' =>
'<',
1092 '=' =>
'=',
'>' =>
'>',
'[' =>
'[',
']' =>
']',
1093 '{' =>
'{',
'|' =>
'|',
'}' =>
'}',
1096 "\n!" =>
"\n!",
"\r!" =>
"\r!",
1097 "\n#" =>
"\n#",
"\r#" =>
"\r#",
1098 "\n*" =>
"\n*",
"\r*" =>
"\r*",
1099 "\n:" =>
"\n:",
"\r:" =>
"\r:",
1100 "\n " =>
"\n ",
"\r " =>
"\r ",
1101 "\n\n" =>
"\n ",
"\r\n" =>
" \n",
1102 "\n\r" =>
"\n ",
"\r\r" =>
"\r ",
1103 "\n\t" =>
"\n	",
"\r\t" =>
"\r	",
1104 "\n----" =>
"\n----",
"\r----" =>
"\r----",
1105 '__' =>
'__',
'://' =>
'://',
1106 '~~~' =>
'~~~',
1111 foreach ( $magicLinks as $magic ) {
1112 $repl[
"$magic "] =
"$magic ";
1113 $repl[
"$magic\t"] =
"$magic	";
1114 $repl[
"$magic\r"] =
"$magic ";
1115 $repl[
"$magic\n"] =
"$magic ";
1116 $repl[
"$magic\f"] =
"$magic";
1124 '+' =>
'+',
'-' =>
'-',
'_' =>
'_',
'~' =>
'~',
1132 '_' =>
'_',
'~' =>
'~',
1133 "\n" =>
" ",
"\r" =>
" ",
1141 if ( substr( $prot, -1 ) ===
':' ) {
1142 $repl2[] = preg_quote( substr( $prot, 0, -1 ),
'/' );
1145 $repl2 = $repl2 ?
'/\b(' . implode(
'|', $repl2 ) .
'):/i' :
'/^(?!)/';
1148 '@phan-var string $repl2';
1149 '@phan-var string $repl3';
1150 '@phan-var string $repl4';
1152 $text = substr( strtr(
"\n$input", $repl ), 1 );
1153 if ( $text ===
'' ) {
1156 $first = strtr( $text[0], $repl3 );
1157 if ( strlen( $text ) > 1 ) {
1158 $text = $first . substr( $text, 1, -1 ) .
1159 strtr( substr( $text, -1 ), $repl4 );
1162 $text = strtr( $first, $repl4 );
1164 $text = preg_replace( $repl2,
'$1:', $text );
1180 if (
$source !==
null || $force ) {
1196 $temp = (bool)( $dest & $bit );
1197 if ( $state !==
null ) {
1215 $s = str_replace(
"\n",
"<br />\n", var_export( $var,
true ) .
"\n" );
1216 if ( headers_sent() || !isset(
$wgOut ) || !is_object(
$wgOut ) ) {
1232 HttpStatus::header( $code );
1235 $wgOut->sendCacheControl();
1238 \MediaWiki\Request\HeaderCallback::warnIfHeadersSent();
1239 header(
'Content-type: text/html; charset=utf-8' );
1241 print
'<!DOCTYPE html>' .
1242 '<html><head><title>' .
1243 htmlspecialchars( $label ) .
1244 '</title></head><body><h1>' .
1245 htmlspecialchars( $label ) .
1247 nl2br( htmlspecialchars( $desc ) ) .
1248 "</p></body></html>\n";
1249 header(
'Content-Length: ' . ob_get_length() );
1275 while ( $status = ob_get_status() ) {
1276 if ( isset( $status[
'flags'] ) ) {
1277 $flags = PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_REMOVABLE;
1278 $deleteable = ( $status[
'flags'] & $flags ) === $flags;
1279 } elseif ( isset( $status[
'del'] ) ) {
1280 $deleteable = $status[
'del'];
1283 $deleteable = $status[
'type'] !== 0;
1285 if ( !$deleteable ) {
1290 if ( $status[
'name'] ===
'MediaWikiIntegrationTestCase::wfResetOutputBuffersBarrier' ) {
1294 if ( !ob_end_clean() ) {
1299 if ( $resetGzipEncoding && $status[
'name'] ==
'ob_gzhandler' ) {
1302 header_remove(
'Content-Encoding' );
1319 $ret = MWTimestamp::convert( $outputtype, $ts );
1320 if ( $ret ===
false ) {
1321 wfDebug(
"wfTimestamp() fed bogus time value: TYPE=$outputtype; VALUE=$ts" );
1335 if ( $ts ===
null ) {
1348 return MWTimestamp::now( TS_MW );
1369 return TempFSFile::getUsableTempDirectory();
1383 if ( FileBackend::isStoragePath( $dir ) ) {
1384 throw new LogicException( __FUNCTION__ .
" given storage path '$dir'." );
1386 if ( $caller !==
null ) {
1387 wfDebug(
"$caller: called wfMkdirParents($dir)" );
1389 if ( strval( $dir ) ===
'' ) {
1393 $dir = str_replace( [
'\\',
'/' ], DIRECTORY_SEPARATOR, $dir );
1403 $ok = is_dir( $dir ) || @mkdir( $dir, $mode,
true ) || is_dir( $dir );
1405 trigger_error( sprintf(
"failed to mkdir \"%s\" mode 0%o", $dir, $mode ), E_USER_WARNING );
1418 if ( is_dir( $dir ) ) {
1419 $objects = scandir( $dir );
1420 foreach ( $objects as $object ) {
1421 if ( $object !=
"." && $object !=
".." ) {
1422 if ( filetype( $dir .
'/' . $object ) ==
"dir" ) {
1425 unlink( $dir .
'/' . $object );
1439function wfPercent( $nr,
int $acc = 2,
bool $round =
true ) {
1440 $accForFormat = $acc >= 0 ? $acc : 0;
1441 $ret = sprintf(
"%.{$accForFormat}f", $nr );
1442 return $round ? round( (
float)$ret, $acc ) .
'%' :
"$ret%";
1485 $val = strtolower( $val );
1490 || preg_match(
"/^\s*[+-]?0*[1-9]/", $val );
1507 return Shell::escape( ...$args );
1535 $limits = [], $options = []
1537 if ( Shell::isDisabled() ) {
1540 return 'Unable to run external programs, proc_open() is disabled.';
1543 if ( is_array( $cmd ) ) {
1544 $cmd = Shell::escape( $cmd );
1547 $includeStderr = isset( $options[
'duplicateStderr'] ) && $options[
'duplicateStderr'];
1548 $profileMethod = $options[
'profileMethod'] ??
wfGetCaller();
1551 $result = Shell::command( [] )
1552 ->unsafeParams( (array)$cmd )
1553 ->environment( $environ )
1555 ->includeStderr( $includeStderr )
1556 ->profileMethod( $profileMethod )
1558 ->restrict( Shell::RESTRICT_NONE )
1565 $retval = $result->getExitCode();
1567 return $result->getStdout();
1588 return wfShellExec( $cmd, $retval, $environ, $limits,
1589 [
'duplicateStderr' =>
true,
'profileMethod' =>
wfGetCaller() ] );
1611 (
new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) )
1612 ->onWfShellWikiCmd( $script, $parameters, $options );
1613 $cmd = [ $options[
'php'] ??
$wgPhpCli ];
1614 if ( isset( $options[
'wrapper'] ) ) {
1615 $cmd[] = $options[
'wrapper'];
1619 return Shell::escape( array_merge( $cmd, $parameters ) );
1642 ?
string &$simplisticMergeAttempt,
1643 string &$mergeLeftovers =
null
1647 # This check may also protect against code injection in
1648 # case of broken installations.
1649 AtEase::suppressWarnings();
1651 AtEase::restoreWarnings();
1653 if ( !$haveDiff3 ) {
1658 # Make temporary files
1660 $oldtextFile = fopen( $oldtextName = tempnam( $td,
'merge-old-' ),
'w' );
1661 $mytextFile = fopen( $mytextName = tempnam( $td,
'merge-mine-' ),
'w' );
1662 $yourtextFile = fopen( $yourtextName = tempnam( $td,
'merge-your-' ),
'w' );
1664 # NOTE: diff3 issues a warning to stderr if any of the files does not end with
1665 # a newline character. To avoid this, we normalize the trailing whitespace before
1666 # creating the diff.
1668 fwrite( $oldtextFile, rtrim( $old ) .
"\n" );
1669 fclose( $oldtextFile );
1670 fwrite( $mytextFile, rtrim( $mine ) .
"\n" );
1671 fclose( $mytextFile );
1672 fwrite( $yourtextFile, rtrim( $yours ) .
"\n" );
1673 fclose( $yourtextFile );
1675 # Check for a conflict
1676 $cmd = Shell::escape(
$wgDiff3,
'--text',
'--overlap-only', $mytextName,
1677 $oldtextName, $yourtextName );
1678 $handle = popen( $cmd,
'r' );
1680 $mergeLeftovers =
'';
1682 $data = fread( $handle, 8192 );
1683 if ( strlen( $data ) == 0 ) {
1686 $mergeLeftovers .= $data;
1690 $conflict = $mergeLeftovers !==
'';
1692 # Merge differences automatically where possible, preferring "my" text for conflicts.
1693 $cmd = Shell::escape(
$wgDiff3,
'--text',
'--ed',
'--merge', $mytextName,
1694 $oldtextName, $yourtextName );
1695 $handle = popen( $cmd,
'r' );
1696 $simplisticMergeAttempt =
'';
1698 $data = fread( $handle, 8192 );
1699 if ( strlen( $data ) == 0 ) {
1702 $simplisticMergeAttempt .= $data;
1705 unlink( $mytextName );
1706 unlink( $oldtextName );
1707 unlink( $yourtextName );
1709 if ( $simplisticMergeAttempt ===
'' && $old !==
'' && !$conflict ) {
1710 wfDebug(
"Unexpected null result from diff3. Command: $cmd" );
1729 if ( $suffix ==
'' ) {
1732 $encSuffix =
'(?:' . preg_quote( $suffix,
'#' ) .
')?';
1736 if ( preg_match(
"#([^/\\\\]*?){$encSuffix}[/\\\\]*$#",
$path,
$matches ) ) {
1754 $path = str_replace(
'/', DIRECTORY_SEPARATOR,
$path );
1755 $from = str_replace(
'/', DIRECTORY_SEPARATOR, $from );
1759 $from = rtrim( $from, DIRECTORY_SEPARATOR );
1761 $pieces = explode( DIRECTORY_SEPARATOR, dirname(
$path ) );
1762 $against = explode( DIRECTORY_SEPARATOR, $from );
1764 if ( $pieces[0] !== $against[0] ) {
1771 while ( count( $pieces ) && count( $against )
1772 && $pieces[0] == $against[0] ) {
1773 array_shift( $pieces );
1774 array_shift( $against );
1778 while ( count( $against ) ) {
1779 array_unshift( $pieces,
'..' );
1780 array_shift( $against );
1785 return implode( DIRECTORY_SEPARATOR, $pieces );
1825function wfGetDB( $db, $groups = [], $wiki =
false ) {
1828 if ( $wiki ===
false ) {
1829 return MediaWikiServices::getInstance()
1830 ->getDBLoadBalancer()
1831 ->getMaintenanceConnectionRef( $db, $groups, $wiki );
1833 return MediaWikiServices::getInstance()
1834 ->getDBLoadBalancerFactory()
1835 ->getMainLB( $wiki )
1836 ->getMaintenanceConnectionRef( $db, $groups, $wiki );
1851 if ( $script ===
'index' ) {
1853 } elseif ( $script ===
'load' ) {
1856 return "{$wgScriptPath}/{$script}.php";
1868 return $value ?
'true' :
'false';
1891 $name = preg_replace(
1892 "/[^" . Title::legalChars() .
"]" . $illegalFileChars .
"/",
1910 if ( $oldLimit != -1 ) {
1912 if ( $newLimit == -1 ) {
1913 wfDebug(
"Removing PHP's memory limit" );
1914 AtEase::suppressWarnings();
1915 ini_set(
'memory_limit', $newLimit );
1916 AtEase::restoreWarnings();
1917 } elseif ( $newLimit > $oldLimit ) {
1918 wfDebug(
"Raising PHP's memory limit to $newLimit bytes" );
1919 AtEase::suppressWarnings();
1920 ini_set(
'memory_limit', $newLimit );
1921 AtEase::restoreWarnings();
1935 $timeout = RequestTimeout::singleton();
1936 $timeLimit = $timeout->getWallTimeLimit();
1937 if ( $timeLimit !== INF ) {
1944 $timeLimit = (int)ini_get(
'max_execution_time' );
1950 ignore_user_abort(
true );
1963 $string = trim( $string ??
'' );
1964 if ( $string ===
'' ) {
1967 $last = $string[strlen( $string ) - 1];
1968 $val = intval( $string );
1995 return in_array( $str, ExpiryDef::INFINITY_VALS );
2015 $multipliers = [ 1 ];
2019 $multipliers[] = 1.5;
2024 if ( !$handler || !isset(
$params[
'width'] ) ) {
2029 if ( isset(
$params[
'page'] ) ) {
2030 $basicParams[
'page'] =
$params[
'page'];
2036 foreach ( $multipliers as $multiplier ) {
2037 $thumbLimits = array_merge( $thumbLimits, array_map(
2038 static function ( $width ) use ( $multiplier ) {
2039 return round( $width * $multiplier );
2042 $imageLimits = array_merge( $imageLimits, array_map(
2043 static function ( $pair ) use ( $multiplier ) {
2045 round( $pair[0] * $multiplier ),
2046 round( $pair[1] * $multiplier ),
2053 if ( in_array(
$params[
'width'], $thumbLimits ) ) {
2054 $normalParams = $basicParams + [
'width' =>
$params[
'width'] ];
2056 $handler->normaliseParams( $file, $normalParams );
2060 foreach ( $imageLimits as $pair ) {
2061 $normalParams = $basicParams + [
'width' => $pair[0],
'height' => $pair[1] ];
2064 $handler->normaliseParams( $file, $normalParams );
2066 if ( $normalParams[
'width'] ==
$params[
'width'] ) {
2077 foreach (
$params as $key => $value ) {
2078 if ( !isset( $normalParams[$key] ) || $normalParams[$key] != $value ) {
2100 foreach ( $baseArray as $name => &$groupVal ) {
2101 if ( isset( $newValues[$name] ) ) {
2102 $groupVal += $newValues[$name];
2106 $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().
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,...
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
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.
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
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()
wfMerge(string $old, string $mine, string $yours, ?string &$simplisticMergeAttempt, string &$mergeLeftovers=null)
wfMerge attempts to merge differences between three texts.
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,...
wfUrlProtocolsWithoutProtRel()
Like wfUrlProtocols(), but excludes '//' from the protocol list.
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.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfShorthandToInteger(?string $string='', int $default=-1)
Converts shorthand byte notation to integer form.
wfBacktrace( $raw=null)
Get a debug backtrace as a string.
wfArrayDiff2( $arr1, $arr2)
Like array_diff( $arr1, $arr2 ) except that it works with two-dimensional arrays.
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
wfExpandIRI( $url)
Take a URL, make sure it's expanded to fully qualified, and replace any encoded non-ASCII Unicode cha...
wfMergeErrorArrays(... $args)
Merge arrays in the style of PermissionManager::getPermissionErrors, with duplicate removal e....
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.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL using $wgServer (or one of its alternatives).
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.
wfUrlProtocols( $includeProtocolRelative=true)
Returns a partial regular expression of recognized URL protocols, e.g.
wfMessageFallback(... $keys)
This function accepts multiple message keys and returns a message instance for the first message whic...
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.
wfGetServerUrl( $proto)
Get the wiki's "server", i.e.
wfStringToBool( $val)
Convert string value to boolean, when the following are interpreted as true:
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...
wfMatchesDomainList( $url, $domains)
Check whether a given URL has a domain that occurs in a given set of domains.
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.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
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.
wfAssembleUrl( $urlParts)
This function will reassemble a URL parsed with wfParseURL.
wfResetOutputBuffers( $resetGzipEncoding=true)
Clear away any user-level output buffers, discarding contents.
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgOut
array $params
The job parameters.
Implements some public methods and some protected utility functions which are required by multiple ch...
getHandler()
Get a MediaHandler instance for this file.
$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.