MediaWiki
REL1_39
MergeHistoryPager.php
Go to the documentation of this file.
1
<?php
22
use
MediaWiki\Cache\LinkBatchFactory
;
23
use
MediaWiki\Page\PageIdentity
;
24
use
MediaWiki\Revision\RevisionStore
;
25
use
Wikimedia\Rdbms\ILoadBalancer
;
26
30
class
MergeHistoryPager
extends
ReverseChronologicalPager
{
31
32
public
$mGroupByDate
=
true
;
33
35
public
$mForm
;
36
38
public
$mConds
;
39
41
private
$articleID;
42
44
private
$maxTimestamp;
45
47
private
$linkBatchFactory;
48
50
private
$revisionStore;
51
61
public
function
__construct
(
62
SpecialMergeHistory
$form,
63
LinkBatchFactory
$linkBatchFactory,
64
ILoadBalancer
$loadBalancer,
65
RevisionStore
$revisionStore,
66
$conds,
67
PageIdentity
$source
,
68
PageIdentity
$dest
69
) {
70
$this->mForm = $form;
71
$this->mConds = $conds;
72
$this->articleID =
$source
->getId();
73
74
$dbr
= $loadBalancer->
getConnectionRef
( ILoadBalancer::DB_REPLICA );
75
$maxtimestamp =
$dbr
->selectField(
76
'revision'
,
77
'MIN(rev_timestamp)'
,
78
[
'rev_page'
=> $dest->
getId
() ],
79
__METHOD__
80
);
81
$this->maxTimestamp = $maxtimestamp;
82
83
// Set database before parent constructor to avoid setting it there with wfGetDB
84
$this->mDb =
$dbr
;
85
parent::__construct( $form->
getContext
() );
86
$this->linkBatchFactory = $linkBatchFactory;
87
$this->revisionStore = $revisionStore;
88
}
89
90
protected
function
doBatchLookups
() {
91
# Do a link batch query
92
$this->mResult->seek( 0 );
93
$batch = $this->linkBatchFactory->newLinkBatch();
94
# Give some pointers to make (last) links
95
$this->mForm->prevId = [];
96
$rev_id =
null
;
97
foreach
( $this->mResult as $row ) {
98
$batch->add(
NS_USER
, $row->rev_user_text );
99
$batch->add(
NS_USER_TALK
, $row->rev_user_text );
100
101
if
( isset( $rev_id ) ) {
102
if
( $rev_id > $row->rev_id ) {
103
$this->mForm->prevId[$rev_id] = $row->rev_id;
104
} elseif ( $rev_id < $row->rev_id ) {
105
$this->mForm->prevId[$row->rev_id] = $rev_id;
106
}
107
}
108
109
$rev_id = $row->rev_id;
110
}
111
112
$batch->execute();
113
$this->mResult->seek( 0 );
114
}
115
119
protected
function
getStartBody
() {
120
return
"<section class='mw-pager-body'>\n"
;
121
}
122
126
protected
function
getEndBody
() {
127
return
"</section>\n"
;
128
}
129
130
public
function
formatRow
( $row ) {
131
return
$this->mForm->formatRevisionRow( $row );
132
}
133
134
public
function
getQueryInfo
() {
135
$dbr
= $this->
getDatabase
();
136
$conds =
$this->mConds
;
137
$conds[
'rev_page'
] = $this->articleID;
138
$conds[] =
"rev_timestamp < "
.
$dbr
->addQuotes( $this->maxTimestamp );
139
140
$queryInfo = $this->revisionStore->getQueryInfo( [
'page'
,
'user'
] );
141
$queryInfo[
'conds'
] = $conds;
142
$queryInfo[
'options'
] = [];
143
144
// rename the "joins" field to "join_conds" as expected by the base class.
145
$queryInfo[
'join_conds'
] = $queryInfo[
'joins'
];
146
unset( $queryInfo[
'joins'
] );
147
148
ChangeTags::modifyDisplayQuery
(
149
$queryInfo[
'tables'
],
150
$queryInfo[
'fields'
],
151
$queryInfo[
'conds'
],
152
$queryInfo[
'join_conds'
],
153
$queryInfo[
'options'
],
154
''
155
);
156
157
return
$queryInfo;
158
}
159
160
public
function
getIndexField
() {
161
return
'rev_timestamp'
;
162
}
163
}
NS_USER
const NS_USER
Definition
Defines.php:66
NS_USER_TALK
const NS_USER_TALK
Definition
Defines.php:67
ChangeTags\modifyDisplayQuery
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='', bool $exclude=false)
Applies all tags-related changes to a query.
Definition
ChangeTags.php:906
IndexPager\getDatabase
getDatabase()
Get the Database object in use.
Definition
IndexPager.php:249
MediaWiki\Cache\LinkBatchFactory
Definition
LinkBatchFactory.php:41
MediaWiki\Revision\RevisionStore
Service for looking up page revisions.
Definition
RevisionStore.php:89
MergeHistoryPager
Definition
MergeHistoryPager.php:30
MergeHistoryPager\$mForm
SpecialMergeHistory $mForm
Definition
MergeHistoryPager.php:35
MergeHistoryPager\getStartBody
getStartBody()
Hook into getBody(), allows text to be inserted at the start.This will be called even if there are no...
Definition
MergeHistoryPager.php:119
MergeHistoryPager\doBatchLookups
doBatchLookups()
Called from getBody(), before getStartBody() is called and after doQuery() was called.
Definition
MergeHistoryPager.php:90
MergeHistoryPager\formatRow
formatRow( $row)
Returns an HTML string representing the result row $row.
Definition
MergeHistoryPager.php:130
MergeHistoryPager\getQueryInfo
getQueryInfo()
Provides all parameters needed for the main paged query.
Definition
MergeHistoryPager.php:134
MergeHistoryPager\getEndBody
getEndBody()
Hook into getBody() for the end of the list.to overridestring
Definition
MergeHistoryPager.php:126
MergeHistoryPager\$mConds
array $mConds
Definition
MergeHistoryPager.php:38
MergeHistoryPager\__construct
__construct(SpecialMergeHistory $form, LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer, RevisionStore $revisionStore, $conds, PageIdentity $source, PageIdentity $dest)
Definition
MergeHistoryPager.php:61
MergeHistoryPager\getIndexField
getIndexField()
Returns the name of the index field.
Definition
MergeHistoryPager.php:160
MergeHistoryPager\$mGroupByDate
$mGroupByDate
Definition
MergeHistoryPager.php:32
ReverseChronologicalPager
Efficient paging for SQL queries.
Definition
ReverseChronologicalPager.php:29
SpecialMergeHistory
Special page allowing users with the appropriate permissions to merge article histories,...
Definition
SpecialMergeHistory.php:36
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition
SpecialPage.php:836
MediaWiki\Page\PageIdentity
Interface for objects (potentially) representing an editable wiki page.
Definition
PageIdentity.php:64
MediaWiki\Page\PageIdentity\getId
getId( $wikiId=self::LOCAL)
Returns the page ID.
Wikimedia\Rdbms\ILoadBalancer
Create and track the database connections and transactions for a given database cluster.
Definition
ILoadBalancer.php:77
Wikimedia\Rdbms\ILoadBalancer\getConnectionRef
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)
$source
$source
Definition
mwdoc-filter.php:34
$dbr
$dbr
Definition
testCompression.php:54
includes
specials
pagers
MergeHistoryPager.php
Generated on Thu Nov 21 2024 05:24:17 for MediaWiki by
1.10.0