Revert r85288 (magic accessors for RequestContext); much more trouble than they're...
[lhc/web/wiklou.git] / includes / revisiondelete / RevisionDelete.php
index a53c2b6..00c8ab2 100644 (file)
 <?php
-/**
- * Revision/log/file deletion backend
- *
- * @file
- */
-
-/**
- * Temporary b/c interface, collection of static functions.
- * @ingroup SpecialPage
- */
-class RevisionDeleter {
-       /**
-        * Checks for a change in the bitfield for a certain option and updates the
-        * provided array accordingly.
-        *
-        * @param $desc String: description to add to the array if the option was
-        * enabled / disabled.
-        * @param $field Integer: the bitmask describing the single option.
-        * @param $diff Integer: the xor of the old and new bitfields.
-        * @param $new Integer: the new bitfield 
-        * @param $arr Array: the array to update.
-        */
-       protected static function checkItem( $desc, $field, $diff, $new, &$arr ) {
-               if( $diff & $field ) {
-                       $arr[ ( $new & $field ) ? 0 : 1 ][] = $desc;
-               }
-       }
-
-       /**
-        * Gets an array of message keys describing the changes made to the visibility
-        * of the revision. If the resulting array is $arr, then $arr[0] will contain an 
-        * array of strings describing the items that were hidden, $arr[2] will contain 
-        * an array of strings describing the items that were unhidden, and $arr[3] will 
-        * contain an array with a single string, which can be one of "applied 
-        * restrictions to sysops", "removed restrictions from sysops", or null.
-        *
-        * @param $n Integer: the new bitfield.
-        * @param $o Integer: the old bitfield.
-        * @return An array as described above.
-        */
-       protected static function getChanges( $n, $o ) {
-               $diff = $n ^ $o;
-               $ret = array( 0 => array(), 1 => array(), 2 => array() );
-               // Build bitfield changes in language
-               self::checkItem( 'revdelete-content',
-                       Revision::DELETED_TEXT, $diff, $n, $ret );
-               self::checkItem( 'revdelete-summary',
-                       Revision::DELETED_COMMENT, $diff, $n, $ret );
-               self::checkItem( 'revdelete-uname',
-                       Revision::DELETED_USER, $diff, $n, $ret );
-               // Restriction application to sysops
-               if( $diff & Revision::DELETED_RESTRICTED ) {
-                       if( $n & Revision::DELETED_RESTRICTED )
-                               $ret[2][] = 'revdelete-restricted';
-                       else
-                               $ret[2][] = 'revdelete-unrestricted';
-               }
-               return $ret;
-       }
-
-       /**
-        * Gets a log message to describe the given revision visibility change. This
-        * message will be of the form "[hid {content, edit summary, username}];
-        * [unhid {...}][applied restrictions to sysops] for $count revisions: $comment".
-        *
-        * @param $count Integer: The number of effected revisions.
-        * @param $nbitfield Integer: The new bitfield for the revision.
-        * @param $obitfield Integer: The old bitfield for the revision.
-        * @param $isForLog Boolean
-        * @param $forContent Boolean
-        */
-       public static function getLogMessage( $count, $nbitfield, $obitfield, $isForLog = false, $forContent = false ) {
-               global $wgLang, $wgContLang;
-               
-               $lang = $forContent ? $wgContLang : $wgLang;
-               $msgFunc = $forContent ? "wfMsgForContent" : "wfMsg";
-               
-               $changes = self::getChanges( $nbitfield, $obitfield );
-               array_walk($changes, 'RevisionDeleter::expandMessageArray', $forContent);
-               
-               $changesText = array();
-               
-               if( count( $changes[0] ) ) {
-                       $changesText[] = $msgFunc( 'revdelete-hid', $lang->commaList( $changes[0] ) );
-               }
-               if( count( $changes[1] ) ) {
-                       $changesText[] = $msgFunc( 'revdelete-unhid', $lang->commaList( $changes[1] ) );
-               }
-               
-               $s = $lang->semicolonList( $changesText );
-               if( count( $changes[2] ) ) {
-                       $s .= $s ? ' (' . $changes[2][0] . ')' : ' ' . $changes[2][0];
-               }
-               
-               $msg = $isForLog ? 'logdelete-log-message' : 'revdelete-log-message';
-               return wfMsgExt( $msg, $forContent ? array( 'parsemag', 'content' ) : array( 'parsemag' ), $s, $lang->formatNum($count) );
-       }
-       
-       private static function expandMessageArray(& $msg, $key, $forContent) {
-               if ( is_array ($msg) ) {
-                       array_walk($msg, 'RevisionDeleter::expandMessageArray', $forContent);
-               } else {
-                       if ( $forContent ) {
-                               $msg = wfMsgForContent($msg);
-                       } else {
-                               $msg = wfMsg($msg);
-                       }
-               }
-       }
-       
-       // Get DB field name for URL param...
-       // Future code for other things may also track
-       // other types of revision-specific changes.
-       // @returns string One of log_id/rev_id/fa_id/ar_timestamp/oi_archive_name
-       public static function getRelationType( $typeName ) {
-               if ( isset( SpecialRevisionDelete::$deprecatedTypeMap[$typeName] ) ) {
-                       $typeName = SpecialRevisionDelete::$deprecatedTypeMap[$typeName];
-               }
-               if ( isset( SpecialRevisionDelete::$allowedTypes[$typeName] ) ) {
-                       $class = SpecialRevisionDelete::$allowedTypes[$typeName]['list-class'];
-                       $list = new $class( null, null, null );
-                       return $list->getIdField();
-               } else {
-                       return null;
-               }
-       }
-       
-       // Checks if a revision still exists in the revision table.
-       //  If it doesn't, returns the corresponding ar_timestamp field
-       //  so that this key can be used instead.
-       public static function checkRevisionExistence( $title, $revid ) {
-               $dbr = wfGetDB( DB_SLAVE );
-               $exists = $dbr->selectField( 'revision', '1',
-                               array( 'rev_id' => $revid ), __METHOD__ );
-                               
-               if ( $exists ) {
-                       return true;
-               }
-               
-               $timestamp = $dbr->selectField( 'archive', 'ar_timestamp',
-                               array( 'ar_namespace' => $title->getNamespace(),
-                                       'ar_title' => $title->getDBkey(),
-                                       'ar_rev_id' => $revid ), __METHOD__ );
-               
-               return $timestamp;
-       }
-       
-       // Creates utility links for log entries.
-       public static function getLogLinks( $title, $paramArray, $skin, $messages ) {
-               global $wgLang;
-               
-               if( count($paramArray) >= 2 ) {
-                       // Different revision types use different URL params...
-                       $originalKey = $key = $paramArray[0];
-                       // $paramArray[1] is a CSV of the IDs
-                       $Ids = explode( ',', $paramArray[1] );
-
-                       $revert = array();
-                       
-                       // For if undeleted revisions are found amidst deleted ones.
-                       $undeletedRevisions = array();
-                       
-                       // This is not going to work if some revs are deleted and some
-                       //  aren't.
-                       if ($key == 'revision') {
-                               foreach( $Ids as $k => $id ) {
-                                       $existResult =
-                                               self::checkRevisionExistence( $title, $id );
-                                       
-                                       if ($existResult !== true) {
-                                               $key = 'archive';
-                                               $Ids[$k] = $existResult;
-                                       } else {
-                                               // Undeleted revision amidst deleted ones
-                                               unset($Ids[$k]);
-                                               $undeletedRevisions[] = $id;
-                                       }
-                               }
-                               
-                               if ( $key == $originalKey ) {
-                                       $Ids = $undeletedRevisions;
-                                       $undeletedRevisions = array();
-                               }
-                       }
-                       
-                       // Diff link for single rev deletions
-                       if( count($Ids) == 1 && !count($undeletedRevisions) ) {
-                               // Live revision diffs...
-                               if( in_array( $key, array( 'oldid', 'revision' ) ) ) {
-                                       $revert[] = $skin->link(
-                                               $title,
-                                               $messages['diff'],
-                                               array(),
-                                               array(
-                                                       'diff' => intval( $Ids[0] ),
-                                                       'unhide' => 1
-                                               ),
-                                               array( 'known', 'noclasses' )
-                                       );
-                               // Deleted revision diffs...
-                               } else if( in_array( $key, array( 'artimestamp','archive' ) ) ) {
-                                       $revert[] = $skin->link(
-                                               SpecialPage::getTitleFor( 'Undelete' ),
-                                               $messages['diff'], 
-                                               array(),
-                                               array(
-                                                       'target'    => $title->getPrefixedDBKey(),
-                                                       'diff'      => 'prev',
-                                                       'timestamp' => $Ids[0]
-                                               ),
-                                               array( 'known', 'noclasses' )
-                                       );
-                               }
-                       }
-                       
-                       // View/modify link...
-                       if ( count($undeletedRevisions) ) {
-                               // FIXME THIS IS A HORRIBLE HORRIBLE HACK AND SHOULD DIE
-                               // It's not possible to pass a list of both deleted and
-                               // undeleted revisions to SpecialRevisionDelete, so we're
-                               // stuck with two links. See bug 23363.
-                               $restoreLinks = array();
-                               
-                               $restoreLinks[] = $skin->link(
-                                       SpecialPage::getTitleFor( 'Revisiondelete' ),
-                                       $messages['revdel-restore-visible'],
-                                       array(),
-                                       array(
-                                               'target' => $title->getPrefixedText(),
-                                               'type' => $originalKey,
-                                               'ids' => implode(',', $undeletedRevisions),
-                                       ),
-                                       array( 'known', 'noclasses' )
-                               );
-                               
-                               $restoreLinks[] = $skin->link(
-                                       SpecialPage::getTitleFor( 'Revisiondelete' ),
-                                       $messages['revdel-restore-deleted'],
-                                       array(),
-                                       array(
-                                               'target' => $title->getPrefixedText(),
-                                               'type' => $key,
-                                               'ids' => implode(',', $Ids),
-                                       ),
-                                       array( 'known', 'noclasses' )
-                               );
-                               
-                               $revert[] = $messages['revdel-restore'] . ' [' .
-                                               $wgLang->pipeList( $restoreLinks ) . ']';
-                       } else {
-                               $revert[] = $skin->link(
-                                       SpecialPage::getTitleFor( 'Revisiondelete' ),
-                                       $messages['revdel-restore'],
-                                       array(),
-                                       array(
-                                               'target' => $title->getPrefixedText(),
-                                               'type' => $key,
-                                               'ids' => implode(',', $Ids),
-                                       ),
-                                       array( 'known', 'noclasses' )
-                               );
-                       }
-                       
-                       // Pipe links
-                       return wfMsg( 'parentheses', $wgLang->pipeList( $revert ) );
-               }
-               return '';
-       }
-}
-
 /**
  * List for revision table items
+ *
+ * This will check both the 'revision' table for live revisions and the
+ * 'archive' table for traditionally-deleted revisions that have an
+ * ar_rev_id saved.
+ *
+ * See RevDel_RevisionItem and RevDel_ArchivedRevisionItem for items.
  */
 class RevDel_RevisionList extends RevDel_List {
        var $currentRevId;
@@ -280,9 +16,13 @@ class RevDel_RevisionList extends RevDel_List {
        var $authorIdField = 'rev_user';
        var $authorNameField = 'rev_user_text';
 
+       /**
+        * @param $db DatabaseBase
+        * @return mixed
+        */
        public function doQuery( $db ) {
                $ids = array_map( 'intval', $this->ids );
-               return $db->select( array('revision','page'), '*',
+               $live = $db->select( array('revision','page'), '*',
                        array(
                                'rev_page' => $this->title->getArticleID(),
                                'rev_id'   => $ids,
@@ -291,16 +31,54 @@ class RevDel_RevisionList extends RevDel_List {
                        __METHOD__,
                        array( 'ORDER BY' => 'rev_id DESC' )
                );
+
+               if ( $live->numRows() >= count( $ids ) ) {
+                       // All requested revisions are live, keeps things simple!
+                       return $live;
+               }
+
+               // Check if any requested revisions are available fully deleted.
+               $archived = $db->select( array( 'archive' ), '*',
+                       array(
+                               'ar_rev_id' => $ids
+                       ),
+                       __METHOD__,
+                       array( 'ORDER BY' => 'ar_rev_id DESC' )
+               );
+
+               if ( $archived->numRows() == 0 ) {
+                       return $live;
+               } elseif ( $live->numRows() == 0 ) {
+                       return $archived;
+               } else {
+                       // Combine the two! Whee
+                       $rows = array();
+                       foreach ( $live as $row ) {
+                               $rows[$row->rev_id] = $row;
+                       }
+                       foreach ( $archived as $row ) {
+                               $rows[$row->ar_rev_id] = $row;
+                       }
+                       krsort( $rows );
+                       return new FakeResultWrapper( array_values( $rows ) );
+               }
        }
 
        public function newItem( $row ) {
-               return new RevDel_RevisionItem( $this, $row );
+               if ( isset( $row->rev_id ) ) {
+                       return new RevDel_RevisionItem( $this, $row );
+               } elseif ( isset( $row->ar_rev_id ) ) {
+                       return new RevDel_ArchivedRevisionItem( $this, $row );
+               } else {
+                       // This shouldn't happen. :)
+                       throw new MWException( 'Invalid row type in RevDel_RevisionList' );
+               }
        }
 
        public function getCurrent() {
                if ( is_null( $this->currentRevId ) ) {
                        $dbw = wfGetDB( DB_MASTER );
-                       $this->currentRevId = $dbw->selectField( 
+                       $this->currentRevId = $dbw->selectField(
                                'page', 'page_latest', $this->title->pageCond(), __METHOD__ );
                }
                return $this->currentRevId;
@@ -324,7 +102,7 @@ class RevDel_RevisionList extends RevDel_List {
 }
 
 /**
- * Item class for a revision table row
+ * Item class for a live revision table row
  */
 class RevDel_RevisionItem extends RevDel_Item {
        var $revision;
@@ -337,7 +115,7 @@ class RevDel_RevisionItem extends RevDel_Item {
        public function canView() {
                return $this->revision->userCan( Revision::DELETED_RESTRICTED );
        }
-       
+
        public function canViewContent() {
                return $this->revision->userCan( Revision::DELETED_TEXT );
        }
@@ -351,8 +129,8 @@ class RevDel_RevisionItem extends RevDel_Item {
                // Update revision table
                $dbw->update( 'revision',
                        array( 'rev_deleted' => $bits ),
-                       array( 
-                               'rev_id' => $this->revision->getId(), 
+                       array(
+                               'rev_id' => $this->revision->getId(),
                                'rev_page' => $this->revision->getPage(),
                                'rev_deleted' => $this->getBits()
                        ),
@@ -364,7 +142,7 @@ class RevDel_RevisionItem extends RevDel_Item {
                }
                // Update recentchanges table
                $dbw->update( 'recentchanges',
-                       array( 
+                       array(
                                'rc_deleted' => $bits,
                                'rc_patrolled' => 1
                        ),
@@ -383,7 +161,7 @@ class RevDel_RevisionItem extends RevDel_Item {
        }
 
        public function isHideCurrentOp( $newBits ) {
-               return ( $newBits & Revision::DELETED_TEXT ) 
+               return ( $newBits & Revision::DELETED_TEXT )
                        && $this->list->getCurrent() == $this->getId();
        }
 
@@ -392,14 +170,13 @@ class RevDel_RevisionItem extends RevDel_Item {
         * Overridden by RevDel_ArchiveItem.
         */
        protected function getRevisionLink() {
-               global $wgLang;
-               $date = $wgLang->timeanddate( $this->revision->getTimestamp(), true );
+               $date = $this->getLang()->timeanddate( $this->revision->getTimestamp(), true );
                if ( $this->isDeleted() && !$this->canViewContent() ) {
                        return $date;
                }
-               return $this->special->skin->link(
+               return Linker::link(
                        $this->list->title,
-                       $date, 
+                       $date,
                        array(),
                        array(
                                'oldid' => $this->revision->getId(),
@@ -416,9 +193,9 @@ class RevDel_RevisionItem extends RevDel_Item {
                if ( $this->isDeleted() && !$this->canViewContent() ) {
                        return wfMsgHtml('diff');
                } else {
-                       return 
-                               $this->special->skin->link( 
-                                       $this->list->title, 
+                       return
+                               Linker::link(
+                                       $this->list->title,
                                        wfMsgHtml('diff'),
                                        array(),
                                        array(
@@ -437,8 +214,8 @@ class RevDel_RevisionItem extends RevDel_Item {
        public function getHTML() {
                $difflink = $this->getDiffLink();
                $revlink = $this->getRevisionLink();
-               $userlink = $this->special->skin->revUserLink( $this->revision );
-               $comment = $this->special->skin->revComment( $this->revision );
+               $userlink = Linker::revUserLink( $this->revision );
+               $comment = Linker::revComment( $this->revision );
                if ( $this->isDeleted() ) {
                        $revlink = "<span class=\"history-deleted\">$revlink</span>";
                }
@@ -456,6 +233,10 @@ class RevDel_ArchiveList extends RevDel_RevisionList {
        var $authorIdField = 'ar_user';
        var $authorNameField = 'ar_user_text';
 
+       /**
+        * @param $db DatabaseBase
+        * @return mixed
+        */
        public function doQuery( $db ) {
                $timestamps = array();
                foreach ( $this->ids as $id ) {
@@ -490,7 +271,7 @@ class RevDel_ArchiveList extends RevDel_RevisionList {
  */
 class RevDel_ArchiveItem extends RevDel_RevisionItem {
        public function __construct( $list, $row ) {
-               parent::__construct( $list, $row );
+               RevDel_Item::__construct( $list, $row );
                $this->revision = Revision::newFromArchiveRow( $row,
                        array( 'page' => $this->list->title->getArticleId() ) );
        }
@@ -499,7 +280,7 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem {
                # Convert DB timestamp to MW timestamp
                return $this->revision->getTimestamp();
        }
-       
+
        public function setBits( $bits ) {
                $dbw = wfGetDB( DB_MASTER );
                $dbw->update( 'archive',
@@ -516,13 +297,12 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem {
        }
 
        protected function getRevisionLink() {
-               global $wgLang;
                $undelete = SpecialPage::getTitleFor( 'Undelete' );
-               $date = $wgLang->timeanddate( $this->revision->getTimestamp(), true );
+               $date = $this->getLang()->timeanddate( $this->revision->getTimestamp(), true );
                if ( $this->isDeleted() && !$this->canViewContent() ) {
                        return $date;
                }
-               return $this->special->skin->link( $undelete, $date, array(),
+               return Linker::link( $undelete, $date, array(),
                        array(
                                'target' => $this->list->title->getPrefixedText(),
                                'timestamp' => $this->revision->getTimestamp()
@@ -533,8 +313,8 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem {
                if ( $this->isDeleted() && !$this->canViewContent() ) {
                        return wfMsgHtml( 'diff' );
                }
-               $undelete = SpecialPage::getTitleFor( 'Undelete' );             
-               return $this->special->skin->link( $undelete, wfMsgHtml('diff'), array(), 
+               $undelete = SpecialPage::getTitleFor( 'Undelete' );
+               return Linker::link( $undelete, wfMsgHtml('diff'), array(),
                        array(
                                'target' => $this->list->title->getPrefixedText(),
                                'diff' => 'prev',
@@ -543,6 +323,35 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem {
        }
 }
 
+
+/**
+ * Item class for a archive table row by ar_rev_id -- actually
+ * used via RevDel_RevisionList.
+ */
+class RevDel_ArchivedRevisionItem extends RevDel_ArchiveItem {
+       public function __construct( $list, $row ) {
+               RevDel_Item::__construct( $list, $row );
+
+               $this->revision = Revision::newFromArchiveRow( $row,
+                       array( 'page' => $this->list->title->getArticleId() ) );
+       }
+
+       public function getId() {
+               return $this->revision->getId();
+       }
+
+       public function setBits( $bits ) {
+               $dbw = wfGetDB( DB_MASTER );
+               $dbw->update( 'archive',
+                       array( 'ar_deleted' => $bits ),
+                       array( 'ar_rev_id' => $this->row->ar_rev_id,
+                                  'ar_deleted' => $this->getBits()
+                       ),
+                       __METHOD__ );
+               return (bool)$dbw->affectedRows();
+       }
+}
+
 /**
  * List for oldimage table items
  */
@@ -554,6 +363,10 @@ class RevDel_FileList extends RevDel_List {
        var $authorNameField = 'oi_user_text';
        var $storeBatch, $deleteBatch, $cleanupBatch;
 
+       /**
+        * @param $db DatabaseBase
+        * @return mixed
+        */
        public function doQuery( $db ) {
                $archiveNames = array();
                foreach( $this->ids as $timestamp ) {
@@ -618,6 +431,10 @@ class RevDel_FileList extends RevDel_List {
  * Item class for an oldimage table row
  */
 class RevDel_FileItem extends RevDel_Item {
+
+       /**
+        * @var File
+        */
        var $file;
 
        public function __construct( $list, $row ) {
@@ -633,7 +450,7 @@ class RevDel_FileItem extends RevDel_Item {
        public function canView() {
                return $this->file->userCan( File::DELETED_RESTRICTED );
        }
-       
+
        public function canViewContent() {
                return $this->file->userCan( File::DELETED_FILE );
        }
@@ -644,7 +461,7 @@ class RevDel_FileItem extends RevDel_Item {
 
        public function setBits( $bits ) {
                # Queue the file op
-               # FIXME: move to LocalFile.php
+               # @todo FIXME: Move to LocalFile.php
                if ( $this->isDeleted() ) {
                        if ( $bits & File::DELETED_FILE ) {
                                # Still deleted
@@ -665,12 +482,12 @@ class RevDel_FileItem extends RevDel_Item {
                        $dstRel = $this->file->repo->getDeletedHashPath( $key ) . $key;
                        $this->list->deleteBatch[] = array( $this->file->getRel(), $dstRel );
                }
-               
+
                # Do the database operations
                $dbw = wfGetDB( DB_MASTER );
                $dbw->update( 'oldimage',
                        array( 'oi_deleted' => $bits ),
-                       array( 
+                       array(
                                'oi_name' => $this->row->oi_name,
                                'oi_timestamp' => $this->row->oi_timestamp,
                                'oi_deleted' => $this->getBits()
@@ -685,24 +502,23 @@ class RevDel_FileItem extends RevDel_Item {
        }
 
        /**
-        * Get the link to the file. 
+        * Get the link to the file.
         * Overridden by RevDel_ArchivedFileItem.
         */
        protected function getLink() {
-               global $wgLang, $wgUser;
-               $date = $wgLang->timeanddate( $this->file->getTimestamp(), true  );             
+               $date = $this->getLang()->timeanddate( $this->file->getTimestamp(), true  );
                if ( $this->isDeleted() ) {
                        # Hidden files...
                        if ( !$this->canViewContent() ) {
                                $link = $date;
                        } else {
-                               $link = $this->special->skin->link( 
-                                       $this->special->getTitle(), 
-                                       $date, array(), 
+                               $link = Linker::link(
+                                       $this->special->getTitle(),
+                                       $date, array(),
                                        array(
                                                'target' => $this->list->title->getPrefixedText(),
                                                'file'   => $this->file->getArchiveName(),
-                                               'token'  => $wgUser->editToken( $this->file->getArchiveName() )
+                                               'token'  => $this->getUser()->editToken( $this->file->getArchiveName() )
                                        )
                                );
                        }
@@ -718,8 +534,8 @@ class RevDel_FileItem extends RevDel_Item {
         */
        protected function getUserTools() {
                if( $this->file->userCan( Revision::DELETED_USER ) ) {
-                       $link = $this->special->skin->userLink( $this->file->user, $this->file->user_text ) .
-                               $this->special->skin->userToolLinks( $this->file->user, $this->file->user_text );
+                       $link = Linker::userLink( $this->file->user, $this->file->user_text ) .
+                               Linker::userToolLinks( $this->file->user, $this->file->user_text );
                } else {
                        $link = wfMsgHtml( 'rev-deleted-user' );
                }
@@ -737,7 +553,7 @@ class RevDel_FileItem extends RevDel_Item {
         */
        protected function getComment() {
                if( $this->file->userCan( File::DELETED_COMMENT ) ) {
-                       $block = $this->special->skin->commentBlock( $this->file->description );
+                       $block = Linker::commentBlock( $this->file->description );
                } else {
                        $block = ' ' . wfMsgHtml( 'rev-deleted-comment' );
                }
@@ -748,15 +564,14 @@ class RevDel_FileItem extends RevDel_Item {
        }
 
        public function getHTML() {
-               global $wgLang;
-               $data = 
+               $data =
                        wfMsg(
-                               'widthheight', 
-                               $wgLang->formatNum( $this->file->getWidth() ),
-                               $wgLang->formatNum( $this->file->getHeight() ) 
+                               'widthheight',
+                               $this->getLang()->formatNum( $this->file->getWidth() ),
+                               $this->getLang()->formatNum( $this->file->getHeight() )
                        ) .
-                       ' (' . 
-                       wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $this->file->getSize() ) ) . 
+                       ' (' .
+                       wfMsgExt( 'nbytes', 'parsemag', $this->getLang()->formatNum( $this->file->getSize() ) ) .
                        ')';
 
                return '<li>' . $this->getLink() . ' ' . $this->getUserTools() . ' ' .
@@ -773,7 +588,11 @@ class RevDel_ArchivedFileList extends RevDel_FileList {
        var $dateField = 'fa_timestamp';
        var $authorIdField = 'fa_user';
        var $authorNameField = 'fa_user_text';
-       
+
+       /**
+        * @param $db DatabaseBase
+        * @return mixed
+        */
        public function doQuery( $db ) {
                $ids = array_map( 'intval', $this->ids );
                return $db->select( 'filearchive', '*',
@@ -796,7 +615,7 @@ class RevDel_ArchivedFileList extends RevDel_FileList {
  */
 class RevDel_ArchivedFileItem extends RevDel_FileItem {
        public function __construct( $list, $row ) {
-               parent::__construct( $list, $row );
+               RevDel_Item::__construct( $list, $row );
                $this->file = ArchivedFile::newFromRow( $row );
        }
 
@@ -818,19 +637,18 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem {
        }
 
        protected function getLink() {
-               global $wgLang, $wgUser;
-               $date = $wgLang->timeanddate( $this->file->getTimestamp(), true  );
+               $date = $this->getLang()->timeanddate( $this->file->getTimestamp(), true  );
                $undelete = SpecialPage::getTitleFor( 'Undelete' );
                $key = $this->file->getKey();
                # Hidden files...
                if( !$this->canViewContent() ) {
                        $link = $date;
                } else {
-                       $link = $this->special->skin->link( $undelete, $date, array(),
+                       $link = Linker::link( $undelete, $date, array(),
                                array(
                                        'target' => $this->list->title->getPrefixedText(),
                                        'file' => $key,
-                                       'token' => $wgUser->editToken( $key )
+                                       'token' => $this->getUser()->editToken( $key )
                                )
                        );
                }
@@ -851,6 +669,10 @@ class RevDel_LogList extends RevDel_List {
        var $authorIdField = 'log_user';
        var $authorNameField = 'log_user_text';
 
+       /**
+        * @param $db DatabaseBase
+        * @return mixed
+        */
        public function doQuery( $db ) {
                $ids = array_map( 'intval', $this->ids );
                return $db->select( 'logging', '*',
@@ -888,7 +710,7 @@ class RevDel_LogItem extends RevDel_Item {
        public function canView() {
                return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED );
        }
-       
+
        public function canViewContent() {
                return true; // none
        }
@@ -900,9 +722,9 @@ class RevDel_LogItem extends RevDel_Item {
        public function setBits( $bits ) {
                $dbw = wfGetDB( DB_MASTER );
                $dbw->update( 'recentchanges',
-                       array( 
-                               'rc_deleted' => $bits, 
-                               'rc_patrolled' => 1 
+                       array(
+                               'rc_deleted' => $bits,
+                               'rc_patrolled' => 1
                        ),
                        array(
                                'rc_logid' => $this->row->log_id,
@@ -922,14 +744,12 @@ class RevDel_LogItem extends RevDel_Item {
        }
 
        public function getHTML() {
-               global $wgLang;
-
-               $date = htmlspecialchars( $wgLang->timeanddate( $this->row->log_timestamp ) );
+               $date = htmlspecialchars( $this->getLang()->timeanddate( $this->row->log_timestamp ) );
                $paramArray = LogPage::extractParams( $this->row->log_params );
                $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
 
                // Log link for this page
-               $loglink = $this->special->skin->link(
+               $loglink = Linker::link(
                        SpecialPage::getTitleFor( 'Log' ),
                        wfMsgHtml( 'log' ),
                        array(),
@@ -940,18 +760,18 @@ class RevDel_LogItem extends RevDel_Item {
                        $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
                } else {
                        $action = LogPage::actionText( $this->row->log_type, $this->row->log_action, $title,
-                               $this->special->skin, $paramArray, true, true );
+                               $this->special->getSkin(), $paramArray, true, true );
                        if( $this->row->log_deleted & LogPage::DELETED_ACTION )
                                $action = '<span class="history-deleted">' . $action . '</span>';
                }
                // User links
-               $userLink = $this->special->skin->userLink( $this->row->log_user,
+               $userLink = Linker::userLink( $this->row->log_user,
                        User::WhoIs( $this->row->log_user ) );
                if( LogEventsList::isDeleted($this->row,LogPage::DELETED_USER) ) {
                        $userLink = '<span class="history-deleted">' . $userLink . '</span>';
                }
                // Comment
-               $comment = $wgLang->getDirMark() . $this->special->skin->commentBlock( $this->row->log_comment );
+               $comment = $this->getLang()->getDirMark() . Linker::commentBlock( $this->row->log_comment );
                if( LogEventsList::isDeleted($this->row,LogPage::DELETED_COMMENT) ) {
                        $comment = '<span class="history-deleted">' . $comment . '</span>';
                }