Tobias Gritschacher has uploaded a new change for review. https://gerrit.wikimedia.org/r/83780
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, 20 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/80/83780/1 diff --git a/repo/includes/changeop/ChangeOpMainSnak.php b/repo/includes/changeop/ChangeOpMainSnak.php index 247e5a1..f387759 100644 --- a/repo/includes/changeop/ChangeOpMainSnak.php +++ b/repo/includes/changeop/ChangeOpMainSnak.php @@ -5,6 +5,7 @@ use InvalidArgumentException; use Wikibase\Snak; use Wikibase\Lib\EntityIdFormatter; +use Wikibase\DataModel\Entity\EntityIdValue; /** * Class for mainsnak change operation @@ -179,12 +180,25 @@ protected function getClaimSummaryArgs( Snak $mainSnak ) { $propertyId = $this->idFormatter->format( $mainSnak->getPropertyId() ); - //TODO: use formatters here! - if ( $mainSnak instanceof PropertyValueSnak ) { - $value = $mainSnak->getDataValue(); - } else { - $value = $mainSnak->getType(); - } + 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(); // todo handle no values in general way (needed elsewhere) + } $args = array( $propertyId => array( $value ) ); return array( $args ); -- To view, visit https://gerrit.wikimedia.org/r/83780 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib6df76009157b867e051f8d3fea822636bf850e9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: mw1.22-wmf16 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