Merge "Reject usernames with # as user-type API parameters"
[lhc/web/wiklou.git] / includes / WatchedItemStore.php
index 4f3d640..8ae7932 100644 (file)
@@ -11,7 +11,7 @@ use Wikimedia\Assert\Assert;
  *
  * @since 1.27
  */
-class WatchedItemStore {
+class WatchedItemStore implements StatsdAwareInterface {
 
        const SORT_DESC = 'DESC';
        const SORT_ASC = 'ASC';
@@ -57,20 +57,22 @@ class WatchedItemStore {
        /**
         * @param LoadBalancer $loadBalancer
         * @param HashBagOStuff $cache
-        * @param StatsdDataFactoryInterface $stats
         */
        public function __construct(
                LoadBalancer $loadBalancer,
-               HashBagOStuff $cache,
-               StatsdDataFactoryInterface $stats
+               HashBagOStuff $cache
        ) {
                $this->loadBalancer = $loadBalancer;
                $this->cache = $cache;
-               $this->stats = $stats;
+               $this->stats = new NullStatsdDataFactory();
                $this->deferredUpdatesAddCallableUpdateCallback = [ 'DeferredUpdates', 'addCallableUpdate' ];
                $this->revisionGetTimestampFromIdCallback = [ 'Revision', 'getTimestampFromId' ];
        }
 
+       public function setStatsdDataFactory( StatsdDataFactoryInterface $stats ) {
+               $this->stats = $stats;
+       }
+
        /**
         * Overrides the DeferredUpdates::addCallableUpdate callback
         * This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
@@ -155,9 +157,9 @@ class WatchedItemStore {
                if ( !self::$instance ) {
                        self::$instance = new self(
                                wfGetLB(),
-                               new HashBagOStuff( [ 'maxKeys' => 100 ] ),
-                               RequestContext::getMain()->getStats()
+                               new HashBagOStuff( [ 'maxKeys' => 100 ] )
                        );
+                       self::$instance->setStatsdDataFactory( RequestContext::getMain()->getStats() );
                }
                return self::$instance;
        }