MediaWiki  1.28.1
MergeHistoryPager.php
Go to the documentation of this file.
1 <?php
26 
28  public $mForm;
29 
31  public $mConds;
32 
33  function __construct( SpecialMergeHistory $form, $conds, Title $source, Title $dest ) {
34  $this->mForm = $form;
35  $this->mConds = $conds;
36  $this->title = $source;
37  $this->articleID = $source->getArticleID();
38 
39  $dbr = wfGetDB( DB_REPLICA );
40  $maxtimestamp = $dbr->selectField(
41  'revision',
42  'MIN(rev_timestamp)',
43  [ 'rev_page' => $dest->getArticleID() ],
44  __METHOD__
45  );
46  $this->maxTimestamp = $maxtimestamp;
47 
48  parent::__construct( $form->getContext() );
49  }
50 
51  function getStartBody() {
52  # Do a link batch query
53  $this->mResult->seek( 0 );
54  $batch = new LinkBatch();
55  # Give some pointers to make (last) links
56  $this->mForm->prevId = [];
57  foreach ( $this->mResult as $row ) {
58  $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
59  $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
60 
61  $rev_id = isset( $rev_id ) ? $rev_id : $row->rev_id;
62  if ( $rev_id > $row->rev_id ) {
63  $this->mForm->prevId[$rev_id] = $row->rev_id;
64  } elseif ( $rev_id < $row->rev_id ) {
65  $this->mForm->prevId[$row->rev_id] = $rev_id;
66  }
67 
68  $rev_id = $row->rev_id;
69  }
70 
71  $batch->execute();
72  $this->mResult->seek( 0 );
73 
74  return '';
75  }
76 
77  function formatRow( $row ) {
78  return $this->mForm->formatRevisionRow( $row );
79  }
80 
81  function getQueryInfo() {
82  $conds = $this->mConds;
83  $conds['rev_page'] = $this->articleID;
84  $conds[] = "rev_timestamp < " . $this->mDb->addQuotes( $this->maxTimestamp );
85 
86  return [
87  'tables' => [ 'revision', 'page', 'user' ],
88  'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
89  'conds' => $conds,
90  'join_conds' => [
91  'page' => Revision::pageJoinCond(),
92  'user' => Revision::userJoinCond() ]
93  ];
94  }
95 
96  function getIndexField() {
97  return 'rev_timestamp';
98  }
99 }
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
getContext()
Gets the context this SpecialPage is executed in.
getArticleID($flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:3209
IndexPager with a formatted navigation bar.
$source
__construct(SpecialMergeHistory $form, $conds, Title $source, Title $dest)
title
$batch
Definition: linkcache.txt:23
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:32
Special page allowing users with the appropriate permissions to merge article histories, with some restrictions.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
Definition: Revision.php:442
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:535
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
static pageJoinCond()
Return the value of a select() page conds array for the page table.
Definition: Revision.php:433
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
const DB_REPLICA
Definition: defines.php:22
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
Definition: Revision.php:423
const NS_USER_TALK
Definition: Defines.php:59
static selectUserFields()
Return the list of user fields that should be selected from user table.
Definition: Revision.php:530
SpecialMergeHistory $mForm