| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Revision; |
| 22 |
|
| 23 |
use Wikimedia\Rdbms\IReadableDatabase; |
| 24 |
use Wikimedia\Rdbms\SelectQueryBuilder; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
class RevisionSelectQueryBuilder extends SelectQueryBuilder { |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public function __construct( IReadableDatabase $db ) { |
| 38 |
parent::__construct( $db ); |
| 39 |
|
| 40 |
$this->select( [ |
| 41 |
'rev_id', |
| 42 |
'rev_page', |
| 43 |
'rev_timestamp', |
| 44 |
'rev_minor_edit', |
| 45 |
'rev_deleted', |
| 46 |
'rev_len', |
| 47 |
'rev_parent_id', |
| 48 |
'rev_sha1', |
| 49 |
'rev_user' => 'actor_rev_user.actor_user', |
| 50 |
'rev_user_text' => 'actor_rev_user.actor_name', |
| 51 |
'rev_actor' => 'rev_actor' |
| 52 |
] ) |
| 53 |
->from( 'revision' ) |
| 54 |
->join( 'actor', 'actor_rev_user', 'actor_rev_user.actor_id = rev_actor' ); |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public function joinUser() { |
| 63 |
$this->field( 'user_name' ) |
| 64 |
->leftJoin( |
| 65 |
'user', |
| 66 |
null, |
| 67 |
[ $this->db->expr( 'actor_rev_user.actor_user', '!=', 0 ), "user_id = actor_rev_user.actor_user" ] |
| 68 |
); |
| 69 |
|
| 70 |
return $this; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
public function joinPage() { |
| 79 |
$this->fields( [ |
| 80 |
'page_namespace', |
| 81 |
'page_title', |
| 82 |
'page_id', |
| 83 |
'page_latest', |
| 84 |
'page_is_redirect', |
| 85 |
'page_len', |
| 86 |
] ) |
| 87 |
->join( 'page', null, 'page_id = rev_page' ); |
| 88 |
|
| 89 |
return $this; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public function joinComment() { |
| 98 |
$this->fields( [ |
| 99 |
'rev_comment_text' => 'comment_rev_comment.comment_text', |
| 100 |
'rev_comment_data' => 'comment_rev_comment.comment_data', |
| 101 |
'rev_comment_cid' => 'comment_rev_comment.comment_id', |
| 102 |
] ); |
| 103 |
$this->join( 'comment', "comment_rev_comment", 'comment_rev_comment.comment_id = rev_comment_id' ); |
| 104 |
return $this; |
| 105 |
} |
| 106 |
} |