Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 53
0.00% covered (danger)
0.00%
0 / 10
CRAP
0.00% covered (danger)
0.00%
0 / 1
RevDelArchiveItem
0.00% covered (danger)
0.00%
0 / 53
0.00% covered (danger)
0.00%
0 / 10
210
0.00% covered (danger)
0.00%
0 / 1
 initRevisionRecord
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
 getIdField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTimestampField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAuthorIdField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAuthorNameField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAuthorActorField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setBits
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
 getRevisionLink
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
12
 getDiffLink
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
12
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 RevisionDelete
20 */
21
22use MediaWiki\MediaWikiServices;
23use MediaWiki\SpecialPage\SpecialPage;
24
25/**
26 * Item class for a archive table row
27 */
28class RevDelArchiveItem extends RevDelRevisionItem {
29    protected static function initRevisionRecord( $list, $row ) {
30        $revRecord = MediaWikiServices::getInstance()
31            ->getRevisionFactory()
32            ->newRevisionFromArchiveRow(
33                $row,
34                IDBAccessObject::READ_NORMAL,
35                null,
36                [ 'page_id' => $list->getPage()->getId() ]
37            );
38
39        return $revRecord;
40    }
41
42    public function getIdField() {
43        return 'ar_timestamp';
44    }
45
46    public function getTimestampField() {
47        return 'ar_timestamp';
48    }
49
50    public function getAuthorIdField() {
51        return 'ar_user';
52    }
53
54    public function getAuthorNameField() {
55        return 'ar_user_text';
56    }
57
58    public function getAuthorActorField() {
59        return 'ar_actor';
60    }
61
62    public function getId() {
63        # Convert DB timestamp to MW timestamp
64        return $this->revisionRecord->getTimestamp();
65    }
66
67    public function setBits( $bits ) {
68        $dbw = MediaWikiServices::getInstance()->getConnectionProvider()->getPrimaryDatabase();
69        $dbw->newUpdateQueryBuilder()
70            ->update( 'archive' )
71            ->set( [ 'ar_deleted' => $bits ] )
72            ->where( [
73                'ar_namespace' => $this->list->getPage()->getNamespace(),
74                'ar_title' => $this->list->getPage()->getDBkey(),
75                // use timestamp for index
76                'ar_timestamp' => $this->row->ar_timestamp,
77                'ar_rev_id' => $this->row->ar_rev_id,
78                'ar_deleted' => $this->getBits()
79            ] )
80            ->caller( __METHOD__ )->execute();
81
82        return (bool)$dbw->affectedRows();
83    }
84
85    protected function getRevisionLink() {
86        $date = $this->list->getLanguage()->userTimeAndDate(
87            $this->revisionRecord->getTimestamp(), $this->list->getUser() );
88
89        if ( $this->isDeleted() && !$this->canViewContent() ) {
90            return htmlspecialchars( $date );
91        }
92
93        return $this->getLinkRenderer()->makeLink(
94            SpecialPage::getTitleFor( 'Undelete' ),
95            $date,
96            [],
97            [
98                'target' => $this->list->getPageName(),
99                'timestamp' => $this->revisionRecord->getTimestamp()
100            ]
101        );
102    }
103
104    protected function getDiffLink() {
105        if ( $this->isDeleted() && !$this->canViewContent() ) {
106            return $this->list->msg( 'diff' )->escaped();
107        }
108
109        return $this->getLinkRenderer()->makeLink(
110            SpecialPage::getTitleFor( 'Undelete' ),
111            $this->list->msg( 'diff' )->text(),
112            [],
113            [
114                'target' => $this->list->getPageName(),
115                'diff' => 'prev',
116                'timestamp' => $this->revisionRecord->getTimestamp()
117            ]
118        );
119    }
120}