$out = array();
foreach ( $args as $errors ) {
foreach ( $errors as $params ) {
+ $originalParams = $params;
+ if ( $params[0] instanceof MessageSpecifier ) {
+ $msg = $params[0];
+ $params = array_merge( array( $msg->getKey() ), $msg->getParams() );
+ }
# @todo FIXME: Sometimes get nested arrays for $params,
# which leads to E_NOTICEs
$spec = implode( "\t", $params );
- $out[$spec] = $params;
+ $out[$spec] = $originalParams;
}
}
return array_values( $out );
* not likely to give duplicate values for any realistic
* number of articles.
*
+ * @note This is designed for use in relation to Special:RandomPage
+ * and the page_random database field.
+ *
* @return string
*/
function wfRandom() {
- # The maximum random value is "only" 2^31-1, so get two random
- # values to reduce the chance of dupes
+ // The maximum random value is "only" 2^31-1, so get two random
+ // values to reduce the chance of dupes
$max = mt_getrandmax() + 1;
$rand = number_format( ( mt_rand() * $max + mt_rand() ) / $max / $max, 12, '.', '' );
-
return $rand;
}
/**
- * Get a random string containing a number of pseudo-random hex
- * characters.
+ * Get a random string containing a number of pseudo-random hex characters.
+ *
* @note This is not secure, if you are trying to generate some sort
* of token please use MWCryptRand instead.
*
}
/**
- * This function takes two arrays as input, and returns a CGI-style string, e.g.
+ * This function takes one or 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 array|null $array2 ( String|Array )
* @param string $prefix
* @return string
*/
$text = trim( $text );
- // Inline logic from deprecated wfDebugTimer()
if ( $wgDebugTimestamps ) {
$context['seconds_elapsed'] = sprintf(
'%6.4f',
return $cache;
}
-/**
- * Get microsecond timestamps for debug logs
- *
- * @deprecated since 1.25
- * @return string
- */
-function wfDebugTimer() {
- global $wgDebugTimestamps, $wgRequestTime;
-
- wfDeprecated( __METHOD__, '1.25' );
-
- if ( !$wgDebugTimestamps ) {
- return '';
- }
-
- $prefix = sprintf( "%6.4f", microtime( true ) - $wgRequestTime );
- $mem = sprintf( "%5.1fM", ( memory_get_usage( true ) / ( 1024 * 1024 ) ) );
- return "$prefix $mem ";
-}
-
/**
* Send a line giving PHP memory usage.
*
* @param string $file Filename
* @param array $context Additional logging context data
* @throws MWException
- * @deprecated since 1.25 Use \\MediaWiki\\Logger\\LegacyLogger::emit or UDPTransport
+ * @deprecated since 1.25 Use \MediaWiki\Logger\LegacyLogger::emit or UDPTransport
*/
function wfErrorLog( $text, $file, array $context = array() ) {
wfDeprecated( __METHOD__, '1.25' );
* Supports base 2 through 36; digit values 10-36 are represented
* as lowercase letters a-z. Input is case-insensitive.
*
+ * @deprecated 1.27 Use Wikimedia\base_convert() directly
+ *
* @param string $input Input number
* @param int $sourceBase Base of the input number
* @param int $destBase Desired base of the output
return in_array( $str, $infinityValues );
}
-/**
- * Work out the IP address based on various globals
- * For trusted proxies, use the XFF client IP (first of the chain)
- *
- * @deprecated since 1.19; call $wgRequest->getIP() directly.
- * @return string
- */
-function wfGetIP() {
- wfDeprecated( __METHOD__, '1.19' );
- global $wgRequest;
- return $wgRequest->getIP();
-}
-
-/**
- * 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.
- * @deprecated Since 1.24, use IP::isTrustedProxy()
- *
- * @param string $ip
- * @return bool
- */
-function wfIsTrustedProxy( $ip ) {
- wfDeprecated( __METHOD__, '1.24' );
- return IP::isTrustedProxy( $ip );
-}
-
-/**
- * Checks if an IP matches a proxy we've configured.
- * @deprecated Since 1.24, use IP::isConfiguredProxy()
- *
- * @param string $ip
- * @return bool
- * @since 1.23 Supports CIDR ranges in $wgSquidServersNoPurge
- */
-function wfIsConfiguredProxy( $ip ) {
- wfDeprecated( __METHOD__, '1.24' );
- return IP::isConfiguredProxy( $ip );
-}
-
/**
* Returns true if these thumbnail parameters match one that MediaWiki
* requests from file description pages and/or parser output.