Merge "RequestContext: Load the request object for getRequest on first call"
[lhc/web/wiklou.git] / includes / context / RequestContext.php
index a0073aa..36c644a 100644 (file)
@@ -123,8 +123,13 @@ class RequestContext implements IContextSource, MutableContext {
         */
        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;
@@ -137,10 +142,7 @@ class RequestContext implements IContextSource, MutableContext {
         */
        public function getStats() {
                if ( $this->stats === null ) {
-                       $config = $this->getConfig();
-                       $prefix = $config->get( 'StatsdMetricPrefix' )
-                               ? rtrim( $config->get( 'StatsdMetricPrefix' ), '.' )
-                               : 'MediaWiki';
+                       $prefix = rtrim( $this->getConfig()->get( 'StatsdMetricPrefix' ), '.' );
                        $this->stats = new BufferingStatsdDataFactory( $prefix );
                }
                return $this->stats;