<?php
use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
-use MediaWiki\MediaWikiServices;
use MediaWiki\Linker\LinkTarget;
use Wikimedia\Assert\Assert;
* @return ScopedCallback to reset the overridden value
* @throws MWException
*/
- public function overrideDeferredUpdatesAddCallableUpdateCallback( $callback ) {
+ public function overrideDeferredUpdatesAddCallableUpdateCallback( callable $callback ) {
if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
throw new MWException(
'Cannot override DeferredUpdates::addCallableUpdate callback in operation.'
);
}
- Assert::parameterType( 'callable', $callback, '$callback' );
-
$previousValue = $this->deferredUpdatesAddCallableUpdateCallback;
$this->deferredUpdatesAddCallableUpdateCallback = $callback;
return new ScopedCallback( function() use ( $previousValue ) {
* @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 ) {
$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 );
}
);