MediaWiki REL1_37
MergeHistoryPager.php
Go to the documentation of this file.
1<?php
26
31
33 public $mForm;
34
36 public $mConds;
37
39 private $articleID;
40
43
46
49
59 public function __construct(
61 $conds,
63 PageIdentity $dest,
65 ILoadBalancer $loadBalancer,
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}
const NS_USER
Definition Defines.php:66
const NS_USER_TALK
Definition Defines.php:67
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.
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, PageIdentity $source, PageIdentity $dest, LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer, RevisionStore $revisionStore)
LinkBatchFactory $linkBatchFactory
getIndexField()
Returns the name of the index field.
RevisionStore $revisionStore
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.
Database cluster connection, tracking, load balancing, and transaction manager interface.
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Get a live database handle reference for a server index.
$source