diff options
Diffstat (limited to 'includes/revisiondelete/RevisionDelete.php')
-rw-r--r-- | includes/revisiondelete/RevisionDelete.php | 108 |
1 files changed, 82 insertions, 26 deletions
diff --git a/includes/revisiondelete/RevisionDelete.php b/includes/revisiondelete/RevisionDelete.php index 6ceadff4..71850877 100644 --- a/includes/revisiondelete/RevisionDelete.php +++ b/includes/revisiondelete/RevisionDelete.php @@ -41,6 +41,19 @@ class RevDel_RevisionList extends RevDel_List { return 'rev_id'; } + public static function getRestriction() { + return 'deleterevision'; + } + + public static function getRevdelConstant() { + return Revision::DELETED_TEXT; + } + + public static function suggestTarget( $target, array $ids ) { + $rev = Revision::newFromId( $ids[0] ); + return $rev ? $rev->getTitle() : $target; + } + /** * @param $db DatabaseBase * @return mixed @@ -52,7 +65,7 @@ class RevDel_RevisionList extends RevDel_List { array_merge( Revision::selectFields(), Revision::selectUserFields() ), array( 'rev_page' => $this->title->getArticleID(), - 'rev_id' => $ids, + 'rev_id' => $ids, ), __METHOD__, array( 'ORDER BY' => 'rev_id DESC' ), @@ -242,8 +255,7 @@ class RevDel_RevisionItem extends RevDel_Item { if ( $this->isDeleted() && !$this->canViewContent() ) { return $this->list->msg( 'diff' )->escaped(); } else { - return - Linker::linkKnown( + return Linker::linkKnown( $this->list->title, $this->list->msg( 'diff' )->escaped(), array(), @@ -293,7 +305,7 @@ class RevDel_ArchiveList extends RevDel_RevisionList { return $db->select( 'archive', '*', array( 'ar_namespace' => $this->title->getNamespace(), - 'ar_title' => $this->title->getDBkey(), + 'ar_title' => $this->title->getDBkey(), 'ar_timestamp' => $timestamps ), __METHOD__, @@ -350,12 +362,12 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem { $dbw->update( 'archive', array( 'ar_deleted' => $bits ), array( - 'ar_namespace' => $this->list->title->getNamespace(), - 'ar_title' => $this->list->title->getDBkey(), + 'ar_namespace' => $this->list->title->getNamespace(), + 'ar_title' => $this->list->title->getDBkey(), // use timestamp for index - 'ar_timestamp' => $this->row->ar_timestamp, - 'ar_rev_id' => $this->row->ar_rev_id, - 'ar_deleted' => $this->getBits() + 'ar_timestamp' => $this->row->ar_timestamp, + 'ar_rev_id' => $this->row->ar_rev_id, + 'ar_deleted' => $this->getBits() ), __METHOD__ ); return (bool)$dbw->affectedRows(); @@ -398,7 +410,6 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem { } } - /** * Item class for a archive table row by ar_rev_id -- actually * used via RevDel_RevisionList. @@ -424,7 +435,7 @@ class RevDel_ArchivedRevisionItem extends RevDel_ArchiveItem { $dbw->update( 'archive', array( 'ar_deleted' => $bits ), array( 'ar_rev_id' => $this->row->ar_rev_id, - 'ar_deleted' => $this->getBits() + 'ar_deleted' => $this->getBits() ), __METHOD__ ); return (bool)$dbw->affectedRows(); @@ -443,6 +454,14 @@ class RevDel_FileList extends RevDel_List { return 'oi_archive_name'; } + public static function getRestriction() { + return 'deleterevision'; + } + + public static function getRevdelConstant() { + return File::DELETED_FILE; + } + var $storeBatch, $deleteBatch, $cleanupBatch; /** @@ -451,12 +470,14 @@ class RevDel_FileList extends RevDel_List { */ public function doQuery( $db ) { $archiveNames = array(); - foreach( $this->ids as $timestamp ) { + foreach ( $this->ids as $timestamp ) { $archiveNames[] = $timestamp . '!' . $this->title->getDBkey(); } - return $db->select( 'oldimage', '*', + return $db->select( + 'oldimage', + OldLocalFile::selectFields(), array( - 'oi_name' => $this->title->getDBkey(), + 'oi_name' => $this->title->getDBkey(), 'oi_archive_name' => $archiveNames ), __METHOD__, @@ -498,9 +519,20 @@ class RevDel_FileList extends RevDel_List { } public function doPostCommitUpdates() { + global $wgUseSquid; $file = wfLocalFile( $this->title ); $file->purgeCache(); $file->purgeDescription(); + $purgeUrls = array(); + foreach ( $this->ids as $timestamp ) { + $archiveName = $timestamp . '!' . $this->title->getDBkey(); + $file->purgeOldThumbnails( $archiveName ); + $purgeUrls[] = $file->getArchiveUrl( $archiveName ); + } + if ( $wgUseSquid ) { + // purge full images from cache + SquidUpdate::purge( $purgeUrls ); + } return Status::newGood(); } @@ -623,8 +655,8 @@ class RevDel_FileItem extends RevDel_Item { array(), array( 'target' => $this->list->title->getPrefixedText(), - 'file' => $this->file->getArchiveName(), - 'token' => $this->list->getUser()->getEditToken( + 'file' => $this->file->getArchiveName(), + 'token' => $this->list->getUser()->getEditToken( $this->file->getArchiveName() ) ) ); @@ -636,13 +668,13 @@ class RevDel_FileItem extends RevDel_Item { * @return string HTML */ protected function getUserTools() { - if( $this->file->userCan( Revision::DELETED_USER, $this->list->getUser() ) ) { + if ( $this->file->userCan( Revision::DELETED_USER, $this->list->getUser() ) ) { $link = Linker::userLink( $this->file->user, $this->file->user_text ) . Linker::userToolLinks( $this->file->user, $this->file->user_text ); } else { $link = $this->list->msg( 'rev-deleted-user' )->escaped(); } - if( $this->file->isDeleted( Revision::DELETED_USER ) ) { + if ( $this->file->isDeleted( Revision::DELETED_USER ) ) { return '<span class="history-deleted">' . $link . '</span>'; } return $link; @@ -655,12 +687,12 @@ class RevDel_FileItem extends RevDel_Item { * @return string HTML */ protected function getComment() { - if( $this->file->userCan( File::DELETED_COMMENT, $this->list->getUser() ) ) { + if ( $this->file->userCan( File::DELETED_COMMENT, $this->list->getUser() ) ) { $block = Linker::commentBlock( $this->file->description ); } else { $block = ' ' . $this->list->msg( 'rev-deleted-comment' )->escaped(); } - if( $this->file->isDeleted( File::DELETED_COMMENT ) ) { + if ( $this->file->isDeleted( File::DELETED_COMMENT ) ) { return "<span class=\"history-deleted\">$block</span>"; } return $block; @@ -673,7 +705,7 @@ class RevDel_FileItem extends RevDel_Item { ' (' . $this->list->msg( 'nbytes' )->numParams( $this->file->getSize() )->text() . ')'; return '<li>' . $this->getLink() . ' ' . $this->getUserTools() . ' ' . - $data . ' ' . $this->getComment(). '</li>'; + $data . ' ' . $this->getComment() . '</li>'; } } @@ -695,10 +727,12 @@ class RevDel_ArchivedFileList extends RevDel_FileList { */ public function doQuery( $db ) { $ids = array_map( 'intval', $this->ids ); - return $db->select( 'filearchive', '*', + return $db->select( + 'filearchive', + ArchivedFile::selectFields(), array( 'fa_name' => $this->title->getDBkey(), - 'fa_id' => $ids + 'fa_id' => $ids ), __METHOD__, array( 'ORDER BY' => 'fa_id DESC' ) @@ -757,7 +791,7 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem { $this->file->getTimestamp(), $this->list->getUser() ) ); # Hidden files... - if( !$this->canViewContent() ) { + if ( !$this->canViewContent() ) { $link = $date; } else { $undelete = SpecialPage::getTitleFor( 'Undelete' ); @@ -770,7 +804,7 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem { ) ); } - if( $this->isDeleted() ) { + if ( $this->isDeleted() ) { $link = '<span class="history-deleted">' . $link . '</span>'; } return $link; @@ -789,6 +823,28 @@ class RevDel_LogList extends RevDel_List { return 'log_id'; } + public static function getRestriction() { + return 'deletelogentry'; + } + + public static function getRevdelConstant() { + return LogPage::DELETED_ACTION; + } + + public static function suggestTarget( $target, array $ids ) { + $result = wfGetDB( DB_SLAVE )->select( 'logging', + 'log_type', + array( 'log_id' => $ids ), + __METHOD__, + array( 'DISTINCT' ) + ); + if ( $result->numRows() == 1 ) { + // If there's only one type, the target can be set to include it. + return SpecialPage::getTitleFor( 'Log', $result->current()->log_type ); + } + return SpecialPage::getTitleFor( 'Log' ); + } + /** * @param $db DatabaseBase * @return mixed @@ -899,7 +955,7 @@ class RevDel_LogItem extends RevDel_Item { $action = $formatter->getActionText(); // Comment $comment = $this->list->getLanguage()->getDirMark() . Linker::commentBlock( $this->row->log_comment ); - if( LogEventsList::isDeleted($this->row,LogPage::DELETED_COMMENT) ) { + if ( LogEventsList::isDeleted( $this->row, LogPage::DELETED_COMMENT ) ) { $comment = '<span class="history-deleted">' . $comment . '</span>'; } |