jenkins-bot has submitted this change and it was merged.
Change subject: (Bug 48622) When unserializing Snaks, consider faulty data
values JSON
......................................................................
(Bug 48622) When unserializing Snaks, consider faulty data values JSON
If unserializing a data value fails, a UnUnserializableValue DataValue will be
created in the place
of the actual data value. This could for example happen if the expected JSON
changes for some
reason and no script ran over existing data to migrate existing JSON to the new
representation.
NOTE: This depends on I4dba219 in the DataValues extensions repository
Change-Id: I4f9215add1f3e964f229cbe222e9b0562045648d
---
M lib/resources/wikibase.datamodel/wikibase.Snak.js
1 file changed, 7 insertions(+), 4 deletions(-)
Approvals:
Tobias Gritschacher: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/resources/wikibase.datamodel/wikibase.Snak.js
b/lib/resources/wikibase.datamodel/wikibase.Snak.js
index 3eb5924..3f20452 100644
--- a/lib/resources/wikibase.datamodel/wikibase.Snak.js
+++ b/lib/resources/wikibase.datamodel/wikibase.Snak.js
@@ -121,10 +121,13 @@
var map = $.extend( {}, json );
if( json.snaktype === 'value' ) {
- map.datavalue = dv.newDataValue(
- json.datavalue.type,
- json.datavalue.value
- );
+ var type = json.datavalue.type,
+ value = json.datavalue.value;
+ try{
+ map.datavalue = dv.newDataValue( type, value );
+ } catch( e ) {
+ map.datavalue = new dv.UnUnserializableValue( value,
type, e );
+ }
}
return SELF.newFromMap( map );
};
--
To view, visit https://gerrit.wikimedia.org/r/64545
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4f9215add1f3e964f229cbe222e9b0562045648d
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits