Florianschmidtwelzow has uploaded a new change for review.
https://gerrit.wikimedia.org/r/253651
Change subject: RequestContext: Load the request object for getRequest on first
call
......................................................................
RequestContext: Load the request object for getRequest on first call
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.
Bug: T118771
Change-Id: I6115ba44e474619d02d456a103758fe73ed298e0
---
M includes/Setup.php
M includes/context/RequestContext.php
2 files changed, 16 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/51/253651/1
diff --git a/includes/Setup.php b/includes/Setup.php
index bd20ac3..2e37289 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -614,15 +614,13 @@
$wgDBerrorLogTZ = $wgLocaltimezone;
}
+// initialize the request object in $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 ) {
diff --git a/includes/context/RequestContext.php
b/includes/context/RequestContext.php
index 4f8e65d..92b34fe 100644
--- a/includes/context/RequestContext.php
+++ b/includes/context/RequestContext.php
@@ -121,8 +121,19 @@
*/
public function getRequest() {
if ( $this->request === null ) {
- global $wgRequest; # fallback to $wg till we can
improve this
- $this->request = $wgRequest;
+ global $wgRequest, // BackCompat
+ $wgCommandLineMode;
+
+ if ( $wgRequest instanceof WebRequest ) {
+ $this->request = $wgRequest;
+ } else {
+ // create the WebRequest object on the fly
+ if ( $wgCommandLineMode ) {
+ $this->request = $wgRequest = new
FauxRequest( array() );
+ } else {
+ $this->request = $wgRequest = new
WebRequest();
+ }
+ }
}
return $this->request;
--
To view, visit https://gerrit.wikimedia.org/r/253651
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6115ba44e474619d02d456a103758fe73ed298e0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits