Jump to content

Manual:Extension support/1.17/ExtUpgrading

From mediawiki.org

HttpRequest and Http::request

[edit]

The HttpRequest class introduced in 1.16 has been renamed to MWHttpRequest. The recommendation is to use branching logic and use MWHttpRequest when possible and at worst Http::request.

if (class_exists('MWHttpRequest') || class_exists('HttpRequest')) {
  // MWHttpRequest is 1.17+
  // HttpRequest is 1.16
  $httpRequest = class_exists('MWHttpRequest') ? 'MWHttpRequest' : 'HttpRequest';
  // to call static methods on it pre php 5.3.0 you will need to: call_user_func( array($httpRequest, 'staticmethod'), $arg1, $arg2, ... );
  ...        
} else {
  // Http::request is pre 1.16     
  $status = Http::request('GET',$url);
}