MediaWiki REL1_34
MergeHistoryPager.php
Go to the documentation of this file.
1<?php
26
28 public $mForm;
29
31 public $mConds;
32
34 private $articleID;
35
38
39 public function __construct( SpecialMergeHistory $form, $conds, Title $source, Title $dest ) {
40 $this->mForm = $form;
41 $this->mConds = $conds;
42 $this->articleID = $source->getArticleID();
43
45 $maxtimestamp = $dbr->selectField(
46 'revision',
47 'MIN(rev_timestamp)',
48 [ 'rev_page' => $dest->getArticleID() ],
49 __METHOD__
50 );
51 $this->maxTimestamp = $maxtimestamp;
52
53 parent::__construct( $form->getContext() );
54 }
55
56 protected function getStartBody() {
57 # Do a link batch query
58 $this->mResult->seek( 0 );
59 $batch = new LinkBatch();
60 # Give some pointers to make (last) links
61 $this->mForm->prevId = [];
62 $rev_id = null;
63 foreach ( $this->mResult as $row ) {
64 $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
65 $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
66
67 if ( isset( $rev_id ) ) {
68 if ( $rev_id > $row->rev_id ) {
69 $this->mForm->prevId[$rev_id] = $row->rev_id;
70 } elseif ( $rev_id < $row->rev_id ) {
71 $this->mForm->prevId[$row->rev_id] = $rev_id;
72 }
73 }
74
75 $rev_id = $row->rev_id;
76 }
77
78 $batch->execute();
79 $this->mResult->seek( 0 );
80
81 return '';
82 }
83
84 function formatRow( $row ) {
85 return $this->mForm->formatRevisionRow( $row );
86 }
87
88 function getQueryInfo() {
89 $conds = $this->mConds;
90 $conds['rev_page'] = $this->articleID;
91 $conds[] = "rev_timestamp < " . $this->mDb->addQuotes( $this->maxTimestamp );
92
93 $revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
94 return [
95 'tables' => $revQuery['tables'],
96 'fields' => $revQuery['fields'],
97 'conds' => $conds,
98 'join_conds' => $revQuery['joins']
99 ];
100 }
101
102 function getIndexField() {
103 return 'rev_timestamp';
104 }
105}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition LinkBatch.php:34
SpecialMergeHistory $mForm
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
formatRow( $row)
Abstract formatting function.
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
__construct(SpecialMergeHistory $form, $conds, Title $source, Title $dest)
getIndexField()
This function should be overridden to return the name of the index fi- eld.
Efficient paging for SQL queries.
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
Definition Revision.php:315
Special page allowing users with the appropriate permissions to merge article histories,...
getContext()
Gets the context this SpecialPage is executed in.
Represents a title within MediaWiki.
Definition Title.php:42
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition Title.php:3126
const NS_USER
Definition Defines.php:71
const NS_USER_TALK
Definition Defines.php:72
$source
const DB_REPLICA
Definition defines.php:25