From: jenkins-bot Date: Mon, 14 Aug 2017 16:33:19 +0000 (+0000) Subject: Merge "Special:Newpages feed now shows first revision instead of latest revision" X-Git-Tag: 1.31.0-rc.0~2392 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=89539f2aa1b158fdcc703ad053e2580cb97a6385;hp=-c Merge "Special:Newpages feed now shows first revision instead of latest revision" --- 89539f2aa1b158fdcc703ad053e2580cb97a6385 diff --combined includes/specials/SpecialNewpages.php index 83482f6f2f,2c39331967..e2c9eab1ce --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@@ -293,6 -293,19 +293,19 @@@ class SpecialNewpages extends Includabl ); } + /** + * @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,18 -316,12 +316,13 @@@ 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 = []; + $attribs = [ 'data-mw-revid' => $result->rev_id ]; $lang = $this->getLanguage(); $dm = $lang->getDirMark(); @@@ -379,19 -386,11 +387,19 @@@ $tagDisplay = ''; } - $css = count( $classes ) ? ' class="' . implode( ' ', $classes ) . '"' : ''; - # Display the old title if the namespace/title has been changed $oldTitleText = ''; $oldTitle = Title::makeTitle( $result->rc_namespace, $result->rc_title ); + $ret = "{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} " + . "{$tagDisplay} {$oldTitleText}"; + + // Let extensions add data + Hooks::run( 'NewPagesLineEnding', [ $this, &$ret, $result, &$classes, &$attribs ] ); + $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] ); + + if ( count( $classes ) ) { + $attribs['class'] = implode( ' ', $classes ); + } if ( !$title->equals( $oldTitle ) ) { $oldTitleText = $oldTitle->getPrefixedText(); @@@ -402,7 -401,8 +410,7 @@@ ); } - return "{$time} {$dm}{$plink} {$hist} {$dm}{$length} " - . "{$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}\n"; + return Html::rawElement( 'li', $attribs, $ret ) . "\n"; } /** @@@ -485,7 -485,7 +493,7 @@@ } 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 '

' . htmlspecialchars( $revision->getUserText() ) .