From 5830ca7a2f3a2a82feb4f9f2a0c26f98a5cc54d6 Mon Sep 17 00:00:00 2001 From: Bill Pirkle Date: Mon, 10 Jun 2019 17:26:24 -0500 Subject: [PATCH] Check for valid user info before calling Linker::userLink() in Linker::revUserTools() If an actor table row has neither an actor_user nor an actor_name value (which should not have happened, but did), we would call Linker::revUserTools() with no valid user info. This generated log noise and displayed bad output. Instead, check for valid user info, and fall back to a default message if necessary. T225469 exists for correcting the underlying bad data, but adding this check is still prudent. Bug: T224368 Change-Id: Ib9816d8b87b995f4fe465004acd608225728e391 --- includes/Linker.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index ae50c66ff2..63afcfcaf8 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1118,17 +1118,22 @@ class Linker { * @return string HTML */ public static function revUserTools( $rev, $isPublic = false, $useParentheses = true ) { - if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) { - $link = wfMessage( 'rev-deleted-user' )->escaped(); - } elseif ( $rev->userCan( Revision::DELETED_USER ) ) { + if ( $rev->userCan( Revision::DELETED_USER ) && + ( !$rev->isDeleted( Revision::DELETED_USER ) || !$isPublic ) + ) { $userId = $rev->getUser( Revision::FOR_THIS_USER ); $userText = $rev->getUserText( Revision::FOR_THIS_USER ); - $link = self::userLink( $userId, $userText ) - . self::userToolLinks( $userId, $userText, false, 0, null, - $useParentheses ); - } else { + if ( $userId && $userText ) { + $link = self::userLink( $userId, $userText ) + . self::userToolLinks( $userId, $userText, false, 0, null, + $useParentheses ); + } + } + + if ( !isset( $link ) ) { $link = wfMessage( 'rev-deleted-user' )->escaped(); } + if ( $rev->isDeleted( Revision::DELETED_USER ) ) { return ' ' . $link . ''; } -- 2.20.1