Skip to content

Commit 4475e1c

Browse files
RohanKrinkle
authored andcommitted
Special:Newpages feed now shows first revision instead of latest revision
Bug: T69026 Change-Id: I1f794f314319127848a4e9981c7d4f549fb4fd0f
1 parent dc17c8d commit 4475e1c

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

includes/specials/SpecialNewpages.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,19 @@ function () {
293293
);
294294
}
295295

296+
/**
297+
* @param stdClass $row Result row from recent changes
298+
* @return Revision|bool
299+
*/
300+
protected function revisionFromRcResult( stdClass $result ) {
301+
return new Revision( [
302+
'comment' => $result->rc_comment,
303+
'deleted' => $result->rc_deleted,
304+
'user_text' => $result->rc_user_text,
305+
'user' => $result->rc_user,
306+
] );
307+
}
308+
296309
/**
297310
* Format a row, providing the timestamp, links to the page/history,
298311
* size, user links, and a comment
@@ -303,14 +316,9 @@ function () {
303316
public function formatRow( $result ) {
304317
$title = Title::newFromRow( $result );
305318

306-
# Revision deletion works on revisions, so we should cast one
307-
$row = [
308-
'comment' => $result->rc_comment,
309-
'deleted' => $result->rc_deleted,
310-
'user_text' => $result->rc_user_text,
311-
'user' => $result->rc_user,
312-
];
313-
$rev = new Revision( $row );
319+
// Revision deletion works on revisions,
320+
// so cast our recent change row to a revision row.
321+
$rev = $this->revisionFromRcResult( $result );
314322
$rev->setTitle( $title );
315323

316324
$classes = [];
@@ -477,7 +485,7 @@ protected function feedItemAuthor( $row ) {
477485
}
478486

479487
protected function feedItemDesc( $row ) {
480-
$revision = Revision::newFromId( $row->rev_id );
488+
$revision = $this->revisionFromRcResult( $row );
481489
if ( $revision ) {
482490
// XXX: include content model/type in feed item?
483491
return '<p>' . htmlspecialchars( $revision->getUserText() ) .

0 commit comments

Comments
 (0)