From 3e80415c5b7fd97b5c8efe4c87dcc108a6aac66e Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sun, 2 Dec 2018 19:06:53 +0100 Subject: [PATCH] Delete always true condition The typehint doesn't allow passing null here. Found by PHPStan. Change-Id: I978469c0df584968ab6d1b54c9ebff05c3222054 --- includes/api/ApiFeedContributions.php | 44 ++++++++++++--------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index 5bf8da9ff8..9edf929f8e 100644 --- a/includes/api/ApiFeedContributions.php +++ b/includes/api/ApiFeedContributions.php @@ -172,33 +172,29 @@ class ApiFeedContributions extends ApiBase { * @return string */ protected function feedItemDesc( RevisionRecord $revision ) { - if ( $revision ) { - $msg = wfMessage( 'colon-separator' )->inContentLanguage()->text(); - try { - $content = $revision->getContent( SlotRecord::MAIN ); - } catch ( RevisionAccessException $e ) { - $content = null; - } - - if ( $content instanceof TextContent ) { - // only textual content has a "source view". - $html = nl2br( htmlspecialchars( $content->getNativeData() ) ); - } else { - // XXX: we could get an HTML representation of the content via getParserOutput, but that may - // contain JS magic and generally may not be suitable for inclusion in a feed. - // Perhaps Content should have a getDescriptiveHtml method and/or a getSourceText method. - // Compare also FeedUtils::formatDiffRow. - $html = ''; - } - - $comment = $revision->getComment(); + $msg = wfMessage( 'colon-separator' )->inContentLanguage()->text(); + try { + $content = $revision->getContent( SlotRecord::MAIN ); + } catch ( RevisionAccessException $e ) { + $content = null; + } - return '

' . htmlspecialchars( $this->feedItemAuthor( $revision ) ) . $msg . - htmlspecialchars( FeedItem::stripComment( $comment ? $comment->text : '' ) ) . - "

\n
\n
" . $html . '
'; + if ( $content instanceof TextContent ) { + // only textual content has a "source view". + $html = nl2br( htmlspecialchars( $content->getNativeData() ) ); + } else { + // XXX: we could get an HTML representation of the content via getParserOutput, but that may + // contain JS magic and generally may not be suitable for inclusion in a feed. + // Perhaps Content should have a getDescriptiveHtml method and/or a getSourceText method. + // Compare also FeedUtils::formatDiffRow. + $html = ''; } - return ''; + $comment = $revision->getComment(); + + return '

' . htmlspecialchars( $this->feedItemAuthor( $revision ) ) . $msg . + htmlspecialchars( FeedItem::stripComment( $comment ? $comment->text : '' ) ) . + "

\n
\n
" . $html . '
'; } public function getAllowedParams() { -- 2.20.1