Restore the newFromId() approach in SpecialNewpages::feedItemDesc
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 17 Aug 2017 20:53:01 +0000 (13:53 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 17 Aug 2017 21:28:22 +0000 (14:28 -0700)
Trying to use the row data is problematic since the text related
fields are missing. This fixing a regression from 4475e1c8c.

Also make SpecialNewpages::feedItemDesc() handle null content.

Bug: T173541
Change-Id: I2213675d3392c6e9761bdc7acde35fd1caee4517

includes/specials/SpecialNewpages.php

index 6a79714..e3b73a9 100644 (file)
@@ -494,17 +494,22 @@ class SpecialNewpages extends IncludableSpecialPage {
        }
 
        protected function feedItemDesc( $row ) {
-               $revision = $this->revisionFromRcResult( $row );
-               if ( $revision ) {
-                       // XXX: include content model/type in feed item?
-                       return '<p>' . htmlspecialchars( $revision->getUserText() ) .
-                               $this->msg( 'colon-separator' )->inContentLanguage()->escaped() .
-                               htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
-                               "</p>\n<hr />\n<div>" .
-                               nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "</div>";
+               $revision = Revision::newFromId( $row->rev_id );
+               if ( !$revision ) {
+                       return '';
                }
 
-               return '';
+               $content = $revision->getContent();
+               if ( $content === null ) {
+                       return '';
+               }
+
+               // XXX: include content model/type in feed item?
+               return '<p>' . htmlspecialchars( $revision->getUserText() ) .
+                       $this->msg( 'colon-separator' )->inContentLanguage()->escaped() .
+                       htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
+                       "</p>\n<hr />\n<div>" .
+                       nl2br( htmlspecialchars( $content->serialize() ) ) . "</div>";
        }
 
        protected function getGroupName() {