MediaWiki  master
MergeHistoryPager.php
Go to the documentation of this file.
1 <?php
26 
28  public $mForm;
29 
31  public $mConds;
32 
34  private $articleID;
35 
37  private $maxTimestamp;
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 
44  $dbr = wfGetDB( DB_REPLICA );
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 }
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:3166
getContext()
Gets the context this SpecialPage is executed in.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Efficient paging for SQL queries.
$source
__construct(SpecialMergeHistory $form, $conds, Title $source, Title $dest)
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
Special page allowing users with the appropriate permissions to merge article histories, with some restrictions.
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object...
Definition: Revision.php:315
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:612
$revQuery
const DB_REPLICA
Definition: defines.php:25
const NS_USER_TALK
Definition: Defines.php:63
SpecialMergeHistory $mForm