Merge "Clarify release notes for Opera 12.0-12.10 being Grade C"
[lhc/web/wiklou.git] / includes / WatchedItemStore.php
index cc4779e..70fdbf1 100644 (file)
@@ -1,16 +1,22 @@
 <?php
 
+use Wikimedia\Rdbms\IDatabase;
 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
 use MediaWiki\Linker\LinkTarget;
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Assert\Assert;
 use Wikimedia\ScopedCallback;
+use Wikimedia\Rdbms\LoadBalancer;
 
 /**
  * Storage layer class for WatchedItems.
  * Database interaction.
  *
- * @author Addshore
+ * Uses database because this uses User::isAnon
+ *
+ * @group Database
  *
+ * @author Addshore
  * @since 1.27
  */
 class WatchedItemStore implements StatsdAwareInterface {
@@ -668,7 +674,7 @@ class WatchedItemStore implements StatsdAwareInterface {
 
        /**
         * @param User $user The user to set the timestamp for
-        * @param string $timestamp Set the update timestamp to this value
+        * @param string|null $timestamp Set the update timestamp to this value
         * @param LinkTarget[] $targets List of targets to update. Default to all targets
         *
         * @return bool success
@@ -687,9 +693,13 @@ class WatchedItemStore implements StatsdAwareInterface {
                        $conds[] = $batch->constructSet( 'wl', $dbw );
                }
 
+               if ( $timestamp !== null ) {
+                       $timestamp = $dbw->timestamp( $timestamp );
+               }
+
                $success = $dbw->update(
                        'watchlist',
-                       [ 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp ) ],
+                       [ 'wl_notificationtimestamp' => $timestamp ],
                        $conds,
                        __METHOD__
                );
@@ -730,7 +740,7 @@ class WatchedItemStore implements StatsdAwareInterface {
                                        global $wgUpdateRowsPerQuery;
 
                                        $dbw = $this->getConnectionRef( DB_MASTER );
-                                       $factory = wfGetLBFactory();
+                                       $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
                                        $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
 
                                        $watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery );