[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Source view] [Print] [Project Stats]
Global functions used everywhere. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
File Size: | 4164 lines (120 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
mb_substr( $str, $start, $count = 'end' ) X-Ref |
return: string |
mb_substr_split_unicode( $str, $splitPos ) X-Ref |
return: int |
mb_strlen( $str, $enc = '' ) X-Ref |
return: int |
mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) X-Ref |
return: int |
mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) X-Ref |
return: int |
gzdecode( $data ) X-Ref |
param: string $data return: string |
hash_equals( $known_string, $user_string ) X-Ref |
Check whether a user-provided string is equal to a fixed-length secret string without revealing bytes of the secret string through timing differences. The usual way to compare strings (PHP's === operator or the underlying memcmp() function in C) is to compare corresponding bytes and stop at the first difference, which would take longer for a partial match than for a complete mismatch. This is not secure when one of the strings (e.g. an HMAC or token) must remain secret and the other may come from an attacker. Statistical analysis of timing measurements over many requests may allow the attacker to guess the string's bytes one at a time (and check his guesses) even if the timing differences are extremely small. When making such a security-sensitive comparison, it is essential that the sequence in which instructions are executed and memory locations are accessed not depend on the secret string's value. HOWEVER, for simplicity, we do not attempt to minimize the inevitable leakage of the string's length. That is generally known anyway as a chararacteristic of the hash function used to compute the secret value. Longer explanation: http://www.emerose.com/timing-attacks-explained param: string $known_string Fixed-length secret string to compare against param: string $user_string User-provided string return: bool True if the strings are the same, false otherwise |
wfArrayDiff2( $a, $b ) X-Ref |
Like array_diff( $a, $b ) except that it works with two-dimensional arrays. param: array $a param: array $b return: array |
wfArrayDiff2_cmp( $a, $b ) X-Ref |
param: array|string $a param: array|string $b return: int |
wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) X-Ref |
Appends to second array if $value differs from that in $default param: string|int $key param: mixed $value param: mixed $default param: array $changed Array to alter |
wfMergeErrorArrays( ) X-Ref |
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g. wfMergeErrorArrays( array( array( 'x' ) ), array( array( 'x', '2' ) ), array( array( 'x' ) ), array( array( 'y' ) ) ); returns: array( array( 'x', '2' ), array( 'x' ), array( 'y' ) ) param: array $array1,... return: array |
wfArrayInsertAfter( array $array, array $insert, $after ) X-Ref |
Insert array into another array after the specified *KEY* param: array $array The array. param: array $insert The array to insert. param: mixed $after The key to insert after return: array |
wfObjectToArray( $objOrArray, $recursive = true ) X-Ref |
Recursively converts the parameter (an object) to an array with the same data param: object|array $objOrArray param: bool $recursive return: array |
wfRandom() X-Ref |
Get a random decimal value between 0 and 1, in a way not likely to give duplicate values for any realistic number of articles. return: string |
wfRandomString( $length = 32 ) X-Ref |
Get a random string containing a number of pseudo-random hex characters. param: int $length The length of the string to generate return: string |
wfUrlencode( $s ) X-Ref |
We want some things to be included as literal characters in our title URLs for prettiness, which urlencode encodes by default. According to RFC 1738, all of the following should be safe: ;:@&=$-_.+!*'(), But + is not safe because it's used to indicate a space; &= are only safe in paths and not in queries (and we don't distinguish here); ' seems kind of scary; and urlencode() doesn't touch -_. to begin with. Plus, although / is reserved, we don't care. So the list we unescape is: ;:@$!*(),/ However, IIS7 redirects fail when the url contains a colon (Bug 22709), so no fancy : for IIS7. %2F in the page titles seems to fatally break for some reason. param: string $s return: string |
wfArrayToCgi( $array1, $array2 = null, $prefix = '' ) X-Ref |
This function takes two arrays as input, and returns a CGI-style string, e.g. "days=7&limit=100". Options in the first array override options in the second. Options set to null or false will not be output. param: array $array1 ( String|Array ) param: array $array2 ( String|Array ) param: string $prefix return: string |
wfCgiToArray( $query ) X-Ref |
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns the same string in array form. This allows compatibility with legacy functions that accept raw query strings instead of nice arrays. Of course, keys and values are urldecode()d. param: string $query Query string return: string[] Array version of input |
wfAppendQuery( $url, $query ) X-Ref |
Append a query string to an existing URL, which may or may not already have query string parameters already. If so, they will be combined. param: string $url param: string|string[] $query String or associative array return: string |
wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) X-Ref |
Expand a potentially local URL to a fully-qualified URL. Assumes $wgServer is correct. The meaning of the PROTO_* constants is as follows: PROTO_HTTP: Output a URL starting with http:// PROTO_HTTPS: Output a URL starting with https:// PROTO_RELATIVE: Output a URL starting with // (protocol-relative URL) PROTO_CURRENT: Output a URL starting with either http:// or https:// , depending on which protocol was used for the current incoming request PROTO_CANONICAL: For URLs without a domain, like /w/index.php , use $wgCanonicalServer. For protocol-relative URLs, use the protocol of $wgCanonicalServer PROTO_INTERNAL: Like PROTO_CANONICAL, but uses $wgInternalServer instead of $wgCanonicalServer param: string $url Either fully-qualified or a local path + query param: string $defaultProto One of the PROTO_* constants. Determines the return: string Fully-qualified URL, current-path-relative URL or false if |
wfAssembleUrl( $urlParts ) X-Ref |
This function will reassemble a URL parsed with wfParseURL. This is useful if you need to edit part of a URL and put it back together. This is the basic structure used (brackets contain keys for $urlParts): [scheme][delimiter][user]:[pass]@[host]:[port][path]?[query]#[fragment] param: array $urlParts URL parts, as output from wfParseUrl return: string URL assembled from its component parts |
wfRemoveDotSegments( $urlPath ) X-Ref |
Remove all dot-segments in the provided URL path. For example, '/a/./b/../c/' becomes '/a/c/'. For details on the algorithm, please see RFC3986 section 5.2.4. param: string $urlPath URL path, potentially containing dot-segments return: string URL path with all dot-segments removed |
wfUrlProtocols( $includeProtocolRelative = true ) X-Ref |
Returns a regular expression of url protocols param: bool $includeProtocolRelative If false, remove '//' from the returned protocol list. return: string |
wfUrlProtocolsWithoutProtRel() X-Ref |
Like wfUrlProtocols(), but excludes '//' from the protocol list. Use this if you need a regex that matches all URL protocols but does not match protocol- relative URLs return: string |
wfParseUrl( $url ) X-Ref |
parse_url() work-alike, but non-broken. Differences: 1) Does not raise warnings on bad URLs (just returns false). 2) Handles protocols that don't use :// (e.g., mailto: and news:, as well as protocol-relative URLs) correctly. 3) Adds a "delimiter" element to the array, either '://', ':' or '//' (see (2)). param: string $url A URL to parse return: string[] Bits of the URL in an associative array, per PHP docs |
wfExpandIRI( $url ) X-Ref |
Take a URL, make sure it's expanded to fully qualified, and replace any encoded non-ASCII Unicode characters with their UTF-8 original forms for more compact display and legibility for local audiences. param: string $url return: string |
wfExpandIRI_callback( $matches ) X-Ref |
Private callback for wfExpandIRI param: array $matches return: string |
wfMakeUrlIndexes( $url ) X-Ref |
Make URL indexes, appropriate for the el_index field of externallinks. param: string $url return: array |
wfMatchesDomainList( $url, $domains ) X-Ref |
Check whether a given URL has a domain that occurs in a given set of domains param: string $url URL param: array $domains Array of domains (strings) return: bool True if the host part of $url ends in one of the strings in $domains |
wfDebug( $text, $dest = 'all' ) X-Ref |
Sends a line to the debug log if enabled or, optionally, to a comment in output. In normal operation this is a NOP. Controlling globals: $wgDebugLogFile - points to the log file $wgDebugRawPage - if false, 'action=raw' hits will not result in debug output. $wgDebugComments - if on, some debug items may appear in comments in the HTML output. param: string $text param: string|bool $dest Destination of the message: |
wfIsDebugRawPage() X-Ref |
Returns true if debug logging should be suppressed if $wgDebugRawPage = false return: bool |
wfDebugTimer() X-Ref |
Get microsecond timestamps for debug logs return: string |
wfDebugMem( $exact = false ) X-Ref |
Send a line giving PHP memory usage. param: bool $exact Print exact byte values instead of kibibytes (default: false) |
wfDebugLog( $logGroup, $text, $dest = 'all' ) X-Ref |
Send a line to a supplementary debug log file, if configured, or main debug log if not. To configure a supplementary log file, set $wgDebugLogGroups[$logGroup] to a string filename or an associative array mapping 'destination' to the desired filename. The associative array may also contain a 'sample' key with an integer value, specifying a sampling factor. param: string $logGroup param: string $text param: string|bool $dest Destination of the message: |
wfLogDBError( $text ) X-Ref |
Log for database errors param: string $text Database error message. |
wfDeprecated( $function, $version = false, $component = false, $callerOffset = 2 ) X-Ref |
Throws a warning that $function is deprecated param: string $function param: string|bool $version Version of MediaWiki that the function param: string|bool $component Added in 1.19. param: int $callerOffset How far up the call stack is the original return: null |
wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) X-Ref |
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings. To log warnings in production, use wfLogWarning() instead. param: string $msg Message to send param: int $callerOffset Number of items to go back in the backtrace to param: int $level PHP error level; defaults to E_USER_NOTICE; |
wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) X-Ref |
Send a warning as a PHP error and the debug log. This is intended for logging warnings in production. For logging development warnings, use WfWarn instead. param: string $msg Message to send param: int $callerOffset Number of items to go back in the backtrace to param: int $level PHP error level; defaults to E_USER_WARNING |
wfErrorLog( $text, $file ) X-Ref |
Log to a file without getting "file size exceeded" signals. Can also log to TCP or UDP with the syntax udp://host:port/prefix. This will send lines to the specified port, prefixed by the specified prefix and a space. param: string $text param: string $file Filename |
wfLogProfilingData() X-Ref |
wfIncrStats( $key, $count = 1 ) X-Ref |
Increment a statistics counter param: string $key param: int $count return: void |
wfReadOnly() X-Ref |
Check whether the wiki is in read-only mode. return: bool |
wfReadOnlyReason() X-Ref |
Get the value of $wgReadOnly or the contents of $wgReadOnlyFile. return: string|bool String when in read-only mode; false otherwise |
wfGetLangObj( $langcode = false ) X-Ref |
Return a Language object from $langcode param: Language|string|bool $langcode Either: return: Language |
wfMessage( $key ) X-Ref |
This is the function for getting translated interface messages. param: string|string[] $key Message key, or array of keys param: mixed $params,... Normal message parameters return: Message |
wfMessageFallback( ) X-Ref |
This function accepts multiple message keys and returns a message instance for the first message which is non-empty. If all messages are empty then an instance of the first message key is returned. param: string|string[] $keys,... Message keys return: Message |
wfMsg( $key ) X-Ref |
Get a message from anywhere, for the current user language. Use wfMsgForContent() instead if the message should NOT change depending on the user preferences. param: string $key Lookup key for the message, usually return: string |
wfMsgNoTrans( $key ) X-Ref |
Same as above except doesn't transform the message param: string $key return: string |
wfMsgForContent( $key ) X-Ref |
Get a message from anywhere, for the current global language set with $wgLanguageCode. Use this if the message should NOT change dependent on the language set in the user's preferences. This is the case for most text written into logs, as well as link targets (such as the name of the copyright policy page). Link titles, on the other hand, should be shown in the UI language. Note that MediaWiki allows users to change the user interface language in their preferences, but a single installation typically only contains content in one language. Be wary of this distinction: If you use wfMsg() where you should use wfMsgForContent(), a user of the software may have to customize potentially hundreds of messages in order to, e.g., fix a link in every possible language. param: string $key Lookup key for the message, usually return: string |
wfMsgForContentNoTrans( $key ) X-Ref |
Same as above except doesn't transform the message param: string $key return: string |
wfMsgReal( $key, $args, $useDB = true, $forContent = false, $transform = true ) X-Ref |
Really get a message param: string $key Key to get. param: array $args param: bool $useDB param: string|bool $forContent Language code, or false for user lang, true for content lang. param: bool $transform Whether or not to transform the message. return: string The requested message. |
wfMsgGetKey( $key, $useDB = true, $langCode = false, $transform = true ) X-Ref |
Fetch a message string value, but don't replace any keys yet. param: string $key param: bool $useDB param: string|bool $langCode Code of the language to get the message for, or param: bool $transform Whether to parse magic words, etc. return: string |
wfMsgReplaceArgs( $message, $args ) X-Ref |
Replace message parameter keys on the given formatted output. param: string $message param: array $args return: string |
wfMsgHtml( $key ) X-Ref |
Return an HTML-escaped version of a message. Parameter replacements, if any, are done *after* the HTML-escaping, so parameters may contain HTML (eg links or form controls). Be sure to pre-escape them if you really do want plaintext, or just wrap the whole thing in htmlspecialchars(). param: string $key param: string $args,... Parameters return: string |
wfMsgWikiHtml( $key ) X-Ref |
Return an HTML version of message Parameter replacements, if any, are done *after* parsing the wiki-text message, so parameters may contain HTML (eg links or form controls). Be sure to pre-escape them if you really do want plaintext, or just wrap the whole thing in htmlspecialchars(). param: string $key param: string $args,... Parameters return: string |
wfMsgExt( $key, $options ) X-Ref |
Returns message in the requested format param: string $key Key of the message param: array $options Processing rules. return: string |
wfEmptyMsg( $key ) X-Ref |
Since wfMsg() and co suck, they don't return false if the message key they looked up didn't exist but instead the key wrapped in <>'s, this function checks for the nonexistence of messages by checking the MessageCache::get() result directly. param: string $key The message key looked up return: bool True if the message *doesn't* exist. |
wfHostname() X-Ref |
Fetch server name for use in error reporting etc. Use real server name if available, so we know which machine in a server farm generated the current page. return: string |
wfReportTime() X-Ref |
Returns a script tag that stores the amount of time it took MediaWiki to handle the request in milliseconds as 'wgBackendResponseTime'. If $wgShowHostnames is true, the script will also set 'wgHostname' to the hostname of the server handling the request. return: string |
wfDebugBacktrace( $limit = 0 ) X-Ref |
Safety wrapper for debug_backtrace(). Will return an empty array if debug_backtrace is disabled, otherwise the output from debug_backtrace() (trimmed). param: int $limit This parameter can be used to limit the number of stack frames returned return: array Array of backtrace information |
wfBacktrace() X-Ref |
Get a debug backtrace as a string return: string |
wfGetCaller( $level = 2 ) X-Ref |
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfGetCaller() call (ie. __FUNCTION__) wfGetCaller( 2 ) [default] is the caller of the function running wfGetCaller() wfGetCaller( 3 ) is the parent of that. param: int $level return: string |
wfGetAllCallers( $limit = 3 ) X-Ref |
Return a string consisting of callers in the stack. Useful sometimes for profiling specific points. param: int $limit The maximum depth of the stack frame to return, or false for the entire stack. return: string |
wfFormatStackFrame( $frame ) X-Ref |
Return a string representation of frame param: array $frame return: string |
wfShowingResults( $offset, $limit ) X-Ref |
param: int $offset param: int $limit return: string |
wfClientAcceptsGzip( $force = false ) X-Ref |
param: bool $force return: bool Whereas client accept gzip compression |
wfCheckLimits( $deflimit = 50, $optionname = 'rclimit' ) X-Ref |
Obtain the offset and limit values from the request string; used in special pages param: int $deflimit Default limit if none supplied param: string $optionname Name of a user preference to check against return: array |
wfEscapeWikiText( $text ) X-Ref |
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc. making its way through. This is achieved by substituting certain characters with HTML entities. As required by the callers, "<nowiki>" is not used. param: string $text Text to be escaped return: string |
wfSetVar( &$dest, $source, $force = false ) X-Ref |
Sets dest to source and returns the original value of dest If source is NULL, it just returns the value, it doesn't set the variable If force is true, it will set the value even if source is NULL param: mixed $dest param: mixed $source param: bool $force return: mixed |
wfSetBit( &$dest, $bit, $state = true ) X-Ref |
As for wfSetVar except setting a bit param: int $dest param: int $bit param: bool $state return: bool |
wfVarDump( $var ) X-Ref |
A wrapper around the PHP function var_export(). Either print it or add it to the regular output ($wgOut). param: mixed $var A PHP variable to dump. |
wfHttpError( $code, $label, $desc ) X-Ref |
Provide a simple HTTP error. param: int|string $code param: string $label param: string $desc |
wfResetOutputBuffers( $resetGzipEncoding = true ) X-Ref |
Clear away any user-level output buffers, discarding contents. Suitable for 'starting afresh', for instance when streaming relatively large amounts of data without buffering, or wanting to output image files without ob_gzhandler's compression. The optional $resetGzipEncoding parameter controls suppression of the Content-Encoding header sent by ob_gzhandler; by default it is left. See comments for wfClearOutputBuffers() for why it would be used. Note that some PHP configuration options may add output buffer layers which cannot be removed; these are left in place. param: bool $resetGzipEncoding |
wfClearOutputBuffers() X-Ref |
More legible than passing a 'false' parameter to wfResetOutputBuffers(): Clear away output buffers, but keep the Content-Encoding header produced by ob_gzhandler, if any. This should be used for HTTP 304 responses, where you need to preserve the Content-Encoding header of the real result, but also need to suppress the output of ob_gzhandler to keep to spec and avoid breaking Firefox in rare cases where the headers and body are broken over two packets. |
wfAcceptToPrefs( $accept, $def = '*/*' ) X-Ref |
Converts an Accept-* header into an array mapping string values to quality factors param: string $accept param: string $def Default return: float[] Associative array of string => float pairs |
mimeTypeMatch( $type, $avail ) X-Ref |
Checks if a given MIME type matches any of the keys in the given array. Basic wildcards are accepted in the array keys. Returns the matching MIME type (or wildcard) if a match, otherwise NULL if no match. param: string $type param: array $avail return: string |
wfNegotiateType( $cprefs, $sprefs ) X-Ref |
Returns the 'best' match between a client's requested internet media types and the server's list of available types. Each list should be an associative array of type to preference (preference is a float between 0.0 and 1.0). Wildcards in the types are acceptable. param: array $cprefs Client's acceptable type list param: array $sprefs Server's offered types return: string |
wfSuppressWarnings( $end = false ) X-Ref |
Reference-counted warning suppression param: bool $end |
wfRestoreWarnings() X-Ref |
Restore error level to previous value |
wfTimestamp( $outputtype = TS_UNIX, $ts = 0 ) X-Ref |
Get a timestamp string in one of various formats param: mixed $outputtype A timestamp in one of the supported formats, the param: mixed $ts Optional timestamp to convert, default 0 for the current time return: string|bool String / false The same date in the format specified in $outputtype or false |
wfTimestampOrNull( $outputtype = TS_UNIX, $ts = null ) X-Ref |
Return a formatted timestamp, or null if input is null. For dealing with nullable timestamp columns in the database. param: int $outputtype param: string $ts return: string |
wfTimestampNow() X-Ref |
Convenience function; returns MediaWiki timestamp for the present time. return: string |
wfIsWindows() X-Ref |
Check if the operating system is Windows return: bool True if it's Windows, false otherwise. |
wfIsHHVM() X-Ref |
Check if we are running under HHVM return: bool |
swap( &$x, &$y ) X-Ref |
Swap two variables param: mixed $x param: mixed $y |
wfTempDir() X-Ref |
Tries to get the system directory for temporary files. First $wgTmpDirectory is checked, and then the TMPDIR, TMP, and TEMP environment variables are then checked in sequence, and if none are set try sys_get_temp_dir(). NOTE: When possible, use instead the tmpfile() function to create temporary files to avoid race conditions on file creation, etc. return: string |
wfMkdirParents( $dir, $mode = null, $caller = null ) X-Ref |
Make directory, and make all parent directories if they don't exist param: string $dir Full path to directory to create param: int $mode Chmod value to use, default is $wgDirectoryMode param: string $caller Optional caller param for debugging. return: bool |
wfRecursiveRemoveDir( $dir ) X-Ref |
Remove a directory and all its content. Does not hide error. param: string $dir |
wfPercent( $nr, $acc = 2, $round = true ) X-Ref |
param: int $nr The number to format param: int $acc The number of digits after the decimal point, default 2 param: bool $round Whether or not to round the value, default true return: string |
wfIniGetBool( $setting ) X-Ref |
Safety wrapper around ini_get() for boolean settings. The values returned from ini_get() are pre-normalized for settings set via php.ini or php_flag/php_admin_flag... but *not* for those set via php_value/php_admin_value. It's fairly common for people to use php_value instead of php_flag, which can leave you with an 'off' setting giving a false positive for code that just takes the ini_get() return value as a boolean. To make things extra interesting, setting via php_value accepts "true" and "yes" as true, but php.ini and php_flag consider them false. :) Unrecognized values go false... again opposite PHP's own coercion from string to bool. Luckily, 'properly' set settings will always come back as '0' or '1', so we only have to worry about them and the 'improper' settings. I frickin' hate PHP... :P param: string $setting return: bool |
wfEscapeShellArg( ) X-Ref |
Windows-compatible version of escapeshellarg() Windows doesn't recognise single-quotes in the shell, but the escapeshellarg() function puts single quotes in regardless of OS. Also fixes the locale problems on Linux in PHP 5.2.6+ (bug backported to earlier distro releases of PHP) param: string $args,... return: string |
wfShellExecDisabled() X-Ref |
Check if wfShellExec() is effectively disabled via php.ini config return: bool|string False or one of (safemode,disabled) |
wfShellExec( $cmd, &$retval = null, $environ = array() X-Ref |
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported. param: string|string[] $cmd If string, a properly shell-escaped command line, param: null|mixed &$retval Optional, will receive the program's exit code. param: array $environ Optional environment variables which should be param: array $limits Optional array with limits(filesize, memory, time, walltime) param: array $options Array of options: return: string Collected stdout as a string |
wfShellExecWithStderr( $cmd, &$retval = null, $environ = array() X-Ref |
Execute a shell command, returning both stdout and stderr. Convenience function, as all the arguments to wfShellExec can become unwieldy. param: string $cmd Command line, properly escaped for shell. param: null|mixed &$retval Optional, will receive the program's exit code. param: array $environ Optional environment variables which should be param: array $limits Optional array with limits(filesize, memory, time, walltime) return: string Collected stdout and stderr as a string |
wfInitShellLocale() X-Ref |
Workaround for http://bugs.php.net/bug.php?id=45132 escapeshellarg() destroys non-ASCII characters if LANG is not a UTF-8 locale |
wfShellMaintenanceCmd( $script, array $parameters = array() X-Ref |
Alias to wfShellWikiCmd() |
wfShellWikiCmd( $script, array $parameters = array() X-Ref |
Generate a shell-escaped command line string to run a MediaWiki cli script. Note that $parameters should be a flat array and an option with an argument should consist of two consecutive items in the array (do not use "--option value"). param: string $script MediaWiki cli script path param: array $parameters Arguments and options to the script param: array $options Associative array of options: return: string |
wfMerge( $old, $mine, $yours, &$result ) X-Ref |
wfMerge attempts to merge differences between three texts. Returns true for a clean merge and false for failure or a conflict. param: string $old param: string $mine param: string $yours param: string $result return: bool |
wfDiff( $before, $after, $params = '-u' ) X-Ref |
Returns unified plain-text diff of two texts. Useful for machine processing of diffs. param: string $before The text before the changes. param: string $after The text after the changes. param: string $params Command-line options for the diff command. return: string Unified diff of $before and $after |
wfUsePHP( $req_ver ) X-Ref |
This function works like "use VERSION" in Perl, the program will die with a backtrace if the current version of PHP is less than the version provided This is useful for extensions which due to their nature are not kept in sync with releases, and might depend on other versions of PHP than the main code Note: PHP might die due to parsing errors in some cases before it ever manages to call this function, such is life param: string|int|float $req_ver The version to check, can be a string, an integer, or a float |
wfUseMW( $req_ver ) X-Ref |
This function works like "use VERSION" in Perl except it checks the version of MediaWiki, the program will die with a backtrace if the current version of MediaWiki is less than the version provided. This is useful for extensions which due to their nature are not kept in sync with releases Note: Due to the behavior of PHP's version_compare() which is used in this function, if you want to allow the 'wmf' development versions add a 'c' (or any single letter other than 'a', 'b' or 'p') as a post-fix to your targeted version number. For example if you wanted to allow any variation of 1.22 use `wfUseMW( '1.22c' )`. Using an 'a' or 'b' instead of 'c' will not result in the same comparison due to the internal logic of version_compare(). param: string|int|float $req_ver The version to check, can be a string, an integer, or a float |
wfBaseName( $path, $suffix = '' ) X-Ref |
Return the final portion of a pathname. Reimplemented because PHP5's "basename()" is buggy with multibyte text. http://bugs.php.net/bug.php?id=33898 PHP's basename() only considers '\' a pathchar on Windows and Netware. We'll consider it so always, as we don't want '\s' in our Unix paths either. param: string $path param: string $suffix String to remove if present return: string |
wfRelativePath( $path, $from ) X-Ref |
Generate a relative path name to the given file. May explode on non-matching case-insensitive paths, funky symlinks, etc. param: string $path Absolute destination path including target filename param: string $from Absolute source path, directory only return: string |
wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1,$lowercase = true, $engine = 'auto') X-Ref |
Convert an arbitrarily-long digit string from one numeric base to another, optionally zero-padding to a minimum column width. Supports base 2 through 36; digit values 10-36 are represented as lowercase letters a-z. Input is case-insensitive. param: string $input Input number param: int $sourceBase Base of the input number param: int $destBase Desired base of the output param: int $pad Minimum number of digits in the output (pad with zeroes) param: bool $lowercase Whether to output in lowercase or uppercase param: string $engine Either "gmp", "bcmath", or "php" return: string|bool The output number as a string, or false on error |
wfCheckEntropy() X-Ref |
Check if there is sufficient entropy in php's built-in session generation return: bool True = there is sufficient entropy |
wfFixSessionID() X-Ref |
Override session_id before session startup if php's built-in session generation code is not secure. |
wfResetSessionID() X-Ref |
Reset the session_id |
wfSetupSession( $sessionId = false ) X-Ref |
Initialise php session param: bool $sessionId |
wfGetPrecompiledData( $name ) X-Ref |
Get an object from the precompiled serialized directory param: string $name return: mixed The variable on success, false on failure |
wfMemcKey( ) X-Ref |
Get a cache key param: string $args,... return: string |
wfForeignMemcKey( $db, $prefix ) X-Ref |
Get a cache key for a foreign DB param: string $db param: string $prefix param: string $args,... return: string |
wfWikiID() X-Ref |
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys return: string |
wfSplitWikiID( $wiki ) X-Ref |
Split a wiki ID into DB name and table prefix param: string $wiki return: array |
wfGetDB( $db, $groups = array() X-Ref |
Get a Database object. param: int $db Index of the connection to get. May be DB_MASTER for the param: string|string[] $groups Query groups. An array of group names that this query param: string|bool $wiki The wiki ID, or false for the current wiki return: DatabaseBase |
wfGetLB( $wiki = false ) X-Ref |
Get a load balancer object. param: string|bool $wiki Wiki ID, or false for the current wiki return: LoadBalancer |
wfGetLBFactory() X-Ref |
Get the load balancer factory object return: LBFactory |
wfFindFile( $title, $options = array() X-Ref |
Find a file. Shortcut for RepoGroup::singleton()->findFile() param: string $title String or Title object param: array $options Associative array of options: return: File|bool File, or false if the file does not exist |
wfLocalFile( $title ) X-Ref |
Get an object referring to a locally registered file. Returns a valid placeholder object if the file does not exist. param: Title|string $title return: LocalFile|null A File, or null if passed an invalid Title |
wfQueriesMustScale() X-Ref |
Should low-performance queries be disabled? return: bool |
wfScript( $script = 'index' ) X-Ref |
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScriptExtension etc. except for 'index' and 'load' which use $wgScript/$wgLoadScript param: string $script Script filename, sans extension return: string |
wfGetScriptUrl() X-Ref |
Get the script URL. return: string Script URL |
wfBoolToStr( $value ) X-Ref |
Convenience function converts boolean values into "true" or "false" (string) values param: bool $value return: string |
wfGetNull() X-Ref |
Get a platform-independent path to the null file, e.g. /dev/null return: string |
wfWaitForSlaves( $ifWritesSince = false, $wiki = false, $cluster = false ) X-Ref |
Modern version of wfWaitForSlaves(). Instead of looking at replication lag and waiting for it to go down, this waits for the slaves to catch up to the master position. Use this when updating very large numbers of rows, as in maintenance scripts, to avoid causing too much lag. Of course, this is a no-op if there are no slaves. param: float|null $ifWritesSince Only wait if writes were done since this UNIX timestamp param: string|bool $wiki Wiki identifier accepted by wfGetLB param: string|bool $cluster Cluster name accepted by LBFactory. Default: false. return: bool Success (able to connect and no timeouts reached) |
wfCountDown( $seconds ) X-Ref |
Count down from $seconds to zero on the terminal, with a one-second pause between showing each number. For use in command-line scripts. param: int $seconds |
wfStripIllegalFilenameChars( $name ) X-Ref |
Replace all invalid characters with - Additional characters can be defined in $wgIllegalFileChars (see bug 20489) By default, $wgIllegalFileChars = ':' param: string $name Filename to process return: string |
wfMemoryLimit() X-Ref |
Set PHP's memory limit to the larger of php.ini or $wgMemoryLimit; return: int Value the memory limit was set to. |
wfShorthandToInteger( $string = '' ) X-Ref |
Converts shorthand byte notation to integer form param: string $string return: int |
wfBCP47( $code ) X-Ref |
Get the normalised IETF language tag See unit test for examples. param: string $code The language code. return: string The language code which complying with BCP 47 standards. |
wfGetCache( $inputType ) X-Ref |
Get a cache object. param: int $inputType Cache type, one the the CACHE_* constants. return: BagOStuff |
wfGetMainCache() X-Ref |
Get the main cache object return: BagOStuff |
wfGetMessageCacheStorage() X-Ref |
Get the cache object used by the message cache return: BagOStuff |
wfGetParserCacheStorage() X-Ref |
Get the cache object used by the parser cache return: BagOStuff |
wfGetLangConverterCacheStorage() X-Ref |
Get the cache object used by the language converter return: BagOStuff |
wfRunHooks( $event, array $args = array() X-Ref |
Call hook functions defined in $wgHooks param: string $event Event name param: array $args Parameters passed to hook functions param: string|null $deprecatedVersion Optionally mark hook as deprecated with version number return: bool True if no handler aborted the hook |
wfUnpack( $format, $data, $length = false ) X-Ref |
Wrapper around php's unpack. param: string $format The format string (See php's docs) param: string $data A binary string of binary data param: int|bool $length The minimum length of $data or false. This is to return: array Associative array of the extracted data |
wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) X-Ref |
Determine if an image exists on the 'bad image list'. The format of MediaWiki:Bad_image_list is as follows: * Only list items (lines starting with "*") are considered * The first link on a line must be a link to a bad image * Any subsequent links on the same line are considered to be exceptions, i.e. articles where the image may occur inline. param: string $name The image name to check param: Title|bool $contextTitle The page on which the image occurs, if known param: string $blacklist Wikitext of a file blacklist return: bool |
wfCanIPUseHTTPS( $ip ) X-Ref |
Determine whether the client at a given source IP is likely to be able to access the wiki via HTTPS. param: string $ip The IPv4/6 address in the normal human-readable form return: bool |
wfGetIP() X-Ref |
Work out the IP address based on various globals For trusted proxies, use the XFF client IP (first of the chain) return: string |
wfIsTrustedProxy( $ip ) X-Ref |
Checks if an IP is a trusted proxy provider. Useful to tell if X-Forwarded-For data is possibly bogus. Squid cache servers for the site are whitelisted. param: string $ip return: bool |
wfIsConfiguredProxy( $ip ) X-Ref |
Checks if an IP matches a proxy we've configured. param: string $ip return: bool |
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |