Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ArchiveSelectQueryBuilder
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
1 / 1
1
 joinComment
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 */
6
7namespace MediaWiki\Revision;
8
9use Wikimedia\Rdbms\IReadableDatabase;
10use Wikimedia\Rdbms\SelectQueryBuilder;
11
12/**
13 * Help and centralize querying archive table.
14 *
15 * @since 1.41
16 */
17class ArchiveSelectQueryBuilder extends SelectQueryBuilder {
18
19    /**
20     * @internal use RevisionStore::newSelectQueryBuilder() instead.
21     * @param IReadableDatabase $db
22     */
23    public function __construct( IReadableDatabase $db ) {
24        parent::__construct( $db );
25
26        $this->select( [
27            'ar_id',
28            'ar_page_id',
29            'ar_namespace',
30            'ar_title',
31            'ar_rev_id',
32            'ar_timestamp',
33            'ar_minor_edit',
34            'ar_deleted',
35            'ar_len',
36            'ar_parent_id',
37            'ar_actor',
38            'ar_user' => 'archive_actor.actor_user',
39            'ar_user_text' => 'archive_actor.actor_name',
40        ] )
41            ->from( 'archive' )
42            ->join( 'actor', 'archive_actor', 'actor_id=ar_actor' );
43    }
44
45    /**
46     * Join the query with comment table and several fields to allow easier query.
47     *
48     * @return $this
49     */
50    public function joinComment() {
51        $this->fields( [
52            'ar_comment_text' => 'comment_ar_comment.comment_text',
53            'ar_comment_data' => 'comment_ar_comment.comment_data',
54            'ar_comment_cid' => 'comment_ar_comment.comment_id',
55        ] );
56        $this->join( 'comment', "comment_ar_comment", 'comment_ar_comment.comment_id = ar_comment_id' );
57        return $this;
58    }
59}