Merge "Add .pipeline/ with dev image variant"
[lhc/web/wiklou.git] / includes / specials / pagers / MergeHistoryPager.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup Pager
20 */
21
22 /**
23 * @ingroup Pager
24 */
25 class MergeHistoryPager extends ReverseChronologicalPager {
26
27 /** @var SpecialMergeHistory */
28 public $mForm;
29
30 /** @var array */
31 public $mConds;
32
33 /** @var int */
34 private $articleID;
35
36 /** @var int */
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 }