Aude has submitted this change and it was merged.

Change subject: Handle error in property parser function
......................................................................


Handle error in property parser function

- e.g. unknown globecoordinate

Change-Id: I09c92f297c0f075fe50bc61128b3a9bdc737c072
---
M client/includes/parserhooks/PropertyParserFunction.php
1 file changed, 22 insertions(+), 15 deletions(-)

Approvals:
  Aude: Verified; Looks good to me, approved



diff --git a/client/includes/parserhooks/PropertyParserFunction.php 
b/client/includes/parserhooks/PropertyParserFunction.php
index bd1a9e4..072eced 100644
--- a/client/includes/parserhooks/PropertyParserFunction.php
+++ b/client/includes/parserhooks/PropertyParserFunction.php
@@ -128,25 +128,32 @@
        public function renderForEntityId( EntityId $entityId, $propertyLabel ) 
{
                wfProfileIn( __METHOD__ );
 
-               $entity = $this->entityLookup->getEntity( $entityId );
+               try {
+                       $entity = $this->entityLookup->getEntity( $entityId );
 
-               if ( !$entity ) {
+                       if ( !$entity ) {
+                               wfProfileOut( __METHOD__ );
+                               return '';
+                       }
+
+                       $claims = $this->getClaimsForProperty( $entity, 
$propertyLabel );
+
+                       if ( $claims->isEmpty() ) {
+                               wfProfileOut( __METHOD__ );
+                               return '';
+                       }
+
+                       $snakList = $claims->getMainSnaks();
+                       $text = $this->formatSnakList( $snakList, 
$propertyLabel );
+
+
+                       wfProfileOut( __METHOD__ );
+                       return $text;
+               } catch ( \Exception $e ) {
+                       wfDebugLog( __CLASS__, __METHOD__ . ': Unable to render 
snak' );
                        wfProfileOut( __METHOD__ );
                        return '';
                }
-
-               $claims = $this->getClaimsForProperty( $entity, $propertyLabel 
);
-
-               if ( $claims->isEmpty() ) {
-                       wfProfileOut( __METHOD__ );
-                       return '';
-               }
-
-               $snakList = $claims->getMainSnaks();
-               $text = $this->formatSnakList( $snakList, $propertyLabel );
-
-               wfProfileOut( __METHOD__ );
-               return $text;
        }
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I09c92f297c0f075fe50bc61128b3a9bdc737c072
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: mw1.22-wmf5
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>

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

Reply via email to