Special:Newpages feed now shows first revision instead of latest revision
authorRohan <rohan1395@yahoo.com>
Tue, 29 Jul 2014 13:42:58 +0000 (19:12 +0530)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 14 Apr 2017 23:31:29 +0000 (16:31 -0700)
Bug: T69026
Change-Id: I1f794f314319127848a4e9981c7d4f549fb4fd0f

includes/specials/SpecialNewpages.php

index be8ad8f..2c39331 100644 (file)
@@ -293,6 +293,19 @@ class SpecialNewpages extends IncludableSpecialPage {
                );
        }
 
                );
        }
 
+       /**
+        * @param stdClass $row Result row from recent changes
+        * @return Revision|bool
+        */
+       protected function revisionFromRcResult( stdClass $result ) {
+               return new Revision( [
+                       'comment' => $result->rc_comment,
+                       'deleted' => $result->rc_deleted,
+                       'user_text' => $result->rc_user_text,
+                       'user' => $result->rc_user,
+               ] );
+       }
+
        /**
         * Format a row, providing the timestamp, links to the page/history,
         * size, user links, and a comment
        /**
         * Format a row, providing the timestamp, links to the page/history,
         * size, user links, and a comment
@@ -303,14 +316,9 @@ class SpecialNewpages extends IncludableSpecialPage {
        public function formatRow( $result ) {
                $title = Title::newFromRow( $result );
 
        public function formatRow( $result ) {
                $title = Title::newFromRow( $result );
 
-               # Revision deletion works on revisions, so we should cast one
-               $row = [
-                       'comment' => $result->rc_comment,
-                       'deleted' => $result->rc_deleted,
-                       'user_text' => $result->rc_user_text,
-                       'user' => $result->rc_user,
-               ];
-               $rev = new Revision( $row );
+               // Revision deletion works on revisions,
+               // so cast our recent change row to a revision row.
+               $rev = $this->revisionFromRcResult( $result );
                $rev->setTitle( $title );
 
                $classes = [];
                $rev->setTitle( $title );
 
                $classes = [];
@@ -477,7 +485,7 @@ class SpecialNewpages extends IncludableSpecialPage {
        }
 
        protected function feedItemDesc( $row ) {
        }
 
        protected function feedItemDesc( $row ) {
-               $revision = Revision::newFromId( $row->rev_id );
+               $revision = $this->revisionFromRcResult( $row );
                if ( $revision ) {
                        // XXX: include content model/type in feed item?
                        return '<p>' . htmlspecialchars( $revision->getUserText() ) .
                if ( $revision ) {
                        // XXX: include content model/type in feed item?
                        return '<p>' . htmlspecialchars( $revision->getUserText() ) .