Tobias Gritschacher has uploaded a new change for review.

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


Change subject: Support multiple datavalues in autosummaries in changeops
......................................................................

Support multiple datavalues in autosummaries in changeops

- this is a hotfix for deployment only
- on master this should be fixed using formatters

Change-Id: Ica8171a2e1cbb5369c1775e8f5f63f299455d8d6
---
M repo/includes/changeop/ChangeOpMainSnak.php
M repo/includes/changeop/ChangeOpQualifier.php
M repo/includes/changeop/ChangeOpReference.php
3 files changed, 36 insertions(+), 2 deletions(-)


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

diff --git a/repo/includes/changeop/ChangeOpMainSnak.php 
b/repo/includes/changeop/ChangeOpMainSnak.php
index ba35240..6231419 100644
--- a/repo/includes/changeop/ChangeOpMainSnak.php
+++ b/repo/includes/changeop/ChangeOpMainSnak.php
@@ -8,6 +8,7 @@
 use Wikibase\Lib\EntityIdFormatter;
 use Wikibase\DataModel\Entity\EntityIdValue;
 use DataValues\GlobeCoordinateValue;
+use DataValues\TimeValue;
 
 /**
  * Class for mainsnak change operation
diff --git a/repo/includes/changeop/ChangeOpQualifier.php 
b/repo/includes/changeop/ChangeOpQualifier.php
index 86b6f6b..a6b4a42 100644
--- a/repo/includes/changeop/ChangeOpQualifier.php
+++ b/repo/includes/changeop/ChangeOpQualifier.php
@@ -6,6 +6,9 @@
 use Wikibase\Snak;
 use Wikibase\Snaks;
 use Wikibase\Lib\EntityIdFormatter;
+use Wikibase\DataModel\Entity\EntityIdValue;
+use DataValues\GlobeCoordinateValue;
+use DataValues\TimeValue;
 
 /**
  * Class for qualifier change operation
@@ -198,8 +201,21 @@
                //TODO: use formatters here!
                if ( $snak instanceof PropertyValueSnak ) {
                        $value = $snak->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 = $snak->getType();
+                       $value = $snak->getType(); // todo handle no values in 
general way (needed elsewhere)
                }
 
                $args = array( $propertyId => array( $value ) );
diff --git a/repo/includes/changeop/ChangeOpReference.php 
b/repo/includes/changeop/ChangeOpReference.php
index b56df8e..2e27333 100644
--- a/repo/includes/changeop/ChangeOpReference.php
+++ b/repo/includes/changeop/ChangeOpReference.php
@@ -8,6 +8,9 @@
 use Wikibase\Statement;
 use Wikibase\PropertyValueSnak;
 use Wikibase\Lib\EntityIdFormatter;
+use Wikibase\DataModel\Entity\EntityIdValue;
+use DataValues\GlobeCoordinateValue;
+use DataValues\TimeValue;
 
 /**
  * Class for reference change operation
@@ -212,8 +215,22 @@
                //TODO: use formatters here!
                if ( $snak instanceof PropertyValueSnak ) {
                        $value = $snak->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 = $snak->getType();
+                       $value = $snak->getType(); // todo handle no values in 
general way (needed elsewhere)
                }
 
                $args = array( $propertyId => array( $value ) );

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

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

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

Reply via email to