Merge "ResourceLoaderOOUIImageModule: Actually load non-default themes' images"
[lhc/web/wiklou.git] / includes / context / ContextSource.php
index df5f71c..135c9b2 100644 (file)
@@ -18,6 +18,8 @@
  * @author Happy-melon
  * @file
  */
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
+use MediaWiki\MediaWikiServices;
 
 /**
  * The simplest way of implementing IContextSource is to hold a RequestContext as a
@@ -38,7 +40,7 @@ abstract class ContextSource implements IContextSource {
         */
        public function getContext() {
                if ( $this->context === null ) {
-                       $class = get_class( $this );
+                       $class = static::class;
                        wfDebug( __METHOD__ . " ($class): called and \$context is null. " .
                                "Using RequestContext::getMain() for sanity\n" );
                        $this->context = RequestContext::getMain();
@@ -165,11 +167,13 @@ abstract class ContextSource implements IContextSource {
        /**
         * Get the Stats object
         *
+        * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
+        *
         * @since 1.25
-        * @return BufferingStatsdDataFactory
+        * @return StatsdDataFactory
         */
        public function getStats() {
-               return $this->getContext()->getStats();
+               return MediaWikiServices::getInstance()->getStatsdDataFactory();
        }
 
        /**
@@ -183,7 +187,7 @@ abstract class ContextSource implements IContextSource {
        public function msg( /* $args */ ) {
                $args = func_get_args();
 
-               return call_user_func_array( array( $this->getContext(), 'msg' ), $args );
+               return call_user_func_array( [ $this->getContext(), 'msg' ], $args );
        }
 
        /**