RevDelArchivedFileItem needs to override getApiData
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 15 Jul 2014 15:39:27 +0000 (11:39 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 15 Jul 2014 18:45:31 +0000 (14:45 -0400)
Why is ArchivedFile so different from OldLocalFile?

Bug: 68034
Change-Id: I89a41a47ea2720e5302be5b463e6ff89737fa089

includes/revisiondelete/RevisionDelete.php

index e7a09d7..8a08fd1 100644 (file)
@@ -885,6 +885,45 @@ class RevDelArchivedFileItem extends RevDelFileItem {
                }
                return $link;
        }
+
+       public function getApiData( ApiResult $result ) {
+               $file = $this->file;
+               $user = $this->list->getUser();
+               $ret = array(
+                       'title' => $this->list->title->getPrefixedText(),
+                       'timestamp' => wfTimestamp( TS_ISO_8601, $file->getTimestamp() ),
+                       'width' => $file->getWidth(),
+                       'height' => $file->getHeight(),
+                       'size' => $file->getSize(),
+               );
+               $ret += $file->isDeleted( Revision::DELETED_USER ) ? array( 'userhidden' => '' ) : array();
+               $ret += $file->isDeleted( Revision::DELETED_COMMENT ) ? array( 'commenthidden' => '' ) : array();
+               $ret += $this->isDeleted() ? array( 'contenthidden' => '' ) : array();
+               if ( $this->canViewContent() ) {
+                       $ret += array(
+                               'url' => SpecialPage::getTitleFor( 'Revisiondelete' )->getLinkURL(
+                                       array(
+                                               'target' => $this->list->title->getPrefixedText(),
+                                               'file' => $file->getKey(),
+                                               'token' => $user->getEditToken( $file->getKey() )
+                                       ),
+                                       false, PROTO_RELATIVE
+                               ),
+                       );
+               }
+               if ( $file->userCan( Revision::DELETED_USER, $user ) ) {
+                       $ret += array(
+                               'userid' => $file->getUser( 'id' ),
+                               'user' => $file->getUser( 'text' ),
+                       );
+               }
+               if ( $file->userCan( Revision::DELETED_COMMENT, $user ) ) {
+                       $ret += array(
+                               'comment' => $file->getRawDescription(),
+                       );
+               }
+               return $ret;
+       }
 }
 
 /**