Jump to content

Manual:Extension support/1.16/ExtDowngrading

From mediawiki.org

MWHttpRequest

[edit]

The MWHttpRequest class introduced in 1.17 was originally named HttpRequest in 1.16 when it was first introduced. If you want to support pre-1.16 you will also need to use Http::request. The recommendation is to use branching logic and use MWHttpRequest when possible.

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);
}