X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_del%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=blobdiff_plain;f=includes%2FWatchedItemStore.php;h=a13609bf5dccbd8ca33afeac444863cba749eee9;hb=c3ba0816e17e880623130fe0b626e963c59fa419;hp=515fbfce86713e83448d2241d917049757261961;hpb=6ba4b76494cbcaba4b991517f8f3588d34672d6e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php index 515fbfce86..a13609bf5d 100644 --- a/includes/WatchedItemStore.php +++ b/includes/WatchedItemStore.php @@ -719,28 +719,31 @@ class WatchedItemStore implements StatsdAwareInterface { */ public function updateNotificationTimestamp( User $editor, LinkTarget $target, $timestamp ) { $dbw = $this->getConnection( DB_MASTER ); - $res = $dbw->select( [ 'watchlist' ], - [ 'wl_user' ], + $uids = $dbw->selectFieldValues( + 'watchlist', + 'wl_user', [ 'wl_user != ' . intval( $editor->getId() ), 'wl_namespace' => $target->getNamespace(), 'wl_title' => $target->getDBkey(), 'wl_notificationtimestamp IS NULL', - ], __METHOD__ + ], + __METHOD__ ); + $this->reuseConnection( $dbw ); - $watchers = []; - foreach ( $res as $row ) { - $watchers[] = intval( $row->wl_user ); - } - + $watchers = array_map( 'intval', $uids ); if ( $watchers ) { // Update wl_notificationtimestamp for all watching users except the editor $fname = __METHOD__; - $dbw->onTransactionIdle( - function () use ( $dbw, $timestamp, $watchers, $target, $fname ) { + DeferredUpdates::addCallableUpdate( + function () use ( $timestamp, $watchers, $target, $fname ) { global $wgUpdateRowsPerQuery; + $dbw = $this->getConnection( DB_MASTER ); + $factory = wfGetLBFactory(); + $ticket = $factory->getEmptyTransactionTicket( __METHOD__ ); + $watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery ); foreach ( $watchersChunks as $watchersChunk ) { $dbw->update( 'watchlist', @@ -753,17 +756,20 @@ class WatchedItemStore implements StatsdAwareInterface { ], $fname ); if ( count( $watchersChunks ) > 1 ) { - $dbw->commit( __METHOD__, 'flush' ); - wfGetLBFactory()->waitForReplication( [ 'wiki' => $dbw->getWikiID() ] ); + $factory->commitAndWaitForReplication( + __METHOD__, $ticket, [ 'wiki' => $dbw->getWikiID() ] + ); } } $this->uncacheLinkTarget( $target ); - } + + $this->reuseConnection( $dbw ); + }, + DeferredUpdates::POSTSEND, + $dbw ); } - $this->reuseConnection( $dbw ); - return $watchers; }