MediaWiki REL1_35
MergeHistoryPager.php
Go to the documentation of this file.
1<?php
23
28
30 public $mForm;
31
33 public $mConds;
34
36 private $articleID;
37
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
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( $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:35
MediaWikiServices is the service locator for the application scope of MediaWiki.
SpecialMergeHistory $mForm
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
formatRow( $row)
Returns an HTML string representing the result row $row.
getQueryInfo()
Provides all parameters needed for the main paged query.
__construct(SpecialMergeHistory $form, $conds, Title $source, Title $dest)
getIndexField()
Returns the name of the index field.
Efficient paging for SQL queries.
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:3225
const NS_USER
Definition Defines.php:72
const NS_USER_TALK
Definition Defines.php:73
$source
const DB_REPLICA
Definition defines.php:25