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