Tobias Gritschacher has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/82816


Change subject: (bug 52501) don't break diff when dataValue could not be 
formatted
......................................................................

(bug 52501) don't break diff when dataValue could not be formatted

Change-Id: Idc0922b270b9df8a30ab9373a691aa4df7f193ac
---
M lib/includes/ClaimDifferenceVisualizer.php
1 file changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/16/82816/1

diff --git a/lib/includes/ClaimDifferenceVisualizer.php 
b/lib/includes/ClaimDifferenceVisualizer.php
index cd35dc5..8f6987d 100644
--- a/lib/includes/ClaimDifferenceVisualizer.php
+++ b/lib/includes/ClaimDifferenceVisualizer.php
@@ -9,6 +9,8 @@
 use Diff\Diff;
 use RuntimeException;
 use Wikibase\Lib\EntityIdFormatter;
+use DataValues\GlobeCoordinateValue;
+use Wikibase\DataModel\Entity\EntityIdValue;
 
 /**
  * Class for generating HTML for Claim Diffs.
@@ -277,16 +279,21 @@
 
                if ( $snakType === 'value' ) {
                        $dataValue = $snak->getDataValue();
+                       $diffValueString = "";
 
                        // FIXME! should use some value formatter
-                       if ( $dataValue instanceof EntityId ) {
-                               $diffValueString = $this->getEntityLabel( 
$dataValue );
+                       if ( $dataValue instanceof EntityIdValue ) {
+                               $diffValueString = $this->getEntityLabel( 
$dataValue->getEntityId() );
                        } else if ( $dataValue instanceof TimeValue ) {
                                // TODO: this will just display the plain 
ISO8601-string,
                                // we should instead use a decent formatter
                                $diffValueString = $dataValue->getTime();
-                       } else {
+                       } else if ( $dataValue instanceof GlobeCoordinateValue 
) {
+                               $diffValueString = $dataValue->getLatitude() . 
', ' . $dataValue->getLongitude();
+                       } else if ( is_string( $dataValue->getValue() ) ) {
                                $diffValueString = $dataValue->getValue();
+                       } else {
+                               //type not supported;
                        }
 
                        return $diffValueString;

-- 
To view, visit https://gerrit.wikimedia.org/r/82816
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc0922b270b9df8a30ab9373a691aa4df7f193ac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: mw1.22-wmf16
Gerrit-Owner: Tobias Gritschacher <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to