MediaWiki
REL1_37
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
33
public
$mForm
;
34
36
public
$mConds
;
37
39
private
$articleID
;
40
42
private
$maxTimestamp
;
43
45
private
$linkBatchFactory
;
46
48
private
$revisionStore
;
49
59
public
function
__construct
(
60
SpecialMergeHistory
$form,
61
$conds,
62
PageIdentity
$source
,
63
PageIdentity
$dest,
64
LinkBatchFactory
$linkBatchFactory
,
65
ILoadBalancer
$loadBalancer,
66
RevisionStore
$revisionStore
67
) {
68
$this->mForm = $form;
69
$this->mConds = $conds;
70
$this->articleID =
$source
->getId();
71
72
$dbr
= $loadBalancer->
getConnectionRef
( ILoadBalancer::DB_REPLICA );
73
$maxtimestamp =
$dbr
->selectField(
74
'revision'
,
75
'MIN(rev_timestamp)'
,
76
[
'rev_page'
=> $dest->
getId
() ],
77
__METHOD__
78
);
79
$this->maxTimestamp = $maxtimestamp;
80
81
// Set database before parent constructor to avoid setting it there with wfGetDB
82
$this->mDb =
$dbr
;
83
parent::__construct( $form->
getContext
() );
84
$this->linkBatchFactory =
$linkBatchFactory
;
85
$this->revisionStore =
$revisionStore
;
86
}
87
88
protected
function
getStartBody
() {
89
# Do a link batch query
90
$this->mResult->seek( 0 );
91
$batch = $this->linkBatchFactory->newLinkBatch();
92
# Give some pointers to make (last) links
93
$this->mForm->prevId = [];
94
$rev_id =
null
;
95
foreach
( $this->mResult as $row ) {
96
$batch->add(
NS_USER
, $row->rev_user_text );
97
$batch->add(
NS_USER_TALK
, $row->rev_user_text );
98
99
if
( isset( $rev_id ) ) {
100
if
( $rev_id > $row->rev_id ) {
101
$this->mForm->prevId[$rev_id] = $row->rev_id;
102
} elseif ( $rev_id < $row->rev_id ) {
103
$this->mForm->prevId[$row->rev_id] = $rev_id;
104
}
105
}
106
107
$rev_id = $row->rev_id;
108
}
109
110
$batch->execute();
111
$this->mResult->seek( 0 );
112
113
return
''
;
114
}
115
116
public
function
formatRow
( $row ) {
117
return
$this->mForm->formatRevisionRow( $row );
118
}
119
120
public
function
getQueryInfo
() {
121
$dbr
= $this->
getDatabase
();
122
$conds =
$this->mConds
;
123
$conds[
'rev_page'
] =
$this->articleID
;
124
$conds[] =
"rev_timestamp < "
.
$dbr
->addQuotes( $this->maxTimestamp );
125
126
$revQuery
= $this->revisionStore->getQueryInfo( [
'page'
,
'user'
] );
127
return
[
128
'tables'
=>
$revQuery
[
'tables'
],
129
'fields'
=>
$revQuery
[
'fields'
],
130
'conds'
=> $conds,
131
'join_conds'
=>
$revQuery
[
'joins'
]
132
];
133
}
134
135
public
function
getIndexField
() {
136
return
'rev_timestamp'
;
137
}
138
}
NS_USER
const NS_USER
Definition
Defines.php:66
NS_USER_TALK
const NS_USER_TALK
Definition
Defines.php:67
IndexPager\getDatabase
getDatabase()
Get the Database object in use.
Definition
IndexPager.php:246
MediaWiki\Cache\LinkBatchFactory
Definition
LinkBatchFactory.php:39
MediaWiki\Revision\RevisionStore
Service for looking up page revisions.
Definition
RevisionStore.php:88
MergeHistoryPager
Definition
MergeHistoryPager.php:30
MergeHistoryPager\$mForm
SpecialMergeHistory $mForm
Definition
MergeHistoryPager.php:33
MergeHistoryPager\getStartBody
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
Definition
MergeHistoryPager.php:88
MergeHistoryPager\formatRow
formatRow( $row)
Returns an HTML string representing the result row $row.
Definition
MergeHistoryPager.php:116
MergeHistoryPager\getQueryInfo
getQueryInfo()
Provides all parameters needed for the main paged query.
Definition
MergeHistoryPager.php:120
MergeHistoryPager\$articleID
int $articleID
Definition
MergeHistoryPager.php:39
MergeHistoryPager\$mConds
array $mConds
Definition
MergeHistoryPager.php:36
MergeHistoryPager\$maxTimestamp
int $maxTimestamp
Definition
MergeHistoryPager.php:42
MergeHistoryPager\__construct
__construct(SpecialMergeHistory $form, $conds, PageIdentity $source, PageIdentity $dest, LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer, RevisionStore $revisionStore)
Definition
MergeHistoryPager.php:59
MergeHistoryPager\$linkBatchFactory
LinkBatchFactory $linkBatchFactory
Definition
MergeHistoryPager.php:45
MergeHistoryPager\getIndexField
getIndexField()
Returns the name of the index field.
Definition
MergeHistoryPager.php:135
MergeHistoryPager\$revisionStore
RevisionStore $revisionStore
Definition
MergeHistoryPager.php:48
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:764
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
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition
ILoadBalancer.php:81
Wikimedia\Rdbms\ILoadBalancer\getConnectionRef
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Get a live database handle reference for a server index.
$source
$source
Definition
mwdoc-filter.php:34
$dbr
$dbr
Definition
testCompression.php:54
$revQuery
$revQuery
Definition
testCompression.php:56
includes
specials
pagers
MergeHistoryPager.php
Generated on Fri Apr 5 2024 23:40:57 for MediaWiki by
1.9.8