ContributionsPager: Make separate method for adding revId to HTML

Why:

* Each revision is displayed as a <li> with a data attribute
  containing the revision ID. However, for subclasses that show
  contributions from external wikis, it doesn't make sense to add
  revision IDs to the HTML.

What:

* Make a separate method for populating HTML attributes, that can
  be overridden by a subclass.

Bug: T377482
Change-Id: Ia22dde32071408798797b9f6f9f862ec5b57b2a4
This commit is contained in:
Thalia 2024-10-17 15:26:50 +01:00
parent 9061de3ebb
commit 45c0d3cd37

View file

@ -606,6 +606,16 @@ abstract class ContributionsPager extends RangeChronologicalPager {
return $this->revisionStore->newRevisionFromRow( $row, 0, $title );
}
/**
* Populate the HTML attributes.
*
* @param mixed $row
* @param string[] &$attributes
*/
protected function populateAttributes( $row, &$attributes ) {
$attributes['data-mw-revid'] = $this->currentRevRecord->getId();
}
/**
* Format a link to an article.
*
@ -972,7 +982,7 @@ abstract class ContributionsPager extends RangeChronologicalPager {
// FIXME: have some better way for extensions to provide formatted rows.
$this->currentRevRecord = $this->tryCreatingRevisionRecord( $row, $this->currentPage );
if ( $this->revisionsOnly || ( $this->currentRevRecord && $this->currentPage ) ) {
$attribs['data-mw-revid'] = $this->currentRevRecord->getId();
$this->populateAttributes( $row, $attribs );
$link = $this->formatArticleLink( $row );