Daniel Kinzler 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:
  Aude: Verified; Looks good to me, but someone else must approve
  Daniel Kinzler: Looks good to me, approved



diff --git a/repo/includes/changeop/ChangeOpMainSnak.php 
b/repo/includes/changeop/ChangeOpMainSnak.php
index 247e5a1..00f2b9e 100644
--- a/repo/includes/changeop/ChangeOpMainSnak.php
+++ b/repo/includes/changeop/ChangeOpMainSnak.php
@@ -5,6 +5,8 @@
 use InvalidArgumentException;
 use Wikibase\Snak;
 use Wikibase\Lib\EntityIdFormatter;
+use Wikibase\DataModel\Entity\EntityIdValue;
+use DataValues\GlobeCoordinateValue;
 
 /**
  * Class for mainsnak change operation
@@ -179,11 +181,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/83780
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib6df76009157b867e051f8d3fea822636bf850e9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: mw1.22-wmf16
Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com>
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