dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "RequestContext: Load the request object for getRequest on first call"
[lhc/web/wiklou.git]
/
includes
/
context
/
RequestContext.php
diff --git
a/includes/context/RequestContext.php
b/includes/context/RequestContext.php
index
42a2aee
..
36c644a
100644
(file)
--- a/
includes/context/RequestContext.php
+++ b/
includes/context/RequestContext.php
@@
-22,6
+22,8
@@
* @file
*/
* @file
*/
+use MediaWiki\Logger\LoggerFactory;
+
/**
* Group all the pieces relevant to the context of a request into one instance
*/
/**
* Group all the pieces relevant to the context of a request into one instance
*/
@@
-66,6
+68,11
@@
class RequestContext implements IContextSource, MutableContext {
*/
private $stats;
*/
private $stats;
+ /**
+ * @var Timing
+ */
+ private $timing;
+
/**
* @var Config
*/
/**
* @var Config
*/
@@
-116,8
+123,13
@@
class RequestContext implements IContextSource, MutableContext {
*/
public function getRequest() {
if ( $this->request === null ) {
*/
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;
}
return $this->request;
@@
-130,15
+142,26
@@
class RequestContext implements IContextSource, MutableContext {
*/
public function getStats() {
if ( $this->stats === null ) {
*/
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;
}
$this->stats = new BufferingStatsdDataFactory( $prefix );
}
return $this->stats;
}
+ /**
+ * Get the timing object
+ *
+ * @return Timing
+ */
+ public function getTiming() {
+ if ( $this->timing === null ) {
+ $this->timing = new Timing( array(
+ 'logger' => LoggerFactory::getInstance( 'Timing' )
+ ) );
+ }
+ return $this->timing;
+ }
+
/**
* Set the Title object
*
/**
* Set the Title object
*