Tobias Gritschacher has submitted this change and it was merged.

Change subject: Support coordinate and entityidvalue in autossummaries
......................................................................


Support coordinate and entityidvalue in autossummaries

- this affects all API modules using ChangeOpMainSnak
- this is a fix for deployment only
- coordinates were just left blank in the summaries till now
- also the entityid were not shown anymore due to the changes in the
  EntityId class
- on master this should be fixed using formatters

Bug: 54005
Change-Id: Ib6df76009157b867e051f8d3fea822636bf850e9
---
M repo/includes/changeop/ChangeOpMainSnak.php
1 file changed, 17 insertions(+), 2 deletions(-)

Approvals:
  Tobias Gritschacher: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/changeop/ChangeOpMainSnak.php 
b/repo/includes/changeop/ChangeOpMainSnak.php
index bbc2a25..ba35240 100644
--- a/repo/includes/changeop/ChangeOpMainSnak.php
+++ b/repo/includes/changeop/ChangeOpMainSnak.php
@@ -6,6 +6,8 @@
 use Wikibase\Lib\ClaimGuidGenerator;
 use Wikibase\Snak;
 use Wikibase\Lib\EntityIdFormatter;
+use Wikibase\DataModel\Entity\EntityIdValue;
+use DataValues\GlobeCoordinateValue;
 
 /**
  * Class for mainsnak change operation
@@ -155,11 +157,24 @@
        protected function getClaimSummaryArgs( Snak $mainSnak ) {
                $propertyId = $this->idFormatter->format( 
$mainSnak->getPropertyId() );
 
-               //TODO: use formatters here!
                if ( $mainSnak instanceof PropertyValueSnak ) {
                        $value = $mainSnak->getDataValue();
+
+                       // TODO: we should use value formatters here!
+                       if ( $value instanceof EntityIdValue ) {
+                               $value = $value->getEntityId();
+                       } elseif ( $value instanceof TimeValue ) {
+                               $value = $value->getTime();
+                       } elseif ( $value instanceof GlobeCoordinateValue ) {
+                               $value = $value->getLatitude() . ', ' . 
$value->getLongitude();
+                       } elseif ( is_string( $value->getValue() ) ) {
+                               $value = $value->getValue();
+                       } else {
+                               //type not supported;
+                               $value = "";
+                       }
                } else {
-                       $value = $mainSnak->getType();
+                       $value = $mainSnak->getType(); // todo handle no values 
in general way (needed elsewhere)
                }
 
                $args = array( $propertyId => array( $value ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib6df76009157b867e051f8d3fea822636bf850e9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: mw1.22-wmf18
Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>
Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to