X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWatchedItemStore.php;h=89ca50c00b2efe5b2f083fb62717e2fccae08060;hb=ad631f135d460fb8a5c301f5959257041e6252d2;hp=6486955fc4887c471f9006448c62e14f1bf6144b;hpb=b6e954a1629f28024d30a8e2575fb6de977b5e00;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php index 6486955fc4..89ca50c00b 100644 --- a/includes/WatchedItemStore.php +++ b/includes/WatchedItemStore.php @@ -1,7 +1,6 @@ deferredUpdatesAddCallableUpdateCallback; $this->deferredUpdatesAddCallableUpdateCallback = $callback; return new ScopedCallback( function() use ( $previousValue ) { @@ -106,14 +103,12 @@ class WatchedItemStore implements StatsdAwareInterface { * @return ScopedCallback to reset the overridden value * @throws MWException */ - public function overrideRevisionGetTimestampFromIdCallback( $callback ) { + public function overrideRevisionGetTimestampFromIdCallback( callable $callback ) { if ( !defined( 'MW_PHPUNIT_TEST' ) ) { throw new MWException( 'Cannot override Revision::getTimestampFromId callback in operation.' ); } - Assert::parameterType( 'callable', $callback, '$callback' ); - $previousValue = $this->revisionGetTimestampFromIdCallback; $this->revisionGetTimestampFromIdCallback = $callback; return new ScopedCallback( function() use ( $previousValue ) { @@ -724,28 +719,29 @@ 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 ); + $watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery ); foreach ( $watchersChunks as $watchersChunk ) { $dbw->update( 'watchlist', @@ -763,12 +759,12 @@ class WatchedItemStore implements StatsdAwareInterface { } } $this->uncacheLinkTarget( $target ); + + $this->reuseConnection( $dbw ); } ); } - $this->reuseConnection( $dbw ); - return $watchers; }