statsd: Rename MediawikiStatsdDataFactory to IBufferingStatsdDataFactory
[lhc/web/wiklou.git] / includes / context / DerivativeContext.php
index 00323ca..0d0c149 100644 (file)
@@ -18,6 +18,8 @@
  * @author Daniel Friesen
  * @file
  */
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
+use MediaWiki\MediaWikiServices;
 
 /**
  * An IContextSource implementation which will inherit context from another source
@@ -26,7 +28,7 @@
  *     a different Title instance set on it.
  * @since 1.19
  */
-class DerivativeContext extends ContextSource {
+class DerivativeContext extends ContextSource implements MutableContext {
        /**
         * @var WebRequest
         */
@@ -67,6 +69,11 @@ class DerivativeContext extends ContextSource {
         */
        private $config;
 
+       /**
+        * @var Timing
+        */
+       private $timing;
+
        /**
         * Constructor
         * @param IContextSource $context Context to inherit from
@@ -100,13 +107,24 @@ class DerivativeContext extends ContextSource {
        /**
         * Get the stats object
         *
-        * @return BufferingStatsdDataFactory
+        * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
+        *
+        * @return IBufferingStatsdDataFactory
         */
        public function getStats() {
-               if ( !is_null( $this->stats ) ) {
-                       return $this->stats;
+               return MediaWikiServices::getInstance()->getStatsdDataFactory();
+       }
+
+       /**
+        * Get the timing object
+        *
+        * @return Timing
+        */
+       public function getTiming() {
+               if ( !is_null( $this->timing ) ) {
+                       return $this->timing;
                } else {
-                       return $this->getContext()->getStats();
+                       return $this->getContext()->getTiming();
                }
        }
 
@@ -306,10 +324,12 @@ class DerivativeContext extends ContextSource {
         * it would set only the original context, and not take
         * into account any changes.
         *
+        * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
+        *   or a MessageSpecifier.
         * @param mixed $args,... Arguments to wfMessage
         * @return Message
         */
-       public function msg() {
+       public function msg( $key ) {
                $args = func_get_args();
 
                return call_user_func_array( 'wfMessage', $args )->setContext( $this );