MediaWiki REL1_39
MergeHistoryPager.php
Go to the documentation of this file.
1<?php
26
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(
63 LinkBatchFactory $linkBatchFactory,
64 ILoadBalancer $loadBalancer,
65 RevisionStore $revisionStore,
66 $conds,
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
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}
const NS_USER
Definition Defines.php:66
const NS_USER_TALK
Definition Defines.php:67
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='', bool $exclude=false)
Applies all tags-related changes to a query.
getDatabase()
Get the Database object in use.
Service for looking up page revisions.
SpecialMergeHistory $mForm
getStartBody()
Hook into getBody(), allows text to be inserted at the start.This will be called even if there are no...
doBatchLookups()
Called from getBody(), before getStartBody() is called and after doQuery() was called.
formatRow( $row)
Returns an HTML string representing the result row $row.
getQueryInfo()
Provides all parameters needed for the main paged query.
getEndBody()
Hook into getBody() for the end of the list.to overridestring
__construct(SpecialMergeHistory $form, LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer, RevisionStore $revisionStore, $conds, PageIdentity $source, PageIdentity $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.
Interface for objects (potentially) representing an editable wiki page.
getId( $wikiId=self::LOCAL)
Returns the page ID.
Create and track the database connections and transactions for a given database cluster.
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)
$source