Thiemo Mättig (WMDE) has uploaded a new change for review. (
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(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/15/395515/1
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: newchange
Gerrit-Change-Id: I7a2fec4f0ed6b1809806f6a56b64fc1c78c17abe
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