SpecialNewpages: add $attribs['class'] immediately before creating <li>
[lhc/web/wiklou.git] / includes / specials / SpecialNewpages.php
index 83482f6..ede4898 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
@@ -303,14 +316,9 @@ class SpecialNewpages extends IncludableSpecialPage {
        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 = [];
@@ -382,6 +390,16 @@ class SpecialNewpages extends IncludableSpecialPage {
                # Display the old title if the namespace/title has been changed
                $oldTitleText = '';
                $oldTitle = Title::makeTitle( $result->rc_namespace, $result->rc_title );
+
+               if ( !$title->equals( $oldTitle ) ) {
+                       $oldTitleText = $oldTitle->getPrefixedText();
+                       $oldTitleText = Html::rawElement(
+                               'span',
+                               [ 'class' => 'mw-newpages-oldtitle' ],
+                               $this->msg( 'rc-old-title' )->params( $oldTitleText )->escaped()
+                       );
+               }
+
                $ret = "{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} "
                        . "{$tagDisplay} {$oldTitleText}";
 
@@ -393,15 +411,6 @@ class SpecialNewpages extends IncludableSpecialPage {
                        $attribs['class'] = implode( ' ', $classes );
                }
 
-               if ( !$title->equals( $oldTitle ) ) {
-                       $oldTitleText = $oldTitle->getPrefixedText();
-                       $oldTitleText = Html::rawElement(
-                               'span',
-                               [ 'class' => 'mw-newpages-oldtitle' ],
-                               $this->msg( 'rc-old-title' )->params( $oldTitleText )->escaped()
-                       );
-               }
-
                return Html::rawElement( 'li', $attribs, $ret ) . "\n";
        }
 
@@ -486,16 +495,21 @@ class SpecialNewpages extends IncludableSpecialPage {
 
        protected function feedItemDesc( $row ) {
                $revision = Revision::newFromId( $row->rev_id );
-               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>";
+               if ( !$revision ) {
+                       return '';
+               }
+
+               $content = $revision->getContent();
+               if ( $content === null ) {
+                       return '';
                }
 
-               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() {