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

Change subject: Fix uncatched StorageException in EntitySavingHelper
......................................................................

Fix uncatched StorageException in EntitySavingHelper

This currently causes failing tests on the MediaInfo extension. The
change that causes this was I5c26fc9. I removed a generic catch there
that was hiding all kinds of exceptions that should not surface in API
requests. This is just an other one of these.

Change-Id: Ia81cf8266dc7fb0396c43b005216129ceb090f6f
---
M repo/includes/Api/EntitySavingHelper.php
M repo/tests/phpunit/includes/Api/EditEntityTest.php
2 files changed, 9 insertions(+), 6 deletions(-)


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

diff --git a/repo/includes/Api/EntitySavingHelper.php 
b/repo/includes/Api/EntitySavingHelper.php
index a94f5cf..69a931a 100644
--- a/repo/includes/Api/EntitySavingHelper.php
+++ b/repo/includes/Api/EntitySavingHelper.php
@@ -16,6 +16,7 @@
 use Wikibase\EntityFactory;
 use Wikibase\Lib\Store\EntityRevisionLookup;
 use Wikibase\Lib\Store\EntityStore;
+use Wikibase\Lib\Store\StorageException;
 use Wikibase\Summary;
 use Wikibase\SummaryFormatter;
 
@@ -265,8 +266,12 @@
 
                        $entity->setId( $customId );
                } else {
-                       // NOTE: We need to assign an ID early, for things like 
the ClaimIdGenerator.
-                       $this->entityStore->assignFreshId( $entity );
+                       try {
+                               // NOTE: We need to assign an ID early, for 
things like the ClaimIdGenerator.
+                               $this->entityStore->assignFreshId( $entity );
+                       } catch ( StorageException $ex ) {
+                               $this->errorReporter->dieException( $ex, 
'invalid-entity-id' );
+                       }
                }
 
                return $entity;
diff --git a/repo/tests/phpunit/includes/Api/EditEntityTest.php 
b/repo/tests/phpunit/includes/Api/EditEntityTest.php
index 9b39ed9..a197baa 100644
--- a/repo/tests/phpunit/includes/Api/EditEntityTest.php
+++ b/repo/tests/phpunit/includes/Api/EditEntityTest.php
@@ -5,8 +5,6 @@
 use ApiUsageException;
 use Wikibase\DataModel\Entity\Item;
 use Wikibase\DataModel\Entity\Property;
-use Wikibase\DataModel\Services\Statement\StatementGuidParsingException;
-use Wikibase\Lib\Store\StorageException;
 use Wikibase\Repo\WikibaseRepo;
 
 /**
@@ -862,8 +860,8 @@
                        'create mediainfo with automatic id' => [
                                'p' => [ 'new' => 'mediainfo', 'data' => '{}' ],
                                'e' => [ 'exception' => [
-                                       'type' => StorageException::class,
-                                       'message' => 'mediainfo entities do not 
support automatic IDs'
+                                       'type' => ApiUsageException::class,
+                                       'code' => 'invalid-entity-id',
                                ] ],
                                'requires' => 'mediainfo' // skip if MediaInfo 
is not configured
                        ],

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia81cf8266dc7fb0396c43b005216129ceb090f6f
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