X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fwatcheditem%2FWatchedItemQueryService.php;h=abe9b89fb2a2a001d5cd5b275c28a884d098f25c;hp=3478b0894c9ae16d2b28cc9bdd497626152dc21c;hb=d9c25c2f4776832c0fe3d7be091fd7f776991122;hpb=e69bcfad17d67da5113cdd75276a5f7b5cefb123 diff --git a/includes/watcheditem/WatchedItemQueryService.php b/includes/watcheditem/WatchedItemQueryService.php index 3478b0894c..abe9b89fb2 100644 --- a/includes/watcheditem/WatchedItemQueryService.php +++ b/includes/watcheditem/WatchedItemQueryService.php @@ -56,12 +56,15 @@ class WatchedItemQueryService { /** @var WatchedItemQueryServiceExtension[]|null */ private $extensions = null; - /** - * @var CommentStore|null */ - private $commentStore = null; + /** @var CommentStore */ + private $commentStore; - public function __construct( LoadBalancer $loadBalancer ) { + public function __construct( + LoadBalancer $loadBalancer, + CommentStore $commentStore + ) { $this->loadBalancer = $loadBalancer; + $this->commentStore = $commentStore; } /** @@ -83,13 +86,6 @@ class WatchedItemQueryService { return $this->loadBalancer->getConnectionRef( DB_REPLICA, [ 'watchlist' ] ); } - private function getCommentStore() { - if ( !$this->commentStore ) { - $this->commentStore = new CommentStore( 'rc_comment' ); - } - return $this->commentStore; - } - /** * @param User $user * @param array $options Allowed keys: @@ -334,7 +330,7 @@ class WatchedItemQueryService { $tables[] = 'page'; } if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) { - $tables += $this->getCommentStore()->getJoin()['tables']; + $tables += $this->commentStore->getJoin( 'rc_comment' )['tables']; } if ( in_array( self::INCLUDE_TAGS, $options['includeFields'] ) ) { $tables[] = 'tag_summary'; @@ -377,7 +373,7 @@ class WatchedItemQueryService { $fields[] = 'rc_user'; } if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) { - $fields += $this->getCommentStore()->getJoin()['fields']; + $fields += $this->commentStore->getJoin( 'rc_comment' )['fields']; } if ( in_array( self::INCLUDE_PATROL_INFO, $options['includeFields'] ) ) { $fields = array_merge( $fields, [ 'rc_patrolled', 'rc_log_type' ] ); @@ -684,7 +680,7 @@ class WatchedItemQueryService { $joinConds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ]; } if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) { - $joinConds += $this->getCommentStore()->getJoin()['joins']; + $joinConds += $this->commentStore->getJoin( 'rc_comment' )['joins']; } if ( in_array( self::INCLUDE_TAGS, $options['includeFields'] ) ) { $joinConds['tag_summary'] = [ 'LEFT JOIN', [ 'rc_id=ts_rc_id' ] ];