diff options
author | umherirrender <umherirrender_de.wp@web.de> | 2016-05-23 20:49:21 +0200 |
---|---|---|
committer | umherirrender <umherirrender_de.wp@web.de> | 2016-05-23 21:16:38 +0200 |
commit | 14b888c515b02115aa412696af8e3f85e7beade2 (patch) | |
tree | 931d9ac3edf8d7f7c733b06e7c577fc155eb0f15 /includes/WatchedItemStore.php | |
parent | f826f2f5f6facdce2c92dcb9e70bb0cf20ff9db0 (diff) | |
download | mediawikicore-14b888c515b02115aa412696af8e3f85e7beade2.tar.gz mediawikicore-14b888c515b02115aa412696af8e3f85e7beade2.zip |
Batch updateNotificationTimestamp() UPDATE queries (without wl_id)
The new primary key is not usable in production (T130067), so batch the
query using the old where condition.
Some code ideas from I3dbe1de4cf39499728a2077a71157d4bcc203e44
Bug: T134613
Change-Id: Ic12926a5166f7578a1136c7944d883c2fe1f3b3a
Diffstat (limited to 'includes/WatchedItemStore.php')
-rw-r--r-- | includes/WatchedItemStore.php | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php index f0619d69f50e..6486955fc488 100644 --- a/includes/WatchedItemStore.php +++ b/includes/WatchedItemStore.php @@ -744,15 +744,24 @@ class WatchedItemStore implements StatsdAwareInterface { $fname = __METHOD__; $dbw->onTransactionIdle( function () use ( $dbw, $timestamp, $watchers, $target, $fname ) { - $dbw->update( 'watchlist', - [ /* SET */ - 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp ) - ], [ /* WHERE */ - 'wl_user' => $watchers, - 'wl_namespace' => $target->getNamespace(), - 'wl_title' => $target->getDBkey(), - ], $fname - ); + global $wgUpdateRowsPerQuery; + + $watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery ); + foreach ( $watchersChunks as $watchersChunk ) { + $dbw->update( 'watchlist', + [ /* SET */ + 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp ) + ], [ /* WHERE - TODO Use wl_id T130067 */ + 'wl_user' => $watchersChunk, + 'wl_namespace' => $target->getNamespace(), + 'wl_title' => $target->getDBkey(), + ], $fname + ); + if ( count( $watchersChunks ) > 1 ) { + $dbw->commit( __METHOD__, 'flush' ); + wfGetLBFactory()->waitForReplication( [ 'wiki' => $dbw->getWikiID() ] ); + } + } $this->uncacheLinkTarget( $target ); } ); |