Daniel Werner has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/64545


Change subject: (Bug 48622) When unserializing Snaks, consider faulty data 
value JSON
......................................................................

(Bug 48622) When unserializing Snaks, consider faulty data value 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, 8 insertions(+), 4 deletions(-)


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

diff --git a/lib/resources/wikibase.datamodel/wikibase.Snak.js 
b/lib/resources/wikibase.datamodel/wikibase.Snak.js
index 3eb5924..682d456 100644
--- a/lib/resources/wikibase.datamodel/wikibase.Snak.js
+++ b/lib/resources/wikibase.datamodel/wikibase.Snak.js
@@ -121,10 +121,14 @@
        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 ) {
+                       console.log( 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: newchange
Gerrit-Change-Id: I4f9215add1f3e964f229cbe222e9b0562045648d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to