jenkins-bot has submitted this change and it was merged.

Change subject: Catch property not found exception in snak formatter
......................................................................


Catch property not found exception in snak formatter

the exception occurs, for example, when referencing a deleted property
with the parser function in the client.

Change-Id: Ib1ddec400cce0e117c952e119899486046c9b548
---
M lib/includes/SnakFormatter.php
1 file changed, 11 insertions(+), 3 deletions(-)

Approvals:
  Daniel Kinzler: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/SnakFormatter.php b/lib/includes/SnakFormatter.php
index ba47249..1c29ab6 100644
--- a/lib/includes/SnakFormatter.php
+++ b/lib/includes/SnakFormatter.php
@@ -90,10 +90,18 @@
        }
 
        private function formatPropertyValueSnak( PropertyValueSnak $snak, 
$languageCode ) {
-               $dataValue = $snak->getDataValue();
-               $dataTypeId = $this->getDataTypeForProperty( 
$snak->getPropertyId() );
+               try {
+                       $dataValue = $snak->getDataValue();
+                       $dataTypeId = $this->getDataTypeForProperty( 
$snak->getPropertyId() );
 
-               return $this->typedValueFormatter->formatToString( $dataValue, 
$dataTypeId, $languageCode );
+                       return $this->typedValueFormatter->formatToString( 
$dataValue, $dataTypeId, $languageCode );
+               } catch ( PropertyNotFoundException $e ) {
+                       // @todo nicer error handling!
+                       wfDebugLog( __CLASS__, __METHOD__ . ': Property '
+                               . $snak->getPropertyId()->getPrefixedId() . ' 
not found.' );
+               }
+
+               return '';
        }
 
        private function getDataTypeForProperty( EntityId $propertyId ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib1ddec400cce0e117c952e119899486046c9b548
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to