X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWatchedItemQueryService.php;h=d0f45bec171016779236eab031affa3742365d61;hb=f629d095f0469dc9fa29143a8efdc498ee634730;hp=1fafb24dbe323bde5d8e22ba6af599691d184d17;hpb=00cc6ec3ba3de2bfb2873651ddaf06d29addfd55;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WatchedItemQueryService.php b/includes/WatchedItemQueryService.php index 1fafb24dbe..d0f45bec17 100644 --- a/includes/WatchedItemQueryService.php +++ b/includes/WatchedItemQueryService.php @@ -55,6 +55,10 @@ class WatchedItemQueryService { /** @var WatchedItemQueryServiceExtension[]|null */ private $extensions = null; + /** + * @var CommentStore|null */ + private $commentStore = null; + public function __construct( LoadBalancer $loadBalancer ) { $this->loadBalancer = $loadBalancer; } @@ -78,6 +82,13 @@ 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: @@ -172,13 +183,9 @@ class WatchedItemQueryService { ); } - $tables = [ 'recentchanges', 'watchlist' ]; - if ( !$options['allRevisions'] ) { - $tables[] = 'page'; - } - $db = $this->getConnection(); + $tables = $this->getWatchedItemsWithRCInfoQueryTables( $options ); $fields = $this->getWatchedItemsWithRCInfoQueryFields( $options ); $conds = $this->getWatchedItemsWithRCInfoQueryConds( $db, $user, $options ); $dbOptions = $this->getWatchedItemsWithRCInfoQueryDbOptions( $options ); @@ -320,6 +327,17 @@ class WatchedItemQueryService { return array_intersect_key( $allFields, array_flip( $rcKeys ) ); } + private function getWatchedItemsWithRCInfoQueryTables( array $options ) { + $tables = [ 'recentchanges', 'watchlist' ]; + if ( !$options['allRevisions'] ) { + $tables[] = 'page'; + } + if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) { + $tables += $this->getCommentStore()->getJoin()['tables']; + } + return $tables; + } + private function getWatchedItemsWithRCInfoQueryFields( array $options ) { $fields = [ 'rc_id', @@ -355,7 +373,7 @@ class WatchedItemQueryService { $fields[] = 'rc_user'; } if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) { - $fields[] = 'rc_comment'; + $fields += $this->getCommentStore()->getJoin()['fields']; } if ( in_array( self::INCLUDE_PATROL_INFO, $options['includeFields'] ) ) { $fields = array_merge( $fields, [ 'rc_patrolled', 'rc_log_type' ] ); @@ -657,6 +675,9 @@ class WatchedItemQueryService { if ( !$options['allRevisions'] ) { $joinConds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ]; } + if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) { + $joinConds += $this->getCommentStore()->getJoin()['joins']; + } return $joinConds; }