* Added generic Rev_List revision listing class and refactored RevDelete_List stuff...
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 2 Jul 2011 09:04:32 +0000 (09:04 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 2 Jul 2011 09:04:32 +0000 (09:04 +0000)
* Fixed bug in revdelete where all list Items where assumed to be of the same type (no longer holds since r87804). This was causing "Undefined property: stdClass::$rev_timestamp" errors for deleted revs.
* Cleaned up RevisionDeleter::getRelationType()
* Minor cleanups to SpecialRevisionDelete

includes/AutoLoader.php
includes/RevisionList.php [new file with mode: 0644]
includes/revisiondelete/RevisionDelete.php
includes/revisiondelete/RevisionDeleteAbstracts.php
includes/revisiondelete/RevisionDeleter.php
includes/specials/SpecialRevisiondelete.php

index c493484..b81d976 100644 (file)
@@ -187,7 +187,10 @@ $wgAutoloadLocalClasses = array(
        'Replacer' => 'includes/StringUtils.php',
        'RequestContext' => 'includes/RequestContext.php',
        'ReverseChronologicalPager' => 'includes/Pager.php',
+       'Rev_Item' => 'includes/RevisionList.php',
+       'Rev_List' => 'includes/RevisionList.php',
        'Revision' => 'includes/Revision.php',
+       'RevisionList' => 'includes/RevisionList.php',
        'RSSFeed' => 'includes/Feed.php',
        'Sanitizer' => 'includes/Sanitizer.php',
        'SiteConfiguration' => 'includes/SiteConfiguration.php',
diff --git a/includes/RevisionList.php b/includes/RevisionList.php
new file mode 100644 (file)
index 0000000..e64ac5a
--- /dev/null
@@ -0,0 +1,354 @@
+<?php
+/**
+ * List for revision table items for a single page
+ */
+abstract class Rev_List {
+       /**
+        * @var Title
+        */
+       var $title;
+       /**
+        * @var RequestContext
+        */
+       var $context;
+
+       var $ids, $res, $current;
+
+       function __construct( RequestContext $context, Title $title, array $ids ) {
+               $this->context = $context;
+               $this->title = $title;
+               $this->ids = $ids;
+       }
+
+       /**
+        * Get the internal type name of this list. Equal to the table name.
+        * Override this function.
+        */
+       public function getType() {
+               return null;
+       }
+
+       /**
+        * Initialise the current iteration pointer
+        */
+       protected function initCurrent() {
+               $row = $this->res->current();
+               if ( $row ) {
+                       $this->current = $this->newItem( $row );
+               } else {
+                       $this->current = false;
+               }
+       }
+
+       /**
+        * Start iteration. This must be called before current() or next().
+        * @return First list item
+        */
+       public function reset() {
+               if ( !$this->res ) {
+                       $this->res = $this->doQuery( wfGetDB( DB_SLAVE ) );
+               } else {
+                       $this->res->rewind();
+               }
+               $this->initCurrent();
+               return $this->current;
+       }
+
+       /**
+        * Get the current list item, or false if we are at the end
+        */
+       public function current() {
+               return $this->current;
+       }
+
+       /**
+        * Move the iteration pointer to the next list item, and return it.
+        */
+       public function next() {
+               $this->res->next();
+               $this->initCurrent();
+               return $this->current;
+       }
+
+       /**
+        * Get the number of items in the list.
+        */
+       public function length() {
+               if( !$this->res ) {
+                       return 0;
+               } else {
+                       return $this->res->numRows();
+               }
+       }
+
+       /**
+        * Do the DB query to iterate through the objects.
+        * @param $db DatabaseBase object to use for the query
+        */
+       abstract public function doQuery( $db );
+
+       /**
+        * Create an item object from a DB result row
+        * @param $row stdclass
+        */
+       abstract public function newItem( $row );
+
+       /**
+        * Get the language of the user doing the action
+        *
+        * @return Language object
+        */
+       public function getLang() {
+               return $this->context->getLang();
+       }
+
+       /**
+        * Get the user doing the action
+        *
+        * @return User object
+        */
+       public function getUser() {
+               return $this->context->getUser();
+       }
+}
+
+/**
+ * Abstract base class for revision items
+ */
+abstract class Rev_Item {
+       /** The parent Rev_List */
+       var $list;
+
+       /** The DB result row */
+       var $row;
+
+       /**
+        * @param $list Rev_List
+        * @param $row DB result row
+        */
+       public function __construct( $list, $row ) {
+               $this->list = $list;
+               $this->row = $row;
+       }
+
+       /**
+        * Get the DB field name associated with the ID list.
+        * Override this function.
+        */
+       public function getIdField() {
+               return null;
+       }
+
+       /**
+        * Get the DB field name storing timestamps.
+        * Override this function.
+        */
+       public function getTimestampField() {
+               return false;
+       }
+
+       /**
+        * Get the DB field name storing user ids.
+        * Override this function.
+        */
+       public function getAuthorIdField() {
+               return false;
+       }
+
+       /**
+        * Get the DB field name storing user names.
+        * Override this function.
+        */
+       public function getAuthorNameField() {
+               return false;
+       }
+
+       /**
+        * Get the ID, as it would appear in the ids URL parameter
+        */
+       public function getId() {
+               $field = $this->getIdField();
+               return $this->row->$field;
+       }
+
+       /**
+        * Get the date, formatted with $wgLang
+        */
+       public function formatDate() {
+               global $wgLang;
+               return $wgLang->date( $this->getTimestamp() );
+       }
+
+       /**
+        * Get the time, formatted with $wgLang
+        */
+       public function formatTime() {
+               global $wgLang;
+               return $wgLang->time( $this->getTimestamp() );
+       }
+
+       /**
+        * Get the timestamp in MW 14-char form
+        */
+       public function getTimestamp() {
+               $field = $this->getTimestampField();
+               return wfTimestamp( TS_MW, $this->row->$field );
+       }
+
+       /**
+        * Get the author user ID
+        */
+       public function getAuthorId() {
+               $field = $this->getAuthorIdField();
+               return intval( $this->row->$field );
+       }
+
+       /**
+        * Get the author user name
+        */
+       public function getAuthorName() {
+               $field = $this->getAuthorNameField();
+               return strval( $this->row->$field );
+       }
+
+       /**
+        * Returns true if the current user can view the item
+        */
+       abstract public function canView();
+
+       /**
+        * Returns true if the current user can view the item text/file
+        */
+       abstract public function canViewContent();
+
+       /**
+        * Get the HTML of the list item. Should be include <li></li> tags.
+        * This is used to show the list in HTML form, by the special page.
+        */
+       abstract public function getHTML();
+}
+
+class RevisionList extends Rev_List {
+       public function getType() {
+               return 'revision';
+       }
+
+       /**
+        * @param $db DatabaseBase
+        * @return mixed
+        */
+       public function doQuery( $db ) {
+               $ids = array_map( 'intval', $this->ids );
+               return $db->select( array('revision','page'), '*',
+                       array(
+                               'rev_page' => $this->title->getArticleID(),
+                               'rev_id'   => array_map( 'intval', $this->ids ),
+                               'rev_page = page_id'
+                       ),
+                       __METHOD__,
+                       array( 'ORDER BY' => 'rev_id DESC' )
+               );
+       }
+
+       public function newItem( $row ) {
+               return new RevisionItem( $this, $row );
+       }
+}
+
+/**
+ * Item class for a live revision table row
+ */
+class RevisionItem extends Rev_Item {
+       var $revision, $context;
+
+       public function __construct( $list, $row ) {
+               parent::__construct( $list, $row );
+               $this->revision = new Revision( $row );
+               $this->context = $list->context;
+       }
+
+       public function getIdField() {
+               return 'rev_id';
+       }
+
+       public function getTimestampField() {
+               return 'rev_timestamp';
+       }
+
+       public function getAuthorIdField() {
+               return 'rev_user';
+       }
+
+       public function getAuthorNameField() {
+               return 'rev_user_text';
+       }
+
+       public function canView() {
+               return $this->revision->userCan( Revision::DELETED_RESTRICTED );
+       }
+
+       public function canViewContent() {
+               return $this->revision->userCan( Revision::DELETED_TEXT );
+       }
+
+       public function isDeleted() {
+               return $this->revision->isDeleted( Revision::DELETED_TEXT );
+       }
+
+       /**
+        * Get the HTML link to the revision text.
+        * Overridden by RevDel_ArchiveItem.
+        */
+       protected function getRevisionLink() {
+               $date = $this->list->getLang()->timeanddate( $this->revision->getTimestamp(), true );
+               if ( $this->isDeleted() && !$this->canViewContent() ) {
+                       return $date;
+               }
+               return Linker::link(
+                       $this->list->title,
+                       $date,
+                       array(),
+                       array(
+                               'oldid' => $this->revision->getId(),
+                               'unhide' => 1
+                       )
+               );
+       }
+
+       /**
+        * Get the HTML link to the diff.
+        * Overridden by RevDel_ArchiveItem
+        */
+       protected function getDiffLink() {
+               if ( $this->isDeleted() && !$this->canViewContent() ) {
+                       return wfMsgHtml('diff');
+               } else {
+                       return
+                               Linker::link(
+                                       $this->list->title,
+                                       wfMsgHtml('diff'),
+                                       array(),
+                                       array(
+                                               'diff' => $this->revision->getId(),
+                                               'oldid' => 'prev',
+                                               'unhide' => 1
+                                       ),
+                                       array(
+                                               'known',
+                                               'noclasses'
+                                       )
+                               );
+               }
+       }
+
+       public function getHTML() {
+               $difflink = $this->getDiffLink();
+               $revlink = $this->getRevisionLink();
+               $userlink = Linker::revUserLink( $this->revision );
+               $comment = Linker::revComment( $this->revision );
+               if ( $this->isDeleted() ) {
+                       $revlink = "<span class=\"history-deleted\">$revlink</span>";
+               }
+               return "<li>($difflink) $revlink $userlink $comment</li>";
+       }
+}
index 00c8ab2..a7902f3 100644 (file)
  */
 class RevDel_RevisionList extends RevDel_List {
        var $currentRevId;
-       var $type = 'revision';
-       var $idField = 'rev_id';
-       var $dateField = 'rev_timestamp';
-       var $authorIdField = 'rev_user';
-       var $authorNameField = 'rev_user_text';
+
+       public function getType() {
+               return 'revision';
+       }
+
+       public static function getRelationType() {
+               return 'rev_id';
+       }
 
        /**
         * @param $db DatabaseBase
@@ -112,6 +115,22 @@ class RevDel_RevisionItem extends RevDel_Item {
                $this->revision = new Revision( $row );
        }
 
+       public function getIdField() {
+               return 'rev_id';
+       }
+
+       public function getTimestampField() {
+               return 'rev_timestamp';
+       }
+
+       public function getAuthorIdField() {
+               return 'rev_user';
+       }
+
+       public function getAuthorNameField() {
+               return 'rev_user_text';
+       }
+
        public function canView() {
                return $this->revision->userCan( Revision::DELETED_RESTRICTED );
        }
@@ -170,7 +189,7 @@ class RevDel_RevisionItem extends RevDel_Item {
         * Overridden by RevDel_ArchiveItem.
         */
        protected function getRevisionLink() {
-               $date = $this->getLang()->timeanddate( $this->revision->getTimestamp(), true );
+               $date = $this->list->getLang()->timeanddate( $this->revision->getTimestamp(), true );
                if ( $this->isDeleted() && !$this->canViewContent() ) {
                        return $date;
                }
@@ -227,11 +246,13 @@ class RevDel_RevisionItem extends RevDel_Item {
  * List for archive table items, i.e. revisions deleted via action=delete
  */
 class RevDel_ArchiveList extends RevDel_RevisionList {
-       var $type = 'archive';
-       var $idField = 'ar_timestamp';
-       var $dateField = 'ar_timestamp';
-       var $authorIdField = 'ar_user';
-       var $authorNameField = 'ar_user_text';
+       public function getType() {
+               return 'archive';
+       }
+
+       public static function getRelationType() {
+               return 'ar_timestamp';
+       }
 
        /**
         * @param $db DatabaseBase
@@ -276,6 +297,22 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem {
                        array( 'page' => $this->list->title->getArticleId() ) );
        }
 
+       public function getIdField() {
+               return 'ar_timestamp';
+       }
+
+       public function getTimestampField() {
+               return 'ar_timestamp';
+       }
+
+       public function getAuthorIdField() {
+               return 'ar_user';
+       }
+
+       public function getAuthorNameField() {
+               return 'ar_user_text';
+       }
+
        public function getId() {
                # Convert DB timestamp to MW timestamp
                return $this->revision->getTimestamp();
@@ -285,12 +322,13 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem {
                $dbw = wfGetDB( DB_MASTER );
                $dbw->update( 'archive',
                        array( 'ar_deleted' => $bits ),
-                       array( 'ar_namespace' => $this->list->title->getNamespace(),
-                               'ar_title'     => $this->list->title->getDBkey(),
+                       array(
+                               '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();
@@ -298,7 +336,7 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem {
 
        protected function getRevisionLink() {
                $undelete = SpecialPage::getTitleFor( 'Undelete' );
-               $date = $this->getLang()->timeanddate( $this->revision->getTimestamp(), true );
+               $date = $this->list->getLang()->timeanddate( $this->revision->getTimestamp(), true );
                if ( $this->isDeleted() && !$this->canViewContent() ) {
                        return $date;
                }
@@ -336,6 +374,10 @@ class RevDel_ArchivedRevisionItem extends RevDel_ArchiveItem {
                        array( 'page' => $this->list->title->getArticleId() ) );
        }
 
+       public function getIdField() {
+               return 'ar_rev_id';
+       }
+
        public function getId() {
                return $this->revision->getId();
        }
@@ -356,11 +398,14 @@ class RevDel_ArchivedRevisionItem extends RevDel_ArchiveItem {
  * List for oldimage table items
  */
 class RevDel_FileList extends RevDel_List {
-       var $type = 'oldimage';
-       var $idField = 'oi_archive_name';
-       var $dateField = 'oi_timestamp';
-       var $authorIdField = 'oi_user';
-       var $authorNameField = 'oi_user_text';
+       public function getType() {
+               return 'oldimage';
+       }
+
+       public static function getRelationType() {
+               return 'oi_archive_name';
+       }
+
        var $storeBatch, $deleteBatch, $cleanupBatch;
 
        /**
@@ -442,6 +487,22 @@ class RevDel_FileItem extends RevDel_Item {
                $this->file = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row );
        }
 
+       public function getIdField() {
+               return 'oi_archive_name';
+       }
+
+       public function getTimestampField() {
+               return 'oi_timestamp';
+       }
+
+       public function getAuthorIdField() {
+               return 'oi_user';
+       }
+
+       public function getAuthorNameField() {
+               return 'oi_user_text';
+       }
+
        public function getId() {
                $parts = explode( '!', $this->row->oi_archive_name );
                return $parts[0];
@@ -506,7 +567,7 @@ class RevDel_FileItem extends RevDel_Item {
         * Overridden by RevDel_ArchivedFileItem.
         */
        protected function getLink() {
-               $date = $this->getLang()->timeanddate( $this->file->getTimestamp(), true  );
+               $date = $this->list->getLang()->timeanddate( $this->file->getTimestamp(), true  );
                if ( $this->isDeleted() ) {
                        # Hidden files...
                        if ( !$this->canViewContent() ) {
@@ -518,7 +579,8 @@ class RevDel_FileItem extends RevDel_Item {
                                        array(
                                                'target' => $this->list->title->getPrefixedText(),
                                                'file'   => $this->file->getArchiveName(),
-                                               'token'  => $this->getUser()->editToken( $this->file->getArchiveName() )
+                                               'token'  => $this->list->getUser()->editToken(
+                                                       $this->file->getArchiveName() )
                                        )
                                );
                        }
@@ -567,11 +629,11 @@ class RevDel_FileItem extends RevDel_Item {
                $data =
                        wfMsg(
                                'widthheight',
-                               $this->getLang()->formatNum( $this->file->getWidth() ),
-                               $this->getLang()->formatNum( $this->file->getHeight() )
+                               $this->list->getLang()->formatNum( $this->file->getWidth() ),
+                               $this->list->getLang()->formatNum( $this->file->getHeight() )
                        ) .
                        ' (' .
-                       wfMsgExt( 'nbytes', 'parsemag', $this->getLang()->formatNum( $this->file->getSize() ) ) .
+                       wfMsgExt( 'nbytes', 'parsemag', $this->list->getLang()->formatNum( $this->file->getSize() ) ) .
                        ')';
 
                return '<li>' . $this->getLink() . ' ' . $this->getUserTools() . ' ' .
@@ -583,11 +645,13 @@ class RevDel_FileItem extends RevDel_Item {
  * List for filearchive table items
  */
 class RevDel_ArchivedFileList extends RevDel_FileList {
-       var $type = 'filearchive';
-       var $idField = 'fa_id';
-       var $dateField = 'fa_timestamp';
-       var $authorIdField = 'fa_user';
-       var $authorNameField = 'fa_user_text';
+       public function getType() {
+               return 'filearchive';
+       }
+
+       public static function getRelationType() {
+               return 'fa_id';
+       }
 
        /**
         * @param $db DatabaseBase
@@ -619,6 +683,22 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem {
                $this->file = ArchivedFile::newFromRow( $row );
        }
 
+       public function getIdField() {
+               return 'fa_id';
+       }
+
+       public function getTimestampField() {
+               return 'fa_timestamp';
+       }
+
+       public function getAuthorIdField() {
+               return 'fa_user';
+       }
+
+       public function getAuthorNameField() {
+               return 'fa_user_text';
+       }
+
        public function getId() {
                return $this->row->fa_id;
        }
@@ -637,7 +717,7 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem {
        }
 
        protected function getLink() {
-               $date = $this->getLang()->timeanddate( $this->file->getTimestamp(), true  );
+               $date = $this->list->getLang()->timeanddate( $this->file->getTimestamp(), true  );
                $undelete = SpecialPage::getTitleFor( 'Undelete' );
                $key = $this->file->getKey();
                # Hidden files...
@@ -648,7 +728,7 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem {
                                array(
                                        'target' => $this->list->title->getPrefixedText(),
                                        'file' => $key,
-                                       'token' => $this->getUser()->editToken( $key )
+                                       'token' => $this->list->getUser()->editToken( $key )
                                )
                        );
                }
@@ -663,11 +743,13 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem {
  * List for logging table items
  */
 class RevDel_LogList extends RevDel_List {
-       var $type = 'logging';
-       var $idField = 'log_id';
-       var $dateField = 'log_timestamp';
-       var $authorIdField = 'log_user';
-       var $authorNameField = 'log_user_text';
+       public function getType() {
+               return 'logging';
+       }
+
+       public static function getRelationType() {
+               return 'log_id';
+       }
 
        /**
         * @param $db DatabaseBase
@@ -707,6 +789,22 @@ class RevDel_LogList extends RevDel_List {
  * Item class for a logging table row
  */
 class RevDel_LogItem extends RevDel_Item {
+       public function getIdField() {
+               return 'log_id';
+       }
+
+       public function getTimestampField() {
+               return 'log_timestamp';
+       }
+
+       public function getAuthorIdField() {
+               return 'log_user';
+       }
+
+       public function getAuthorNameField() {
+               return 'log_user_text';
+       }
+
        public function canView() {
                return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED );
        }
@@ -744,7 +842,7 @@ class RevDel_LogItem extends RevDel_Item {
        }
 
        public function getHTML() {
-               $date = htmlspecialchars( $this->getLang()->timeanddate( $this->row->log_timestamp ) );
+               $date = htmlspecialchars( $this->list->getLang()->timeanddate( $this->row->log_timestamp ) );
                $paramArray = LogPage::extractParams( $this->row->log_params );
                $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
 
@@ -771,7 +869,7 @@ class RevDel_LogItem extends RevDel_Item {
                        $userLink = '<span class="history-deleted">' . $userLink . '</span>';
                }
                // Comment
-               $comment = $this->getLang()->getDirMark() . Linker::commentBlock( $this->row->log_comment );
+               $comment = $this->list->getLang()->getDirMark() . Linker::commentBlock( $this->row->log_comment );
                if( LogEventsList::isDeleted($this->row,LogPage::DELETED_COMMENT) ) {
                        $comment = '<span class="history-deleted">' . $comment . '</span>';
                }
index 72d8652..de39053 100644 (file)
@@ -6,65 +6,16 @@
  * relevant rows, to return RevDel_Item subclasses wrapping them, and
  * to wrap bulk update operations.
  */
-abstract class RevDel_List {
-
-       /**
-        * @var Title
-        */
-       var $title;
-
-       var $special, $ids, $res, $current;
-       var $type = null; // override this
-       var $idField = null; // override this
-       var $dateField = false; // override this
-       var $authorIdField = false; // override this
-       var $authorNameField = false; // override this
-
+abstract class RevDel_List extends Rev_List {
        /**
-        * @param $special The parent SpecialPage
-        * @param $title The target title
-        * @param $ids Array of IDs
+        * Get the DB field name associated with the ID list.
+        * This used to populate the log_search table for finding log entries.
+        * Override this function.
         */
-       public function __construct( $special, $title, $ids ) {
-               $this->special = $special;
-               $this->title = $title;
-               $this->ids = $ids;
+       public static function getRelationType() {
+               return null;
        }
 
-       /**
-        * Get the internal type name of this list. Equal to the table name.
-        */
-       public function getType() {
-               return $this->type;
-       }
-
-       /**
-        * Get the DB field name associated with the ID list
-        */
-       public function getIdField() {
-               return $this->idField;
-       }
-
-       /**
-        * Get the DB field name storing timestamps
-        */
-       public function getTimestampField() {
-               return $this->dateField;
-       }
-
-       /**
-        * Get the DB field name storing user ids
-        */
-       public function getAuthorIdField() {
-               return $this->authorIdField;
-       }
-
-       /**
-        * Get the DB field name storing user names
-        */
-       public function getAuthorNameField() {
-               return $this->authorNameField;
-       }
        /**
         * Set the visibility for the revisions in this list. Logging and
         * transactions are done here.
@@ -252,59 +203,6 @@ abstract class RevDel_List {
                );
        }
 
-       /**
-        * Initialise the current iteration pointer
-        */
-       protected function initCurrent() {
-               $row = $this->res->current();
-               if ( $row ) {
-                       $this->current = $this->newItem( $row );
-               } else {
-                       $this->current = false;
-               }
-       }
-
-       /**
-        * Start iteration. This must be called before current() or next().
-        * @return First list item
-        */
-       public function reset() {
-               if ( !$this->res ) {
-                       $this->res = $this->doQuery( wfGetDB( DB_SLAVE ) );
-               } else {
-                       $this->res->rewind();
-               }
-               $this->initCurrent();
-               return $this->current;
-       }
-
-       /**
-        * Get the current list item, or false if we are at the end
-        */
-       public function current() {
-               return $this->current;
-       }
-
-       /**
-        * Move the iteration pointer to the next list item, and return it.
-        */
-       public function next() {
-               $this->res->next();
-               $this->initCurrent();
-               return $this->current;
-       }
-
-       /**
-        * Get the number of items in the list.
-        */
-       public function length() {
-               if( !$this->res ) {
-                       return 0;
-               } else {
-                       return $this->res->numRows();
-               }
-       }
-
        /**
         * Clear any data structures needed for doPreCommitUpdates() and doPostCommitUpdates()
         * STUB
@@ -330,36 +228,6 @@ abstract class RevDel_List {
                return Status::newGood();
        }
 
-       /**
-        * Get the user doing the action
-        *
-        * @return User object
-        */
-       public function getUser() {
-               return $this->special->getUser();
-       }
-
-       /**
-        * Get the language of the user doing the action
-        *
-        * @return Language object
-        */
-       public function getLang() {
-               return $this->special->getLang();
-       }
-
-       /**
-        * Create an item object from a DB result row
-        * @param $row stdclass
-        */
-       abstract public function newItem( $row );
-
-       /**
-        * Do the DB query to iterate through the objects.
-        * @param $db DatabaseBase object to use for the query
-        */
-       abstract public function doQuery( $db );
-
        /**
         * Get the integer value of the flag used for suppression
         */
@@ -369,74 +237,7 @@ abstract class RevDel_List {
 /**
  * Abstract base class for deletable items
  */
-abstract class RevDel_Item {
-       /** The parent SpecialPage */
-       var $special;
-
-       /** The parent RevDel_List */
-       var $list;
-
-       /** The DB result row */
-       var $row;
-
-       /**
-        * @param $list RevDel_List
-        * @param $row DB result row
-        */
-       public function __construct( $list, $row ) {
-               $this->special = $list->special;
-               $this->list = $list;
-               $this->row = $row;
-       }
-
-       /**
-        * Get the ID, as it would appear in the ids URL parameter
-        */
-       public function getId() {
-               $field = $this->list->getIdField();
-               return $this->row->$field;
-       }
-
-       /**
-        * Get the date, formatted with $wgLang
-        */
-       public function formatDate() {
-               global $wgLang;
-               return $wgLang->date( $this->getTimestamp() );
-       }
-
-       /**
-        * Get the time, formatted with $wgLang
-        */
-       public function formatTime() {
-               global $wgLang;
-               return $wgLang->time( $this->getTimestamp() );
-       }
-
-       /**
-        * Get the timestamp in MW 14-char form
-        */
-       public function getTimestamp() {
-               $field = $this->list->getTimestampField();
-               return wfTimestamp( TS_MW, $this->row->$field );
-       }
-
-       /**
-        * Get the author user ID
-        */
-       public function getAuthorId() {
-               $field = $this->list->getAuthorIdField();
-               return intval( $this->row->$field );
-       }
-
-       /**
-        * Get the author user name
-        */
-       public function getAuthorName() {
-               $field = $this->list->getAuthorNameField();
-               return strval( $this->row->$field );
-       }
-
+abstract class RevDel_Item extends Rev_Item {
        /**
         * Returns true if the item is "current", and the operation to set the given
         * bits can't be executed for that reason
@@ -446,45 +247,11 @@ abstract class RevDel_Item {
                return false;
        }
 
-       /**
-        * Get the user doing the action
-        *
-        * @return User object
-        */
-       public function getUser() {
-               return $this->special->getUser();
-       }
-
-       /**
-        * Get the language of the user doing the action
-        *
-        * @return Language object
-        */
-       public function getLang() {
-               return $this->special->getLang();
-       }
-
-       /**
-        * Returns true if the current user can view the item
-        */
-       abstract public function canView();
-
-       /**
-        * Returns true if the current user can view the item text/file
-        */
-       abstract public function canViewContent();
-
        /**
         * Get the current deletion bitfield value
         */
        abstract public function getBits();
 
-       /**
-        * Get the HTML of the list item. Should be include <li></li> tags.
-        * This is used to show the list in HTML form, by the special page.
-        */
-       abstract public function getHTML();
-
        /**
         * Set the visibility of the item. This should do any necessary DB queries.
         *
index 2bd886e..0fbc995 100644 (file)
@@ -119,8 +119,7 @@ class RevisionDeleter {
                }
                if ( isset( SpecialRevisionDelete::$allowedTypes[$typeName] ) ) {
                        $class = SpecialRevisionDelete::$allowedTypes[$typeName]['list-class'];
-                       $list = new $class( null, null, null );
-                       return $list->getIdField();
+                       return call_user_func( array( $class, 'getRelationType' ) );
                } else {
                        return null;
                }
index 9922602..3c64325 100644 (file)
@@ -61,39 +61,39 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
         */
        static $allowedTypes = array(
                'revision' => array(
-                       'check-label' => 'revdelete-hide-text',
+                       'check-label'   => 'revdelete-hide-text',
                        'deletion-bits' => Revision::DELETED_TEXT,
-                       'success' => 'revdelete-success',
-                       'failure' => 'revdelete-failure',
-                       'list-class' => 'RevDel_RevisionList',
+                       'success'               => 'revdelete-success',
+                       'failure'               => 'revdelete-failure',
+                       'list-class'    => 'RevDel_RevisionList',
                ),
                'archive' => array(
-                       'check-label' => 'revdelete-hide-text',
+                       'check-label'   => 'revdelete-hide-text',
                        'deletion-bits' => Revision::DELETED_TEXT,
-                       'success' => 'revdelete-success',
-                       'failure' => 'revdelete-failure',
-                       'list-class' => 'RevDel_ArchiveList',
+                       'success'               => 'revdelete-success',
+                       'failure'               => 'revdelete-failure',
+                       'list-class'    => 'RevDel_ArchiveList',
                ),
                'oldimage'=> array(
-                       'check-label' => 'revdelete-hide-image',
+                       'check-label'   => 'revdelete-hide-image',
                        'deletion-bits' => File::DELETED_FILE,
-                       'success' => 'revdelete-success',
-                       'failure' => 'revdelete-failure',
-                       'list-class' => 'RevDel_FileList',
+                       'success'               => 'revdelete-success',
+                       'failure'               => 'revdelete-failure',
+                       'list-class'    => 'RevDel_FileList',
                ),
                'filearchive' => array(
-                       'check-label' => 'revdelete-hide-image',
+                       'check-label'   => 'revdelete-hide-image',
                        'deletion-bits' => File::DELETED_FILE,
-                       'success' => 'revdelete-success',
-                       'failure' => 'revdelete-failure',
-                       'list-class' => 'RevDel_ArchivedFileList',
+                       'success'               => 'revdelete-success',
+                       'failure'               => 'revdelete-failure',
+                       'list-class'    => 'RevDel_ArchivedFileList',
                ),
                'logging' => array(
-                       'check-label' => 'revdelete-hide-name',
+                       'check-label'   => 'revdelete-hide-name',
                        'deletion-bits' => LogPage::DELETED_ACTION,
-                       'success' => 'logdelete-success',
-                       'failure' => 'logdelete-failure',
-                       'list-class' => 'RevDel_LogList',
+                       'success'               => 'logdelete-success',
+                       'failure'               => 'logdelete-failure',
+                       'list-class'    => 'RevDel_LogList',
                ),
        );
 
@@ -258,7 +258,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
        protected function getLogQueryCond() {
                $conds = array();
                // Revision delete logs for these item
-               $conds['log_type'] = array('delete','suppress');
+               $conds['log_type'] = array( 'delete', 'suppress' );
                $conds['log_action'] = $this->getList()->getLogAction();
                $conds['ls_field'] = RevisionDeleter::getRelationType( $this->typeName );
                $conds['ls_value'] = $this->ids;
@@ -328,7 +328,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
        protected function getList() {
                if ( is_null( $this->list ) ) {
                        $class = $this->typeInfo['list-class'];
-                       $this->list = new $class( $this, $this->targetObj, $this->ids );
+                       $this->list = new $class( $this->getContext(), $this->targetObj, $this->ids );
                }
                return $this->list;
        }
@@ -506,7 +506,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
         */
        protected function submit() {
                # Check edit token on submission
-               if( $this->submitClicked && !$this->getUser()->matchEditToken( $this->getRequest()->getVal('wpEditToken') ) ) {
+               $token = $this->getRequest()->getVal('wpEditToken');
+               if( $this->submitClicked && !$this->getUser()->matchEditToken( $token ) ) {
                        $this->getOutput()->addWikiMsg( 'sessionfailure' );
                        return false;
                }