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