X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWatchedItemQueryService.php;h=84972247a661561d35999b9e075b56ca7b000853;hb=3887981320fcc1f06479a39f7fa7cf358845683a;hp=3dcd30f006c9638cd43e2e10b2fd30a776a5ea56;hpb=425090d4eb0b9de89ad6818f40ab8295368f645e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WatchedItemQueryService.php b/includes/WatchedItemQueryService.php index 3dcd30f006..84972247a6 100644 --- a/includes/WatchedItemQueryService.php +++ b/includes/WatchedItemQueryService.php @@ -55,19 +55,11 @@ class WatchedItemQueryService { } /** - * @return DatabaseBase + * @return IDatabase * @throws MWException */ private function getConnection() { - return $this->loadBalancer->getConnection( DB_SLAVE, [ 'watchlist' ] ); - } - - /** - * @param DatabaseBase $connection - * @throws MWException - */ - private function reuseConnection( DatabaseBase $connection ) { - $this->loadBalancer->reuseConnection( $connection ); + return $this->loadBalancer->getConnectionRef( DB_REPLICA, [ 'watchlist' ] ); } /** @@ -181,8 +173,6 @@ class WatchedItemQueryService { $joinConds ); - $this->reuseConnection( $db ); - $items = []; foreach ( $res as $row ) { $items[] = [ @@ -258,8 +248,6 @@ class WatchedItemQueryService { $dbOptions ); - $this->reuseConnection( $db ); - $watchedItems = []; foreach ( $res as $row ) { // todo these could all be cached at some point? @@ -337,7 +325,7 @@ class WatchedItemQueryService { } private function getWatchedItemsWithRCInfoQueryConds( - DatabaseBase $db, + IDatabase $db, User $user, array $options ) { @@ -445,7 +433,7 @@ class WatchedItemQueryService { return $conds; } - private function getStartEndConds( DatabaseBase $db, array $options ) { + private function getStartEndConds( IDatabase $db, array $options ) { if ( !isset( $options['start'] ) && ! isset( $options['end'] ) ) { return []; } @@ -464,7 +452,7 @@ class WatchedItemQueryService { return $conds; } - private function getUserRelatedConds( DatabaseBase $db, User $user, array $options ) { + private function getUserRelatedConds( IDatabase $db, User $user, array $options ) { if ( !array_key_exists( 'onlyByUser', $options ) && !array_key_exists( 'notByUser', $options ) ) { return []; } @@ -491,7 +479,7 @@ class WatchedItemQueryService { return $conds; } - private function getExtraDeletedPageLogEntryRelatedCond( DatabaseBase $db, User $user ) { + private function getExtraDeletedPageLogEntryRelatedCond( IDatabase $db, User $user ) { // LogPage::DELETED_ACTION hides the affected page, too. So hide those // entirely from the watchlist, or someone could guess the title. $bitmask = 0; @@ -509,7 +497,7 @@ class WatchedItemQueryService { return ''; } - private function getStartFromConds( DatabaseBase $db, array $options ) { + private function getStartFromConds( IDatabase $db, array $options ) { $op = $options['dir'] === self::DIR_OLDER ? '<' : '>'; list( $rcTimestamp, $rcId ) = $options['startFrom']; $rcTimestamp = $db->addQuotes( $db->timestamp( $rcTimestamp ) ); @@ -529,7 +517,7 @@ class WatchedItemQueryService { ); } - private function getWatchedItemsForUserQueryConds( DatabaseBase $db, User $user, array $options ) { + private function getWatchedItemsForUserQueryConds( IDatabase $db, User $user, array $options ) { $conds = [ 'wl_user' => $user->getId() ]; if ( $options['namespaceIds'] ) { $conds['wl_namespace'] = array_map( 'intval', $options['namespaceIds'] ); @@ -563,12 +551,12 @@ class WatchedItemQueryService { * Creates a query condition part for getting only items before or after the given link target * (while ordering using $sort mode) * - * @param DatabaseBase $db + * @param IDatabase $db * @param LinkTarget $target * @param string $op comparison operator to use in the conditions * @return string */ - private function getFromUntilTargetConds( DatabaseBase $db, LinkTarget $target, $op ) { + private function getFromUntilTargetConds( IDatabase $db, LinkTarget $target, $op ) { return $db->makeList( [ "wl_namespace $op " . $target->getNamespace(),