X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2Fpagers%2FContribsPager.php;h=81a1f5a506a6ca4eb4cc4c29ca4f78833f84ad8c;hb=b7625d63a6f1f8867c911dbd6e93eebdaca3312f;hp=205364f81babdbc1711c9e1f9e022e759f2b1d80;hpb=a93cf8f4eee40a448bcd99b8fe1c32dc80775b6b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/pagers/ContribsPager.php b/includes/specials/pagers/ContribsPager.php index 205364f81b..81a1f5a506 100644 --- a/includes/specials/pagers/ContribsPager.php +++ b/includes/specials/pagers/ContribsPager.php @@ -407,24 +407,13 @@ class ContribsPager extends RangeChronologicalPager { } /** - * Generates each row in the contributions list. + * Check whether the revision associated is valid for formatting. If has no associated revision + * id then null is returned. * - * Contributions which are marked "top" are currently on top of the history. - * For these contributions, a [rollback] link is shown for users with roll- - * back privileges. The rollback link restores the most recent version that - * was not written by the target user. - * - * @todo This would probably look a lot nicer in a table. * @param object $row - * @return string + * @return Revision|null */ - function formatRow( $row ) { - $ret = ''; - $classes = []; - $attribs = []; - - $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); - + public function tryToCreateValidRevision( $row ) { /* * There may be more than just revision rows. To make sure that we'll only be processing * revisions here, let's _try_ to build a revision out of our row (without displaying @@ -440,8 +429,30 @@ class ContribsPager extends RangeChronologicalPager { $validRevision = false; } Wikimedia\restoreWarnings(); + return $validRevision ? $rev : null; + } + + /** + * Generates each row in the contributions list. + * + * Contributions which are marked "top" are currently on top of the history. + * For these contributions, a [rollback] link is shown for users with roll- + * back privileges. The rollback link restores the most recent version that + * was not written by the target user. + * + * @todo This would probably look a lot nicer in a table. + * @param object $row + * @return string + */ + function formatRow( $row ) { + $ret = ''; + $classes = []; + $attribs = []; + + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); - if ( $validRevision ) { + $rev = $this->tryToCreateValidRevision( $row ); + if ( $rev ) { $attribs['data-mw-revid'] = $rev->getId(); $page = Title::newFromRow( $row ); @@ -593,7 +604,10 @@ class ContribsPager extends RangeChronologicalPager { // Let extensions add data Hooks::run( 'ContributionsLineEnding', [ $this, &$ret, $row, &$classes, &$attribs ] ); - $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] ); + $attribs = array_filter( $attribs, + [ Sanitizer::class, 'isReservedDataAttribute' ], + ARRAY_FILTER_USE_KEY + ); // TODO: Handle exceptions in the catch block above. Do any extensions rely on // receiving empty rows?