Update ImportableUploadRevisionImporter for interwiki usernames
[lhc/web/wiklou.git] / includes / RevisionList.php
index 052fd16..5243cc6 100644 (file)
@@ -21,6 +21,8 @@
  */
 
 use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IDatabase;
 
 /**
  * List for revision table items for a single page
@@ -35,7 +37,7 @@ abstract class RevisionListBase extends ContextSource implements Iterator {
        /** @var ResultWrapper|bool */
        protected $res;
 
-       /** @var bool|object */
+       /** @var bool|Revision */
        protected $current;
 
        /**
@@ -114,7 +116,7 @@ abstract class RevisionListBase extends ContextSource implements Iterator {
        }
 
        public function key() {
-               return $this->res ? $this->res->key(): 0;
+               return $this->res ? $this->res->key() : 0;
        }
 
        public function valid() {
@@ -201,6 +203,16 @@ abstract class RevisionItemBase {
                return false;
        }
 
+       /**
+        * Get the DB field name storing actor ids.
+        * Override this function.
+        * @since 1.31
+        * @return bool
+        */
+       public function getAuthorActorField() {
+               return false;
+       }
+
        /**
         * Get the ID, as it would appear in the ids URL parameter
         * @return int
@@ -255,6 +267,16 @@ abstract class RevisionItemBase {
                return strval( $this->row->$field );
        }
 
+       /**
+        * Get the author actor ID
+        * @since 1.31
+        * @return string
+        */
+       public function getAuthorActor() {
+               $field = $this->getAuthorActorField();
+               return strval( $this->row->$field );
+       }
+
        /**
         * Returns true if the current user can view the item
         */
@@ -294,15 +316,14 @@ class RevisionList extends RevisionListBase {
                if ( $this->ids !== null ) {
                        $conds['rev_id'] = array_map( 'intval', $this->ids );
                }
+               $revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
                return $db->select(
-                       [ 'revision', 'page', 'user' ],
-                       array_merge( Revision::selectFields(), Revision::selectUserFields() ),
+                       $revQuery['tables'],
+                       $revQuery['fields'],
                        $conds,
                        __METHOD__,
                        [ 'ORDER BY' => 'rev_id DESC' ],
-                       [
-                               'page' => Revision::pageJoinCond(),
-                               'user' => Revision::userJoinCond() ]
+                       $revQuery['joins']
                );
        }
 
@@ -363,13 +384,14 @@ class RevisionItem extends RevisionItemBase {
         * @return string
         */
        protected function getRevisionLink() {
-               $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
-                       $this->revision->getTimestamp(), $this->list->getUser() ) );
+               $date = $this->list->getLanguage()->userTimeAndDate(
+                       $this->revision->getTimestamp(), $this->list->getUser() );
 
                if ( $this->isDeleted() && !$this->canViewContent() ) {
-                       return $date;
+                       return htmlspecialchars( $date );
                }
-               return Linker::linkKnown(
+               $linkRenderer = $this->getLinkRenderer();
+               return $linkRenderer->makeKnownLink(
                        $this->list->title,
                        $date,
                        [],
@@ -391,9 +413,10 @@ class RevisionItem extends RevisionItemBase {
                if ( $this->isDeleted() && !$this->canViewContent() ) {
                        return $this->context->msg( 'diff' )->escaped();
                } else {
-                       return Linker::linkKnown(
+                       $linkRenderer = $this->getLinkRenderer();
+                       return $linkRenderer->makeKnownLink(
                                        $this->list->title,
-                                       $this->list->msg( 'diff' )->escaped(),
+                                       $this->list->msg( 'diff' )->text(),
                                        [],
                                        [
                                                'diff' => $this->revision->getId(),