Remove $timeout parameter from Http::get()
authorChad Horohoe <chadh@wikimedia.org>
Fri, 27 Feb 2015 16:48:21 +0000 (08:48 -0800)
committerChad Horohoe <chadh@wikimedia.org>
Mon, 2 Mar 2015 18:15:49 +0000 (10:15 -0800)
It is inconsistent with request() and post() and there's a couple
of mistaken usages in core and extensions that think they have the
same signature.

Change-Id: I834278639a3648edec7bcb57db7bb61f456d2a92

includes/HttpFunctions.php

index d066df8..7f0d6a2 100644 (file)
@@ -82,14 +82,22 @@ class Http {
        /**
         * Simple wrapper for Http::request( 'GET' )
         * @see Http::request()
+        * @since 1.25 Second parameter $timeout removed. Second parameter
+        * is now $options which can be given a 'timeout'
         *
         * @param string $url
-        * @param string $timeout
         * @param array $options
         * @return string
         */
-       public static function get( $url, $timeout = 'default', $options = array() ) {
-               $options['timeout'] = $timeout;
+       public static function get( $url, $options = array() ) {
+               $args = func_get_args();
+               if ( is_string( $args[1] ) || is_numeric( $args[1] ) ) {
+                       // Second was used to be the timeout
+                       // And third parameter used to be $options
+                       wfWarn( "Second parameter should not be a timeout." );
+                       $options = isset( $args[2] ) ? $args[2] : array();
+                       $options['timeout'] = $args[1];
+               }
                return Http::request( 'GET', $url, $options );
        }