Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/165700
Change subject: Cleanup EntityContentDiffView ...................................................................... Cleanup EntityContentDiffView This is a follow up to I0567dde. Plus a bit of additional cleanup to get rid of all orange warnings in PHPStorm. Change-Id: I12269f2d55adf0d3ecb6b165013f40208aeb3afb --- M repo/includes/Diff/EntityContentDiffView.php 1 file changed, 23 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/00/165700/1 diff --git a/repo/includes/Diff/EntityContentDiffView.php b/repo/includes/Diff/EntityContentDiffView.php index cf20d8b..51245b6 100644 --- a/repo/includes/Diff/EntityContentDiffView.php +++ b/repo/includes/Diff/EntityContentDiffView.php @@ -8,12 +8,15 @@ use DifferenceEngine; use Html; use IContextSource; +use Language; use Linker; +use MWException; use ParserOptions; use ParserOutput; use Revision; use ValueFormatters\FormatterOptions; use ValueFormatters\ValueFormatter; +use Wikibase\EntityContent; use Wikibase\Lib\EntityIdLabelFormatter; use Wikibase\Lib\EscapingValueFormatter; use Wikibase\Lib\SnakFormatter; @@ -108,12 +111,14 @@ } /** - * Override parent DifferenceEngine - * * @return Language */ public function getDiffLang() { - return $this->getLanguage(); + if ( $this->mDiffLang === null ) { + $this->mDiffLang = $this->getLanguage(); + } + + return parent::getDiffLang(); } /** @@ -182,14 +187,16 @@ * @param Content $old * @param Content $new * + * @throws MWException If the two content objects are neither EntityContent nor TextContent. * @return string */ public function generateContentDiffBody( Content $old, Content $new ) { - /* @var EntityContent $old */ - /* @var EntityContent $new */ - $diff = $old->getDiff( $new ); + if ( ( $old instanceof EntityContent ) && ( $new instanceof EntityContent ) ) { + $diff = $old->getDiff( $new ); + return $this->diffVisualizer->visualizeEntityContentDiff( $diff ); + } - return $this->diffVisualizer->visualizeEntityContentDiff( $diff ); + return parent::generateContentDiffBody( $old, $new ); } /** @@ -204,7 +211,8 @@ $parserOptions->setTidy( true ); $parserOptions->setEditSection( false ); - $parserOptions->addExtraKey("diff=1"); // don't poison parser cache with diff-specific stuff + // Do not poison parser cache with diff-specific stuff + $parserOptions->addExtraKey( 'diff=1' ); $parserOutput = $page->getParserOutput( $parserOptions, $rev->getId() ); return $parserOutput; @@ -216,9 +224,13 @@ * @return string */ protected function getDiffBodyCacheKey() { - return wfMemcKey( 'diff', 'version', MW_DIFF_VERSION, - 'oldid', $this->getOldid(), 'newid', $this->getNewid(), - 'lang', $this->getLanguage()->getCode() ); + return wfMemcKey( + 'diff', + 'version', MW_DIFF_VERSION, + 'oldid', $this->getOldid(), + 'newid', $this->getNewid(), + 'lang', $this->getLanguage()->getCode() + ); } } -- To view, visit https://gerrit.wikimedia.org/r/165700 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I12269f2d55adf0d3ecb6b165013f40208aeb3afb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits