Thiemo Mättig (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/345517 )

Change subject: Properly report serialization errors in EditEntity API
......................................................................

Properly report serialization errors in EditEntity API

Instead of "crashing" with a technical exception, this type of errors
now surfaces properly as an API error the caller of the API can work
with.

Required for I2b10bc1.

Change-Id: I47e3ee1709d4aa8f847585eaf9e8d759184b99a7
---
M repo/includes/Api/ModifyEntity.php
1 file changed, 11 insertions(+), 4 deletions(-)


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

diff --git a/repo/includes/Api/ModifyEntity.php 
b/repo/includes/Api/ModifyEntity.php
index 7cceb2c..ee3f05d 100644
--- a/repo/includes/Api/ModifyEntity.php
+++ b/repo/includes/Api/ModifyEntity.php
@@ -5,6 +5,7 @@
 use ApiBase;
 use ApiMain;
 use LogicException;
+use MWContentSerializationException;
 use Status;
 use User;
 use Wikibase\ChangeOp\ChangeOp;
@@ -246,10 +247,16 @@
                        $this->errorReporter->dieError( 'Attempted modification 
of the item failed', 'failed-modify' );
                }
 
-               $status = $this->entitySavingHelper->attemptSaveEntity(
-                       $entity,
-                       $summary
-               );
+               try {
+                       $status = $this->entitySavingHelper->attemptSaveEntity(
+                               $entity,
+                               $summary
+                       );
+               } catch ( MWContentSerializationException $ex ) {
+                       // This happens if the $entity created via 
modifyEntity() above (possibly cleared
+                       // before) is not sufficiently initialized and failed 
serialization.
+                       $this->errorReporter->dieError( $ex->getMessage(), 
'failed-save' );
+               }
 
                $this->addToOutput( $entity, $status, $entityRevId );
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I47e3ee1709d4aa8f847585eaf9e8d759184b99a7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

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

Reply via email to