[MediaWiki-commits] [Gerrit] RequestContext: Load the request object for getRequest on fi... - change (mediawiki/core)

2016-01-06 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

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.

Change-Id: I6115ba44e474619d02d456a103758fe73ed298e0
---
M includes/Setup.php
M includes/context/RequestContext.php
2 files changed, 10 insertions(+), 7 deletions(-)

Approvals:
  Krinkle: Looks good to me, but someone else must approve
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Setup.php b/includes/Setup.php
index bd20ac3..f72f5ca 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -614,15 +614,13 @@
$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 ) {
diff --git a/includes/context/RequestContext.php 
b/includes/context/RequestContext.php
index 4f8e65d..8c13e97 100644
--- a/includes/context/RequestContext.php
+++ b/includes/context/RequestContext.php
@@ -121,8 +121,13 @@
 */
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;

-- 
To view, visit https://gerrit.wikimedia.org/r/253651
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6115ba44e474619d02d456a103758fe73ed298e0
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow 
Gerrit-Reviewer: Aaron Schulz 
Gerrit-Reviewer: Florianschmidtwelzow 
Gerrit-Reviewer: Krinkle 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: Reedy 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] RequestContext: Load the request object for getRequest on fi... - change (mediawiki/core)

2015-11-17 Thread Florianschmidtwelzow (Code Review)
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 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits