Merge "Remove ApiQueryBase::getDirectionDescription()"
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 421cd90..e30b371 100644 (file)
@@ -374,20 +374,22 @@ function wfObjectToArray( $objOrArray, $recursive = true ) {
  * 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.
  *
@@ -458,12 +460,12 @@ function wfUrlencode( $s ) {
 }
 
 /**
- * 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
  */
@@ -1049,7 +1051,6 @@ function wfDebug( $text, $dest = 'all', array $context = array() ) {
 
        $text = trim( $text );
 
-       // Inline logic from deprecated wfDebugTimer()
        if ( $wgDebugTimestamps ) {
                $context['seconds_elapsed'] = sprintf(
                        '%6.4f',
@@ -1092,26 +1093,6 @@ function wfIsDebugRawPage() {
        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.
  *
@@ -1238,7 +1219,7 @@ function wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) {
  * @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' );
@@ -3330,6 +3311,8 @@ function wfRelativePath( $path, $from ) {
  * 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
@@ -4089,46 +4072,6 @@ function wfIsInfinity( $str ) {
        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.