jenkins-bot has submitted this change and it was merged. Change subject: make getEntityIdForClaim use ClaimGuidParser ......................................................................
make getEntityIdForClaim use ClaimGuidParser Change-Id: I4733cfd29e46eef891e36d44d08b75a4a1f96973 --- M repo/includes/ClaimSaver.php 1 file changed, 5 insertions(+), 20 deletions(-) Approvals: Addshore: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/ClaimSaver.php b/repo/includes/ClaimSaver.php index 9d7e469..d66ff0e 100644 --- a/repo/includes/ClaimSaver.php +++ b/repo/includes/ClaimSaver.php @@ -7,6 +7,7 @@ use Status; use ValueParsers\ParseException; use Wikibase\Claims; +use Wikibase\DataModel\Claim\ClaimGuidParsingException; use Wikibase\ExceptionWithCode; use Wikibase\Repo\WikibaseRepo; @@ -99,30 +100,14 @@ * @throws ExceptionWithCode */ protected function getEntityIdForClaim( Claim $claim ) { - $guid = $claim->getGuid(); - - if ( $guid === null ) { - throw new ExceptionWithCode( 'The ID of the claim needs to be set', 'setclaim-no-guid' ); - } - try { - $entityId = Entity::getIdFromClaimGuid( $guid ); + $parser = WikibaseRepo::getDefaultInstance()->getClaimGuidParser(); + return $parser->parse( $claim->getGuid() )->getEntityId(); } - catch ( MWException $exception ) { + catch( ClaimGuidParsingException $exception ) { + //todo fix the error code below to be 'invalid-guid' throw new ExceptionWithCode( $exception->getMessage(), 'setclaim-invalid-guid' ); } - - $idParser = WikibaseRepo::getDefaultInstance()->getEntityIdParser(); - - try { - $entityId = $idParser->parse( $entityId ); - } - catch ( ParseException $parseException ) { - throw new ExceptionWithCode( $parseException->getMessage(), 'setclaim-invalid-guid' ); - } - - assert( $entityId instanceof EntityId ); - return $entityId; } /** -- To view, visit https://gerrit.wikimedia.org/r/83782 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4733cfd29e46eef891e36d44d08b75a4a1f96973 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits