MediaWiki  1.29.2
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  $rev_id = null;
58  foreach ( $this->mResult as $row ) {
59  $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
60  $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
61 
62  if ( isset( $rev_id ) ) {
63  if ( $rev_id > $row->rev_id ) {
64  $this->mForm->prevId[$rev_id] = $row->rev_id;
65  } elseif ( $rev_id < $row->rev_id ) {
66  $this->mForm->prevId[$row->rev_id] = $rev_id;
67  }
68  }
69 
70  $rev_id = $row->rev_id;
71  }
72 
73  $batch->execute();
74  $this->mResult->seek( 0 );
75 
76  return '';
77  }
78 
79  function formatRow( $row ) {
80  return $this->mForm->formatRevisionRow( $row );
81  }
82 
83  function getQueryInfo() {
84  $conds = $this->mConds;
85  $conds['rev_page'] = $this->articleID;
86  $conds[] = "rev_timestamp < " . $this->mDb->addQuotes( $this->maxTimestamp );
87 
88  return [
89  'tables' => [ 'revision', 'page', 'user' ],
90  'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
91  'conds' => $conds,
92  'join_conds' => [
93  'page' => Revision::pageJoinCond(),
94  'user' => Revision::userJoinCond() ]
95  ];
96  }
97 
98  function getIndexField() {
99  return 'rev_timestamp';
100  }
101 }
MergeHistoryPager\getIndexField
getIndexField()
This function should be overridden to return the name of the index fi- eld.
Definition: MergeHistoryPager.php:98
Revision\pageJoinCond
static pageJoinCond()
Return the value of a select() page conds array for the page table.
Definition: Revision.php:439
MergeHistoryPager\$mForm
SpecialMergeHistory $mForm
Definition: MergeHistoryPager.php:28
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
Title\getArticleID
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:3220
php
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
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3060
MergeHistoryPager\__construct
__construct(SpecialMergeHistory $form, $conds, Title $source, Title $dest)
Definition: MergeHistoryPager.php:33
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:648
MergeHistoryPager\getQueryInfo
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
Definition: MergeHistoryPager.php:83
MergeHistoryPager\getStartBody
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
Definition: MergeHistoryPager.php:51
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:538
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:65
title
title
Definition: parserTests.txt:211
MergeHistoryPager\formatRow
formatRow( $row)
Abstract formatting function.
Definition: MergeHistoryPager.php:79
Title
Represents a title within MediaWiki.
Definition: Title.php:39
$dbr
if(! $regexes) $dbr
Definition: cleanup.php:94
MergeHistoryPager\$mConds
array $mConds
Definition: MergeHistoryPager.php:31
as
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
Revision\userJoinCond
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
Definition: Revision.php:429
NS_USER
const NS_USER
Definition: Defines.php:64
$source
$source
Definition: mwdoc-filter.php:45
$batch
$batch
Definition: linkcache.txt:23
ReverseChronologicalPager
IndexPager with a formatted navigation bar.
Definition: ReverseChronologicalPager.php:29
Revision\selectUserFields
static selectUserFields()
Return the list of user fields that should be selected from user table.
Definition: Revision.php:536
MergeHistoryPager
Definition: MergeHistoryPager.php:25
Revision\selectFields
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
Definition: Revision.php:448
SpecialMergeHistory
Special page allowing users with the appropriate permissions to merge article histories,...
Definition: SpecialMergeHistory.php:30
array
the array() calling protocol came about after MediaWiki 1.4rc1.