jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/395515 )
Change subject: Catch uncatched SerializationException in EntityContent::getNativeData ...................................................................... Catch uncatched SerializationException in EntityContent::getNativeData This is quite obviously a bug. Whenever a serializer is called, code must expect the serialization to fail, and handle the failure appropriately. However, this was never necessary here because it was impossible to feed an "invalid" entity to this serializer. The concept of an entity that can not be serialized never existed, but exists now with StorageLexemeSerializer. Personally I think StorageLexemeSerializer violates a contract and must be changed. But this is independend from this patch. This try-catch should be here no matter what. I decided to simply return the entity object as a fallback. Could also return an empty array, "really anything", as the interface says. Bug: T182082 Change-Id: I7a2fec4f0ed6b1809806f6a56b64fc1c78c17abe --- M repo/includes/Content/EntityContent.php 1 file changed, 6 insertions(+), 1 deletion(-) Approvals: Ladsgroup: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/Content/EntityContent.php b/repo/includes/Content/EntityContent.php index da186ac..bcecb60 100644 --- a/repo/includes/Content/EntityContent.php +++ b/repo/includes/Content/EntityContent.php @@ -16,6 +16,7 @@ use ParserOptions; use ParserOutput; use RuntimeException; +use Serializers\Exceptions\SerializationException; use Status; use Title; use User; @@ -450,7 +451,11 @@ // NOTE: this may or may not be consistent with what EntityContentCodec does! $serializer = WikibaseRepo::getDefaultInstance()->getAllTypesEntitySerializer(); - return $serializer->serialize( $this->getEntity() ); + try { + return $serializer->serialize( $this->getEntity() ); + } catch ( SerializationException $ex ) { + return $this->getEntity(); + } } /** -- To view, visit https://gerrit.wikimedia.org/r/395515 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7a2fec4f0ed6b1809806f6a56b64fc1c78c17abe Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.kr...@wikimedia.de> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.kr...@wikimedia.de> Gerrit-Reviewer: WMDE-leszek <leszek.mani...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits