1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
<?php
use MediaWiki\Cache\LinkBatchFactory;
use Wikimedia\Rdbms\IResultWrapper;
class AbuseLogPager extends ReverseChronologicalPager {
/**
* @var SpecialAbuseLog
*/
public $mForm;
/**
* @var array
*/
public $mConds;
/** @var LinkBatchFactory */
private $linkBatchFactory;
/** @var bool */
private $joinWithArchive;
/**
* @param SpecialAbuseLog $form
* @param array $conds
* @param LinkBatchFactory $linkBatchFactory
* @param bool $joinWithArchive
*/
public function __construct(
SpecialAbuseLog $form,
array $conds,
LinkBatchFactory $linkBatchFactory,
bool $joinWithArchive = false
) {
parent::__construct( $form->getContext(), $form->getLinkRenderer() );
$this->mForm = $form;
$this->mConds = $conds;
$this->linkBatchFactory = $linkBatchFactory;
$this->joinWithArchive = $joinWithArchive;
}
/**
* @param object $row
* @return string
*/
public function formatRow( $row ) {
return $this->mForm->formatRow( $row );
}
/**
* @return array
*/
public function getQueryInfo() {
$conds = $this->mConds;
$info = [
'tables' => [ 'abuse_filter_log', 'abuse_filter', 'revision' ],
'fields' => [
$this->mDb->tableName( 'abuse_filter_log' ) . '.*',
$this->mDb->tableName( 'abuse_filter' ) . '.*',
'rev_id',
],
'conds' => $conds,
'join_conds' => [
'abuse_filter' => [
'LEFT JOIN',
'af_id=afl_filter',
],
'revision' => [
'LEFT JOIN',
[
'afl_wiki IS NULL',
'afl_rev_id IS NOT NULL',
'rev_id=afl_rev_id',
]
],
],
];
if ( $this->joinWithArchive ) {
$info['tables'][] = 'archive';
$info['fields'][] = 'ar_timestamp';
$info['join_conds']['archive'] = [
'LEFT JOIN',
[
'afl_wiki IS NULL',
'afl_rev_id IS NOT NULL',
'rev_id IS NULL',
'ar_rev_id=afl_rev_id',
]
];
}
if ( !$this->mForm->canSeeHidden( $this->getUser() ) ) {
$info['conds']['afl_deleted'] = 0;
}
return $info;
}
/**
* @param IResultWrapper $result
*/
protected function preprocessResults( $result ) {
if ( $this->getNumRows() === 0 ) {
return;
}
$lb = $this->linkBatchFactory->newLinkBatch();
$lb->setCaller( __METHOD__ );
foreach ( $result as $row ) {
// Only for local wiki results
if ( !$row->afl_wiki ) {
$lb->add( $row->afl_namespace, $row->afl_title );
$lb->add( NS_USER, $row->afl_user );
$lb->add( NS_USER_TALK, $row->afl_user_text );
}
}
$lb->execute();
$result->seek( 0 );
}
/**
* @return string
*/
public function getIndexField() {
return 'afl_timestamp';
}
}
|