X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=blobdiff_plain;f=includes%2Fwatcheditem%2FWatchedItemStore.php;h=85668959d0338944ca3e18a8070e255c80442f10;hb=70d9fbb0bfacaf837b7e8efb3770245d646ab522;hp=f9435a1b0e7947129af2f7f289d1ddc6def1a5c7;hpb=a479750da672066b4189b115d1141a23d8c5cae3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/watcheditem/WatchedItemStore.php b/includes/watcheditem/WatchedItemStore.php index f9435a1b0e..85668959d0 100644 --- a/includes/watcheditem/WatchedItemStore.php +++ b/includes/watcheditem/WatchedItemStore.php @@ -4,7 +4,6 @@ use Wikimedia\Rdbms\IDatabase; use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface; use MediaWiki\Linker\LinkTarget; use Wikimedia\Assert\Assert; -use Wikimedia\Rdbms\LBFactory; use Wikimedia\ScopedCallback; use Wikimedia\Rdbms\ILBFactory; use Wikimedia\Rdbms\LoadBalancer; @@ -389,7 +388,8 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac $this->uncacheTitlesForUser( $user, $titles ); $dbw = $this->getConnectionRef( DB_MASTER ); - $ticket = $this->lbFactory->getEmptyTransactionTicket( __METHOD__ ); + $ticket = count( $titles ) > $this->updateRowsPerQuery ? + $this->lbFactory->getEmptyTransactionTicket( __METHOD__ ) : null; $affectedRows = 0; // Batch delete items per namespace. @@ -402,7 +402,9 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac 'wl_title' => $toDelete ], __METHOD__ ); $affectedRows += $dbw->affectedRows(); - $this->lbFactory->commitAndWaitForReplication( __METHOD__, $ticket ); + if ( $ticket ) { + $this->lbFactory->commitAndWaitForReplication( __METHOD__, $ticket ); + } } } @@ -714,7 +716,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac if ( $this->readOnlyMode->isReadOnly() ) { return false; } - // Only loggedin user can have a watchlist + // Only logged-in user can have a watchlist if ( $user->isAnon() ) { return false; } @@ -741,7 +743,8 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac } $dbw = $this->getConnectionRef( DB_MASTER ); - $ticket = $this->lbFactory->getEmptyTransactionTicket( __METHOD__ ); + $ticket = count( $targets ) > $this->updateRowsPerQuery ? + $this->lbFactory->getEmptyTransactionTicket( __METHOD__ ) : null; $affectedRows = 0; $rowBatches = array_chunk( $rows, $this->updateRowsPerQuery ); foreach ( $rowBatches as $toInsert ) { @@ -749,7 +752,9 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac // if there's already an entry for this page $dbw->insert( 'watchlist', $toInsert, __METHOD__, 'IGNORE' ); $affectedRows += $dbw->affectedRows(); - $this->lbFactory->commitAndWaitForReplication( __METHOD__, $ticket ); + if ( $ticket ) { + $this->lbFactory->commitAndWaitForReplication( __METHOD__, $ticket ); + } } // Update process cache to ensure skin doesn't claim that the current // page is unwatched in the response of action=watch itself (T28292). @@ -902,6 +907,10 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac return false; } + if ( ! Hooks::run( 'BeforeResetNotificationTimestamp', [ &$user, &$title, $force, &$oldid ] ) ) { + return false; + } + $item = null; if ( $force != 'force' ) { $item = $this->loadWatchedItem( $user, $title );