Instead of relying on the global $wgRequest, which probably isn't initialized
so far, create the request object when RequestContext::getRequest() is called
the first time.
Change-Id: I6115ba44e474619d02d456a103758fe73ed298e0
$wgDBerrorLogTZ = $wgLocaltimezone;
}
+// initialize the request object in $wgRequest
+$wgRequest = RequestContext::getMain()->getRequest(); // BackCompat
+
// Useful debug output
if ( $wgCommandLineMode ) {
- $wgRequest = new FauxRequest( array() );
-
wfDebug( "\n\nStart command line script $self\n" );
} else {
- // Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
- $wgRequest = new WebRequest;
-
$debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
if ( $wgDebugPrintHttpHeaders ) {
*/
public function getRequest() {
if ( $this->request === null ) {
- global $wgRequest; # fallback to $wg till we can improve this
- $this->request = $wgRequest;
+ global $wgCommandLineMode;
+ // create the WebRequest object on the fly
+ if ( $wgCommandLineMode ) {
+ $this->request = new FauxRequest( array() );
+ } else {
+ $this->request = new WebRequest();
+ }
}
return $this->request;