"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "includes/watcheditem/WatchedItemStore.php" between
mediawiki-1.31.1.tar.gz and mediawiki-1.32.0.tar.gz

About: MediaWiki is a wiki engine (the collaborative editing software that runs for e.g. Wikipedia, the free encyclopedia).

WatchedItemStore.php  (mediawiki-1.31.1):WatchedItemStore.php  (mediawiki-1.32.0)
<?php <?php
use Wikimedia\Rdbms\IDatabase; use Wikimedia\Rdbms\IDatabase;
use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface; use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
use MediaWiki\Linker\LinkTarget; use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
use Wikimedia\Assert\Assert; use Wikimedia\Assert\Assert;
use Wikimedia\ScopedCallback; use Wikimedia\ScopedCallback;
use Wikimedia\Rdbms\ILBFactory;
use Wikimedia\Rdbms\LoadBalancer; use Wikimedia\Rdbms\LoadBalancer;
/** /**
* Storage layer class for WatchedItems. * Storage layer class for WatchedItems.
* Database interaction & caching * Database interaction & caching
* TODO caching should be factored out into a CachingWatchedItemStore class * TODO caching should be factored out into a CachingWatchedItemStore class
* *
* @author Addshore * @author Addshore
* @since 1.27 * @since 1.27
*/ */
class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac e { class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac e {
/** /**
* @var ILBFactory
*/
private $lbFactory;
/**
* @var LoadBalancer * @var LoadBalancer
*/ */
private $loadBalancer; private $loadBalancer;
/** /**
* @var ReadOnlyMode * @var ReadOnlyMode
*/ */
private $readOnlyMode; private $readOnlyMode;
/** /**
skipping to change at line 65 skipping to change at line 70
* @var int * @var int
*/ */
private $updateRowsPerQuery; private $updateRowsPerQuery;
/** /**
* @var StatsdDataFactoryInterface * @var StatsdDataFactoryInterface
*/ */
private $stats; private $stats;
/** /**
* @param LoadBalancer $loadBalancer * @param ILBFactory $lbFactory
* @param HashBagOStuff $cache * @param HashBagOStuff $cache
* @param ReadOnlyMode $readOnlyMode * @param ReadOnlyMode $readOnlyMode
* @param int $updateRowsPerQuery * @param int $updateRowsPerQuery
*/ */
public function __construct( public function __construct(
LoadBalancer $loadBalancer, ILBFactory $lbFactory,
HashBagOStuff $cache, HashBagOStuff $cache,
ReadOnlyMode $readOnlyMode, ReadOnlyMode $readOnlyMode,
$updateRowsPerQuery $updateRowsPerQuery
) { ) {
$this->loadBalancer = $loadBalancer; $this->lbFactory = $lbFactory;
$this->loadBalancer = $lbFactory->getMainLB();
$this->cache = $cache; $this->cache = $cache;
$this->readOnlyMode = $readOnlyMode; $this->readOnlyMode = $readOnlyMode;
$this->stats = new NullStatsdDataFactory(); $this->stats = new NullStatsdDataFactory();
$this->deferredUpdatesAddCallableUpdateCallback = $this->deferredUpdatesAddCallableUpdateCallback =
[ DeferredUpdates::class, 'addCallableUpdate' ]; [ DeferredUpdates::class, 'addCallableUpdate' ];
$this->revisionGetTimestampFromIdCallback = $this->revisionGetTimestampFromIdCallback =
[ Revision::class, 'getTimestampFromId' ]; [ Revision::class, 'getTimestampFromId' ];
$this->updateRowsPerQuery = $updateRowsPerQuery; $this->updateRowsPerQuery = $updateRowsPerQuery;
} }
skipping to change at line 410 skipping to change at line 416
/** /**
* @since 1.27 * @since 1.27
* @param array $targetsWithVisitThresholds * @param array $targetsWithVisitThresholds
* @param int|null $minimumWatchers * @param int|null $minimumWatchers
* @return array * @return array
*/ */
public function countVisitingWatchersMultiple( public function countVisitingWatchersMultiple(
array $targetsWithVisitThresholds, array $targetsWithVisitThresholds,
$minimumWatchers = null $minimumWatchers = null
) { ) {
if ( $targetsWithVisitThresholds === [] ) {
// No titles requested => no results returned
return [];
}
$dbr = $this->getConnectionRef( DB_REPLICA ); $dbr = $this->getConnectionRef( DB_REPLICA );
$conds = $this->getVisitingWatchersCondition( $dbr, $targetsWithV isitThresholds ); $conds = $this->getVisitingWatchersCondition( $dbr, $targetsWithV isitThresholds );
$dbOptions = [ 'GROUP BY' => [ 'wl_namespace', 'wl_title' ] ]; $dbOptions = [ 'GROUP BY' => [ 'wl_namespace', 'wl_title' ] ];
if ( $minimumWatchers !== null ) { if ( $minimumWatchers !== null ) {
$dbOptions['HAVING'] = 'COUNT(*) >= ' . (int)$minimumWatc hers; $dbOptions['HAVING'] = 'COUNT(*) >= ' . (int)$minimumWatc hers;
} }
$res = $dbr->select( $res = $dbr->select(
'watchlist', 'watchlist',
skipping to change at line 817 skipping to change at line 828
], ],
__METHOD__ __METHOD__
); );
$watchers = array_map( 'intval', $uids ); $watchers = array_map( 'intval', $uids );
if ( $watchers ) { if ( $watchers ) {
// Update wl_notificationtimestamp for all watching users except the editor // Update wl_notificationtimestamp for all watching users except the editor
$fname = __METHOD__; $fname = __METHOD__;
DeferredUpdates::addCallableUpdate( DeferredUpdates::addCallableUpdate(
function () use ( $timestamp, $watchers, $target, $fname ) { function () use ( $timestamp, $watchers, $target, $fname ) {
global $wgUpdateRowsPerQuery;
$dbw = $this->getConnectionRef( DB_MASTER ); $dbw = $this->getConnectionRef( DB_MASTER );
$factory = MediaWikiServices::getInstance $ticket = $this->lbFactory->getEmptyTrans
()->getDBLoadBalancerFactory(); actionTicket( $fname );
$ticket = $factory->getEmptyTransactionTi
cket( __METHOD__ );
$watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery ); $watchersChunks = array_chunk( $watchers, $this->updateRowsPerQuery );
foreach ( $watchersChunks as $watchersChu nk ) { foreach ( $watchersChunks as $watchersChu nk ) {
$dbw->update( 'watchlist', $dbw->update( 'watchlist',
[ /* SET */ [ /* SET */
'wl_notificationt imestamp' => $dbw->timestamp( $timestamp ) 'wl_notificationt imestamp' => $dbw->timestamp( $timestamp )
], [ /* WHERE - TODO Use wl_id T130067 */ ], [ /* WHERE - TODO Use wl_id T130067 */
'wl_user' => $wat chersChunk, 'wl_user' => $wat chersChunk,
'wl_namespace' => $target->getNamespace(), 'wl_namespace' => $target->getNamespace(),
'wl_title' => $ta rget->getDBkey(), 'wl_title' => $ta rget->getDBkey(),
], $fname ], $fname
); );
if ( count( $watchersChunks ) > 1 ) { if ( count( $watchersChunks ) > 1 ) {
$factory->commitAndWaitFo $this->lbFactory->commitA
rReplication( ndWaitForReplication(
__METHOD__, $tick $fname, $ticket,
et, [ 'domain' => $dbw->getDomainID() ] [ 'domain' => $dbw->getDomainID() ]
); );
} }
} }
$this->uncacheLinkTarget( $target ); $this->uncacheLinkTarget( $target );
}, },
DeferredUpdates::POSTSEND, DeferredUpdates::POSTSEND,
$dbw $dbw
); );
} }
 End of changes. 11 change blocks. 
15 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)