3 * Base implementations for deletable items.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup RevisionDelete
25 * List for revision table items
27 * This will check both the 'revision' table for live revisions and the
28 * 'archive' table for traditionally-deleted revisions that have an
31 * See RevDelRevisionItem and RevDelArchivedRevisionItem for items.
33 class RevDelRevisionList
extends RevDelList
{
37 public function getType() {
41 public static function getRelationType() {
45 public static function getRestriction() {
46 return 'deleterevision';
49 public static function getRevdelConstant() {
50 return Revision
::DELETED_TEXT
;
53 public static function suggestTarget( $target, array $ids ) {
54 $rev = Revision
::newFromId( $ids[0] );
55 return $rev ?
$rev->getTitle() : $target;
59 * @param DatabaseBase $db
62 public function doQuery( $db ) {
63 $ids = array_map( 'intval', $this->ids
);
65 array( 'revision', 'page', 'user' ),
66 array_merge( Revision
::selectFields(), Revision
::selectUserFields() ),
68 'rev_page' => $this->title
->getArticleID(),
72 array( 'ORDER BY' => 'rev_id DESC' ),
74 'page' => Revision
::pageJoinCond(),
75 'user' => Revision
::userJoinCond() )
78 if ( $live->numRows() >= count( $ids ) ) {
79 // All requested revisions are live, keeps things simple!
83 // Check if any requested revisions are available fully deleted.
84 $archived = $db->select( array( 'archive' ), Revision
::selectArchiveFields(),
89 array( 'ORDER BY' => 'ar_rev_id DESC' )
92 if ( $archived->numRows() == 0 ) {
94 } elseif ( $live->numRows() == 0 ) {
97 // Combine the two! Whee
99 foreach ( $live as $row ) {
100 $rows[$row->rev_id
] = $row;
102 foreach ( $archived as $row ) {
103 $rows[$row->ar_rev_id
] = $row;
106 return new FakeResultWrapper( array_values( $rows ) );
110 public function newItem( $row ) {
111 if ( isset( $row->rev_id
) ) {
112 return new RevDelRevisionItem( $this, $row );
113 } elseif ( isset( $row->ar_rev_id
) ) {
114 return new RevDelArchivedRevisionItem( $this, $row );
116 // This shouldn't happen. :)
117 throw new MWException( 'Invalid row type in RevDelRevisionList' );
121 public function getCurrent() {
122 if ( is_null( $this->currentRevId
) ) {
123 $dbw = wfGetDB( DB_MASTER
);
124 $this->currentRevId
= $dbw->selectField(
125 'page', 'page_latest', $this->title
->pageCond(), __METHOD__
);
127 return $this->currentRevId
;
130 public function getSuppressBit() {
131 return Revision
::DELETED_RESTRICTED
;
134 public function doPreCommitUpdates() {
135 $this->title
->invalidateCache();
136 return Status
::newGood();
139 public function doPostCommitUpdates() {
140 $this->title
->purgeSquid();
141 // Extensions that require referencing previous revisions may need this
142 wfRunHooks( 'ArticleRevisionVisibilitySet', array( &$this->title
) );
143 return Status
::newGood();
148 * Item class for a live revision table row
150 class RevDelRevisionItem
extends RevDelItem
{
154 public function __construct( $list, $row ) {
155 parent
::__construct( $list, $row );
156 $this->revision
= new Revision( $row );
159 public function getIdField() {
163 public function getTimestampField() {
164 return 'rev_timestamp';
167 public function getAuthorIdField() {
171 public function getAuthorNameField() {
172 return 'rev_user_text';
175 public function canView() {
176 return $this->revision
->userCan( Revision
::DELETED_RESTRICTED
, $this->list->getUser() );
179 public function canViewContent() {
180 return $this->revision
->userCan( Revision
::DELETED_TEXT
, $this->list->getUser() );
183 public function getBits() {
184 return $this->revision
->getVisibility();
187 public function setBits( $bits ) {
188 $dbw = wfGetDB( DB_MASTER
);
189 // Update revision table
190 $dbw->update( 'revision',
191 array( 'rev_deleted' => $bits ),
193 'rev_id' => $this->revision
->getId(),
194 'rev_page' => $this->revision
->getPage(),
195 'rev_deleted' => $this->getBits()
199 if ( !$dbw->affectedRows() ) {
203 // Update recentchanges table
204 $dbw->update( 'recentchanges',
206 'rc_deleted' => $bits,
210 'rc_this_oldid' => $this->revision
->getId(), // condition
211 // non-unique timestamp index
212 'rc_timestamp' => $dbw->timestamp( $this->revision
->getTimestamp() ),
219 public function isDeleted() {
220 return $this->revision
->isDeleted( Revision
::DELETED_TEXT
);
223 public function isHideCurrentOp( $newBits ) {
224 return ( $newBits & Revision
::DELETED_TEXT
)
225 && $this->list->getCurrent() == $this->getId();
229 * Get the HTML link to the revision text.
230 * Overridden by RevDelArchiveItem.
233 protected function getRevisionLink() {
234 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
235 $this->revision
->getTimestamp(), $this->list->getUser() ) );
237 if ( $this->isDeleted() && !$this->canViewContent() ) {
240 return Linker
::linkKnown(
245 'oldid' => $this->revision
->getId(),
252 * Get the HTML link to the diff.
253 * Overridden by RevDelArchiveItem
256 protected function getDiffLink() {
257 if ( $this->isDeleted() && !$this->canViewContent() ) {
258 return $this->list->msg( 'diff' )->escaped();
260 return Linker
::linkKnown(
262 $this->list->msg( 'diff' )->escaped(),
265 'diff' => $this->revision
->getId(),
273 public function getHTML() {
274 $difflink = $this->list->msg( 'parentheses' )
275 ->rawParams( $this->getDiffLink() )->escaped();
276 $revlink = $this->getRevisionLink();
277 $userlink = Linker
::revUserLink( $this->revision
);
278 $comment = Linker
::revComment( $this->revision
);
279 if ( $this->isDeleted() ) {
280 $revlink = "<span class=\"history-deleted\">$revlink</span>";
282 return "<li>$difflink $revlink $userlink $comment</li>";
285 public function getApiData( ApiResult
$result ) {
286 $rev = $this->revision
;
287 $user = $this->list->getUser();
289 'id' => $rev->getId(),
290 'timestamp' => wfTimestamp( TS_ISO_8601
, $rev->getTimestamp() ),
292 $ret +
= $rev->isDeleted( Revision
::DELETED_USER
) ?
array( 'userhidden' => '' ) : array();
293 $ret +
= $rev->isDeleted( Revision
::DELETED_COMMENT
) ?
array( 'commenthidden' => '' ) : array();
294 $ret +
= $rev->isDeleted( Revision
::DELETED_TEXT
) ?
array( 'texthidden' => '' ) : array();
295 if ( $rev->userCan( Revision
::DELETED_USER
, $user ) ) {
297 'userid' => $rev->getUser( Revision
::FOR_THIS_USER
),
298 'user' => $rev->getUserText( Revision
::FOR_THIS_USER
),
301 if ( $rev->userCan( Revision
::DELETED_COMMENT
, $user ) ) {
303 'comment' => $rev->getComment( Revision
::FOR_THIS_USER
),
311 * List for archive table items, i.e. revisions deleted via action=delete
313 class RevDelArchiveList
extends RevDelRevisionList
{
314 public function getType() {
318 public static function getRelationType() {
319 return 'ar_timestamp';
323 * @param DatabaseBase $db
326 public function doQuery( $db ) {
327 $timestamps = array();
328 foreach ( $this->ids
as $id ) {
329 $timestamps[] = $db->timestamp( $id );
331 return $db->select( 'archive', Revision
::selectArchiveFields(),
333 'ar_namespace' => $this->title
->getNamespace(),
334 'ar_title' => $this->title
->getDBkey(),
335 'ar_timestamp' => $timestamps
338 array( 'ORDER BY' => 'ar_timestamp DESC' )
342 public function newItem( $row ) {
343 return new RevDelArchiveItem( $this, $row );
346 public function doPreCommitUpdates() {
347 return Status
::newGood();
350 public function doPostCommitUpdates() {
351 return Status
::newGood();
356 * Item class for a archive table row
358 class RevDelArchiveItem
extends RevDelRevisionItem
{
359 public function __construct( $list, $row ) {
360 RevDelItem
::__construct( $list, $row );
361 $this->revision
= Revision
::newFromArchiveRow( $row,
362 array( 'page' => $this->list->title
->getArticleID() ) );
365 public function getIdField() {
366 return 'ar_timestamp';
369 public function getTimestampField() {
370 return 'ar_timestamp';
373 public function getAuthorIdField() {
377 public function getAuthorNameField() {
378 return 'ar_user_text';
381 public function getId() {
382 # Convert DB timestamp to MW timestamp
383 return $this->revision
->getTimestamp();
386 public function setBits( $bits ) {
387 $dbw = wfGetDB( DB_MASTER
);
388 $dbw->update( 'archive',
389 array( 'ar_deleted' => $bits ),
391 'ar_namespace' => $this->list->title
->getNamespace(),
392 'ar_title' => $this->list->title
->getDBkey(),
393 // use timestamp for index
394 'ar_timestamp' => $this->row
->ar_timestamp
,
395 'ar_rev_id' => $this->row
->ar_rev_id
,
396 'ar_deleted' => $this->getBits()
399 return (bool)$dbw->affectedRows();
402 protected function getRevisionLink() {
403 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
404 $this->revision
->getTimestamp(), $this->list->getUser() ) );
406 if ( $this->isDeleted() && !$this->canViewContent() ) {
411 SpecialPage
::getTitleFor( 'Undelete' ),
415 'target' => $this->list->title
->getPrefixedText(),
416 'timestamp' => $this->revision
->getTimestamp()
421 protected function getDiffLink() {
422 if ( $this->isDeleted() && !$this->canViewContent() ) {
423 return $this->list->msg( 'diff' )->escaped();
427 SpecialPage
::getTitleFor( 'Undelete' ),
428 $this->list->msg( 'diff' )->escaped(),
431 'target' => $this->list->title
->getPrefixedText(),
433 'timestamp' => $this->revision
->getTimestamp()
440 * Item class for a archive table row by ar_rev_id -- actually
441 * used via RevDelRevisionList.
443 class RevDelArchivedRevisionItem
extends RevDelArchiveItem
{
444 public function __construct( $list, $row ) {
445 RevDelItem
::__construct( $list, $row );
447 $this->revision
= Revision
::newFromArchiveRow( $row,
448 array( 'page' => $this->list->title
->getArticleID() ) );
451 public function getIdField() {
455 public function getId() {
456 return $this->revision
->getId();
459 public function setBits( $bits ) {
460 $dbw = wfGetDB( DB_MASTER
);
461 $dbw->update( 'archive',
462 array( 'ar_deleted' => $bits ),
463 array( 'ar_rev_id' => $this->row
->ar_rev_id
,
464 'ar_deleted' => $this->getBits()
467 return (bool)$dbw->affectedRows();
472 * List for oldimage table items
474 class RevDelFileList
extends RevDelList
{
484 public function getType() {
488 public static function getRelationType() {
489 return 'oi_archive_name';
492 public static function getRestriction() {
493 return 'deleterevision';
496 public static function getRevdelConstant() {
497 return File
::DELETED_FILE
;
501 * @param DatabaseBase $db
504 public function doQuery( $db ) {
505 $archiveNames = array();
506 foreach ( $this->ids
as $timestamp ) {
507 $archiveNames[] = $timestamp . '!' . $this->title
->getDBkey();
511 OldLocalFile
::selectFields(),
513 'oi_name' => $this->title
->getDBkey(),
514 'oi_archive_name' => $archiveNames
517 array( 'ORDER BY' => 'oi_timestamp DESC' )
521 public function newItem( $row ) {
522 return new RevDelFileItem( $this, $row );
525 public function clearFileOps() {
526 $this->deleteBatch
= array();
527 $this->storeBatch
= array();
528 $this->cleanupBatch
= array();
531 public function doPreCommitUpdates() {
532 $status = Status
::newGood();
533 $repo = RepoGroup
::singleton()->getLocalRepo();
534 if ( $this->storeBatch
) {
535 $status->merge( $repo->storeBatch( $this->storeBatch
, FileRepo
::OVERWRITE_SAME
) );
537 if ( !$status->isOK() ) {
540 if ( $this->deleteBatch
) {
541 $status->merge( $repo->deleteBatch( $this->deleteBatch
) );
543 if ( !$status->isOK() ) {
544 // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
545 // modified (but destined for rollback) causes data loss
548 if ( $this->cleanupBatch
) {
549 $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch
) );
554 public function doPostCommitUpdates() {
555 $file = wfLocalFile( $this->title
);
557 $file->purgeDescription();
558 $purgeUrls = array();
559 foreach ( $this->ids
as $timestamp ) {
560 $archiveName = $timestamp . '!' . $this->title
->getDBkey();
561 $file->purgeOldThumbnails( $archiveName );
562 $purgeUrls[] = $file->getArchiveUrl( $archiveName );
564 if ( $this->getConfig()->get( 'UseSquid' ) ) {
565 // purge full images from cache
566 SquidUpdate
::purge( $purgeUrls );
568 return Status
::newGood();
571 public function getSuppressBit() {
572 return File
::DELETED_RESTRICTED
;
577 * Item class for an oldimage table row
579 class RevDelFileItem
extends RevDelItem
{
583 public function __construct( $list, $row ) {
584 parent
::__construct( $list, $row );
585 $this->file
= RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
588 public function getIdField() {
589 return 'oi_archive_name';
592 public function getTimestampField() {
593 return 'oi_timestamp';
596 public function getAuthorIdField() {
600 public function getAuthorNameField() {
601 return 'oi_user_text';
604 public function getId() {
605 $parts = explode( '!', $this->row
->oi_archive_name
);
609 public function canView() {
610 return $this->file
->userCan( File
::DELETED_RESTRICTED
, $this->list->getUser() );
613 public function canViewContent() {
614 return $this->file
->userCan( File
::DELETED_FILE
, $this->list->getUser() );
617 public function getBits() {
618 return $this->file
->getVisibility();
621 public function setBits( $bits ) {
623 # @todo FIXME: Move to LocalFile.php
624 if ( $this->isDeleted() ) {
625 if ( $bits & File
::DELETED_FILE
) {
629 $key = $this->file
->getStorageKey();
630 $srcRel = $this->file
->repo
->getDeletedHashPath( $key ) . $key;
631 $this->list->storeBatch
[] = array(
632 $this->file
->repo
->getVirtualUrl( 'deleted' ) . '/' . $srcRel,
634 $this->file
->getRel()
636 $this->list->cleanupBatch
[] = $key;
638 } elseif ( $bits & File
::DELETED_FILE
) {
640 $key = $this->file
->getStorageKey();
641 $dstRel = $this->file
->repo
->getDeletedHashPath( $key ) . $key;
642 $this->list->deleteBatch
[] = array( $this->file
->getRel(), $dstRel );
645 # Do the database operations
646 $dbw = wfGetDB( DB_MASTER
);
647 $dbw->update( 'oldimage',
648 array( 'oi_deleted' => $bits ),
650 'oi_name' => $this->row
->oi_name
,
651 'oi_timestamp' => $this->row
->oi_timestamp
,
652 'oi_deleted' => $this->getBits()
656 return (bool)$dbw->affectedRows();
659 public function isDeleted() {
660 return $this->file
->isDeleted( File
::DELETED_FILE
);
664 * Get the link to the file.
665 * Overridden by RevDelArchivedFileItem.
668 protected function getLink() {
669 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
670 $this->file
->getTimestamp(), $this->list->getUser() ) );
672 if ( !$this->isDeleted() ) {
674 return Html
::rawElement( 'a', array( 'href' => $this->file
->getUrl() ), $date );
678 if ( !$this->canViewContent() ) {
681 $link = Linker
::link(
682 SpecialPage
::getTitleFor( 'Revisiondelete' ),
686 'target' => $this->list->title
->getPrefixedText(),
687 'file' => $this->file
->getArchiveName(),
688 'token' => $this->list->getUser()->getEditToken(
689 $this->file
->getArchiveName() )
693 return '<span class="history-deleted">' . $link . '</span>';
697 * Generate a user tool link cluster if the current user is allowed to view it
698 * @return string HTML
700 protected function getUserTools() {
701 if ( $this->file
->userCan( Revision
::DELETED_USER
, $this->list->getUser() ) ) {
702 $uid = $this->file
->getUser( 'id' );
703 $name = $this->file
->getUser( 'text' );
704 $link = Linker
::userLink( $uid, $name ) . Linker
::userToolLinks( $uid, $name );
706 $link = $this->list->msg( 'rev-deleted-user' )->escaped();
708 if ( $this->file
->isDeleted( Revision
::DELETED_USER
) ) {
709 return '<span class="history-deleted">' . $link . '</span>';
715 * Wrap and format the file's comment block, if the current
716 * user is allowed to view it.
718 * @return string HTML
720 protected function getComment() {
721 if ( $this->file
->userCan( File
::DELETED_COMMENT
, $this->list->getUser() ) ) {
722 $block = Linker
::commentBlock( $this->file
->getDescription() );
724 $block = ' ' . $this->list->msg( 'rev-deleted-comment' )->escaped();
726 if ( $this->file
->isDeleted( File
::DELETED_COMMENT
) ) {
727 return "<span class=\"history-deleted\">$block</span>";
732 public function getHTML() {
734 $this->list->msg( 'widthheight' )->numParams(
735 $this->file
->getWidth(), $this->file
->getHeight() )->text() .
736 ' (' . $this->list->msg( 'nbytes' )->numParams( $this->file
->getSize() )->text() . ')';
738 return '<li>' . $this->getLink() . ' ' . $this->getUserTools() . ' ' .
739 $data . ' ' . $this->getComment() . '</li>';
742 public function getApiData( ApiResult
$result ) {
744 $user = $this->list->getUser();
746 'title' => $this->list->title
->getPrefixedText(),
747 'archivename' => $file->getArchiveName(),
748 'timestamp' => wfTimestamp( TS_ISO_8601
, $file->getTimestamp() ),
749 'width' => $file->getWidth(),
750 'height' => $file->getHeight(),
751 'size' => $file->getSize(),
753 $ret +
= $file->isDeleted( Revision
::DELETED_USER
) ?
array( 'userhidden' => '' ) : array();
754 $ret +
= $file->isDeleted( Revision
::DELETED_COMMENT
) ?
array( 'commenthidden' => '' ) : array();
755 $ret +
= $this->isDeleted() ?
array( 'contenthidden' => '' ) : array();
756 if ( !$this->isDeleted() ) {
758 'url' => $file->getUrl(),
760 } elseif ( $this->canViewContent() ) {
762 'url' => SpecialPage
::getTitleFor( 'Revisiondelete' )->getLinkURL(
764 'target' => $this->list->title
->getPrefixedText(),
765 'file' => $file->getArchiveName(),
766 'token' => $user->getEditToken( $file->getArchiveName() )
768 false, PROTO_RELATIVE
772 if ( $file->userCan( Revision
::DELETED_USER
, $user ) ) {
774 'userid' => $file->user
,
775 'user' => $file->user_text
,
778 if ( $file->userCan( Revision
::DELETED_COMMENT
, $user ) ) {
780 'comment' => $file->description
,
788 * List for filearchive table items
790 class RevDelArchivedFileList
extends RevDelFileList
{
791 public function getType() {
792 return 'filearchive';
795 public static function getRelationType() {
800 * @param DatabaseBase $db
803 public function doQuery( $db ) {
804 $ids = array_map( 'intval', $this->ids
);
807 ArchivedFile
::selectFields(),
809 'fa_name' => $this->title
->getDBkey(),
813 array( 'ORDER BY' => 'fa_id DESC' )
817 public function newItem( $row ) {
818 return new RevDelArchivedFileItem( $this, $row );
823 * Item class for a filearchive table row
825 class RevDelArchivedFileItem
extends RevDelFileItem
{
826 public function __construct( $list, $row ) {
827 RevDelItem
::__construct( $list, $row );
828 $this->file
= ArchivedFile
::newFromRow( $row );
831 public function getIdField() {
835 public function getTimestampField() {
836 return 'fa_timestamp';
839 public function getAuthorIdField() {
843 public function getAuthorNameField() {
844 return 'fa_user_text';
847 public function getId() {
848 return $this->row
->fa_id
;
851 public function setBits( $bits ) {
852 $dbw = wfGetDB( DB_MASTER
);
853 $dbw->update( 'filearchive',
854 array( 'fa_deleted' => $bits ),
856 'fa_id' => $this->row
->fa_id
,
857 'fa_deleted' => $this->getBits(),
861 return (bool)$dbw->affectedRows();
864 protected function getLink() {
865 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
866 $this->file
->getTimestamp(), $this->list->getUser() ) );
869 if ( !$this->canViewContent() ) {
872 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
873 $key = $this->file
->getKey();
874 $link = Linker
::link( $undelete, $date, array(),
876 'target' => $this->list->title
->getPrefixedText(),
878 'token' => $this->list->getUser()->getEditToken( $key )
882 if ( $this->isDeleted() ) {
883 $link = '<span class="history-deleted">' . $link . '</span>';
888 public function getApiData( ApiResult
$result ) {
890 $user = $this->list->getUser();
892 'title' => $this->list->title
->getPrefixedText(),
893 'timestamp' => wfTimestamp( TS_ISO_8601
, $file->getTimestamp() ),
894 'width' => $file->getWidth(),
895 'height' => $file->getHeight(),
896 'size' => $file->getSize(),
898 $ret +
= $file->isDeleted( Revision
::DELETED_USER
) ?
array( 'userhidden' => '' ) : array();
899 $ret +
= $file->isDeleted( Revision
::DELETED_COMMENT
) ?
array( 'commenthidden' => '' ) : array();
900 $ret +
= $this->isDeleted() ?
array( 'contenthidden' => '' ) : array();
901 if ( $this->canViewContent() ) {
903 'url' => SpecialPage
::getTitleFor( 'Revisiondelete' )->getLinkURL(
905 'target' => $this->list->title
->getPrefixedText(),
906 'file' => $file->getKey(),
907 'token' => $user->getEditToken( $file->getKey() )
909 false, PROTO_RELATIVE
913 if ( $file->userCan( Revision
::DELETED_USER
, $user ) ) {
915 'userid' => $file->getUser( 'id' ),
916 'user' => $file->getUser( 'text' ),
919 if ( $file->userCan( Revision
::DELETED_COMMENT
, $user ) ) {
921 'comment' => $file->getRawDescription(),
929 * List for logging table items
931 class RevDelLogList
extends RevDelList
{
932 public function getType() {
936 public static function getRelationType() {
940 public static function getRestriction() {
941 return 'deletelogentry';
944 public static function getRevdelConstant() {
945 return LogPage
::DELETED_ACTION
;
948 public static function suggestTarget( $target, array $ids ) {
949 $result = wfGetDB( DB_SLAVE
)->select( 'logging',
951 array( 'log_id' => $ids ),
955 if ( $result->numRows() == 1 ) {
956 // If there's only one type, the target can be set to include it.
957 return SpecialPage
::getTitleFor( 'Log', $result->current()->log_type
);
959 return SpecialPage
::getTitleFor( 'Log' );
963 * @param DatabaseBase $db
966 public function doQuery( $db ) {
967 $ids = array_map( 'intval', $this->ids
);
968 return $db->select( 'logging', array(
982 array( 'log_id' => $ids ),
984 array( 'ORDER BY' => 'log_id DESC' )
988 public function newItem( $row ) {
989 return new RevDelLogItem( $this, $row );
992 public function getSuppressBit() {
993 return Revision
::DELETED_RESTRICTED
;
996 public function getLogAction() {
1000 public function getLogParams( $params ) {
1002 implode( ',', $params['ids'] ),
1003 "ofield={$params['oldBits']}",
1004 "nfield={$params['newBits']}"
1010 * Item class for a logging table row
1012 class RevDelLogItem
extends RevDelItem
{
1013 public function getIdField() {
1017 public function getTimestampField() {
1018 return 'log_timestamp';
1021 public function getAuthorIdField() {
1025 public function getAuthorNameField() {
1026 return 'log_user_text';
1029 public function canView() {
1030 return LogEventsList
::userCan( $this->row
, Revision
::DELETED_RESTRICTED
, $this->list->getUser() );
1033 public function canViewContent() {
1034 return true; // none
1037 public function getBits() {
1038 return $this->row
->log_deleted
;
1041 public function setBits( $bits ) {
1042 $dbw = wfGetDB( DB_MASTER
);
1043 $dbw->update( 'recentchanges',
1045 'rc_deleted' => $bits,
1049 'rc_logid' => $this->row
->log_id
,
1050 'rc_timestamp' => $this->row
->log_timestamp
// index
1054 $dbw->update( 'logging',
1055 array( 'log_deleted' => $bits ),
1057 'log_id' => $this->row
->log_id
,
1058 'log_deleted' => $this->getBits()
1062 return (bool)$dbw->affectedRows();
1065 public function getHTML() {
1066 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
1067 $this->row
->log_timestamp
, $this->list->getUser() ) );
1068 $title = Title
::makeTitle( $this->row
->log_namespace
, $this->row
->log_title
);
1069 $formatter = LogFormatter
::newFromRow( $this->row
);
1070 $formatter->setContext( $this->list->getContext() );
1071 $formatter->setAudience( LogFormatter
::FOR_THIS_USER
);
1073 // Log link for this page
1074 $loglink = Linker
::link(
1075 SpecialPage
::getTitleFor( 'Log' ),
1076 $this->list->msg( 'log' )->escaped(),
1078 array( 'page' => $title->getPrefixedText() )
1080 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
1081 // User links and action text
1082 $action = $formatter->getActionText();
1084 $comment = $this->list->getLanguage()->getDirMark()
1085 . Linker
::commentBlock( $this->row
->log_comment
);
1087 if ( LogEventsList
::isDeleted( $this->row
, LogPage
::DELETED_COMMENT
) ) {
1088 $comment = '<span class="history-deleted">' . $comment . '</span>';
1091 return "<li>$loglink $date $action $comment</li>";
1094 public function getApiData( ApiResult
$result ) {
1095 $logEntry = DatabaseLogEntry
::newFromRow( $this->row
);
1096 $user = $this->list->getUser();
1098 'id' => $logEntry->getId(),
1099 'type' => $logEntry->getType(),
1100 'action' => $logEntry->getSubtype(),
1102 $ret +
= $logEntry->isDeleted( LogPage
::DELETED_USER
)
1103 ?
array( 'userhidden' => '' )
1105 $ret +
= $logEntry->isDeleted( LogPage
::DELETED_COMMENT
)
1106 ?
array( 'commenthidden' => '' )
1108 $ret +
= $logEntry->isDeleted( LogPage
::DELETED_ACTION
)
1109 ?
array( 'actionhidden' => '' )
1112 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_ACTION
, $user ) ) {
1113 ApiQueryLogEvents
::addLogParams(
1116 $logEntry->getParameters(),
1117 $logEntry->getType(),
1118 $logEntry->getSubtype(),
1119 $logEntry->getTimestamp(),
1120 $logEntry->isLegacy()
1123 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_USER
, $user ) ) {
1125 'userid' => $this->row
->log_user
,
1126 'user' => $this->row
->log_user_text
,
1129 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_COMMENT
, $user ) ) {
1131 'comment' => $this->row
->log_comment
,