MediaWiki
REL1_35
MergeHistoryPager.php
Go to the documentation of this file.
1
<?php
22
use
MediaWiki\MediaWikiServices
;
23
27
class
MergeHistoryPager
extends
ReverseChronologicalPager
{
28
30
public
$mForm
;
31
33
public
$mConds
;
34
36
private
$articleID
;
37
39
private
$maxTimestamp
;
40
41
public
function
__construct
(
SpecialMergeHistory
$form, $conds,
Title
$source
,
Title
$dest ) {
42
$this->mForm = $form;
43
$this->mConds = $conds;
44
$this->articleID =
$source
->getArticleID();
45
46
$dbr
=
wfGetDB
(
DB_REPLICA
);
47
$maxtimestamp =
$dbr
->selectField(
48
'revision'
,
49
'MIN(rev_timestamp)'
,
50
[
'rev_page'
=> $dest->
getArticleID
() ],
51
__METHOD__
52
);
53
$this->maxTimestamp = $maxtimestamp;
54
55
parent::__construct( $form->
getContext
() );
56
}
57
58
protected
function
getStartBody
() {
59
# Do a link batch query
60
$this->mResult->seek( 0 );
61
$batch =
new
LinkBatch
();
62
# Give some pointers to make (last) links
63
$this->mForm->prevId = [];
64
$rev_id =
null
;
65
foreach
( $this->mResult as $row ) {
66
$batch->addObj( Title::makeTitleSafe(
NS_USER
, $row->user_name ) );
67
$batch->addObj( Title::makeTitleSafe(
NS_USER_TALK
, $row->user_name ) );
68
69
if
( isset( $rev_id ) ) {
70
if
( $rev_id > $row->rev_id ) {
71
$this->mForm->prevId[$rev_id] = $row->rev_id;
72
} elseif ( $rev_id < $row->rev_id ) {
73
$this->mForm->prevId[$row->rev_id] = $rev_id;
74
}
75
}
76
77
$rev_id = $row->rev_id;
78
}
79
80
$batch->execute();
81
$this->mResult->seek( 0 );
82
83
return
''
;
84
}
85
86
public
function
formatRow
( $row ) {
87
return
$this->mForm->formatRevisionRow( $row );
88
}
89
90
public
function
getQueryInfo
() {
91
$conds =
$this->mConds
;
92
$conds[
'rev_page'
] =
$this->articleID
;
93
$conds[] =
"rev_timestamp < "
. $this->mDb->addQuotes( $this->maxTimestamp );
94
95
// TODO inject a RevisionStore into SpecialMergeHistory and pass it to
96
// the MergeHistoryPager constructor
97
$revQuery
= MediaWikiServices::getInstance()
98
->getRevisionStore()
99
->getQueryInfo( [
'page'
,
'user'
] );
100
return
[
101
'tables'
=>
$revQuery
[
'tables'
],
102
'fields'
=>
$revQuery
[
'fields'
],
103
'conds'
=> $conds,
104
'join_conds'
=>
$revQuery
[
'joins'
]
105
];
106
}
107
108
public
function
getIndexField
() {
109
return
'rev_timestamp'
;
110
}
111
}
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition
GlobalFunctions.php:2462
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition
LinkBatch.php:35
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition
MediaWikiServices.php:152
MergeHistoryPager
Definition
MergeHistoryPager.php:27
MergeHistoryPager\$mForm
SpecialMergeHistory $mForm
Definition
MergeHistoryPager.php:30
MergeHistoryPager\getStartBody
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
Definition
MergeHistoryPager.php:58
MergeHistoryPager\formatRow
formatRow( $row)
Returns an HTML string representing the result row $row.
Definition
MergeHistoryPager.php:86
MergeHistoryPager\getQueryInfo
getQueryInfo()
Provides all parameters needed for the main paged query.
Definition
MergeHistoryPager.php:90
MergeHistoryPager\$articleID
int $articleID
Definition
MergeHistoryPager.php:36
MergeHistoryPager\__construct
__construct(SpecialMergeHistory $form, $conds, Title $source, Title $dest)
Definition
MergeHistoryPager.php:41
MergeHistoryPager\$mConds
array $mConds
Definition
MergeHistoryPager.php:33
MergeHistoryPager\$maxTimestamp
int $maxTimestamp
Definition
MergeHistoryPager.php:39
MergeHistoryPager\getIndexField
getIndexField()
Returns the name of the index field.
Definition
MergeHistoryPager.php:108
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:33
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition
SpecialPage.php:717
Title
Represents a title within MediaWiki.
Definition
Title.php:42
Title\getArticleID
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition
Title.php:3225
NS_USER
const NS_USER
Definition
Defines.php:72
NS_USER_TALK
const NS_USER_TALK
Definition
Defines.php:73
$source
$source
Definition
mwdoc-filter.php:34
DB_REPLICA
const DB_REPLICA
Definition
defines.php:25
$dbr
$dbr
Definition
testCompression.php:54
$revQuery
$revQuery
Definition
testCompression.php:56
includes
specials
pagers
MergeHistoryPager.php
Generated on Sat Apr 6 2024 00:07:56 for MediaWiki by
1.9.8