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.
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.
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
19 * @ingroup RevisionDelete
22 use MediaWiki\MediaWikiServices
;
23 use MediaWiki\SpecialPage\SpecialPage
;
24 use Wikimedia\Rdbms\IDBAccessObject
;
27 * Item class for a archive table row
29 class RevDelArchiveItem
extends RevDelRevisionItem
{
30 protected static function initRevisionRecord( $list, $row ) {
31 $revRecord = MediaWikiServices
::getInstance()
32 ->getRevisionFactory()
33 ->newRevisionFromArchiveRow(
35 IDBAccessObject
::READ_NORMAL
,
37 [ 'page_id' => $list->getPage()->getId() ]
43 public function getIdField() {
44 return 'ar_timestamp';
47 public function getTimestampField() {
48 return 'ar_timestamp';
51 public function getAuthorIdField() {
55 public function getAuthorNameField() {
56 return 'ar_user_text';
59 public function getAuthorActorField() {
63 public function getId() {
64 # Convert DB timestamp to MW timestamp
65 return $this->revisionRecord
->getTimestamp();
68 public function setBits( $bits ) {
69 $dbw = MediaWikiServices
::getInstance()->getConnectionProvider()->getPrimaryDatabase();
70 $dbw->newUpdateQueryBuilder()
72 ->set( [ 'ar_deleted' => $bits ] )
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()
81 ->caller( __METHOD__
)->execute();
83 return (bool)$dbw->affectedRows();
86 protected function getRevisionLink() {
87 $date = $this->list->getLanguage()->userTimeAndDate(
88 $this->revisionRecord
->getTimestamp(), $this->list->getUser() );
90 if ( $this->isDeleted() && !$this->canViewContent() ) {
91 return htmlspecialchars( $date );
94 return $this->getLinkRenderer()->makeLink(
95 SpecialPage
::getTitleFor( 'Undelete' ),
99 'target' => $this->list->getPageName(),
100 'timestamp' => $this->revisionRecord
->getTimestamp()
105 protected function getDiffLink() {
106 if ( $this->isDeleted() && !$this->canViewContent() ) {
107 return $this->list->msg( 'diff' )->escaped();
110 return $this->getLinkRenderer()->makeLink(
111 SpecialPage
::getTitleFor( 'Undelete' ),
112 $this->list->msg( 'diff' )->text(),
115 'target' => $this->list->getPageName(),
117 'timestamp' => $this->revisionRecord
->getTimestamp()