Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement UnDeserializableValue::newFromJSON and toJSON #78

Merged
merged 1 commit into from
Jun 1, 2015

Conversation

filbertkm
Copy link
Collaborator

made the error attribute of the value be a string, with
the error reason, for more consistency with the backend
implementation and for better ease of use.

also fixed more of the wording and variable names from
"ununserializable" to "undeserializable", for consistency purposes.

Bug: T99231

function( ofType, unUnserializableStructure, unserializeError ) {
if( !$.isPlainObject( unUnserializableStructure ) ) {
throw new Error( 'The un-unserializable structure has to be a plain object' );
function( ofType, unDeserializableStructure, deserializeError ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PHP class uses the order $data, $type, $error. Not sure what's better and if it's worth the trouble to change one of the implementations. What do you think?

@thiemowmde
Copy link
Contributor

If you want we can merge this and fix the tiny issues later. Please tell me.

@filbertkm
Copy link
Collaborator Author

I think we need to go back to the way I ordered the params before. UnDeserializableValue inherits from dv.DataValue which has a specific order. I think it's best to be consistent with that, even if it's different that in php.

@filbertkm filbertkm force-pushed the undeserializable branch 2 times, most recently from 01390fe to 867ee33 Compare May 19, 2015 13:31
@thiemowmde
Copy link
Contributor

What do you mean with "specific order [in] dv.DataValue"?

return {
type: 'undeserializable',
data: {
targetType: this.getTargetType(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite different from how it was before. I do not know how much this matters. What was your reason to change it?


/**
* @inheritdoc
*
* @return {string}
* @return {int}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why int? This is the error message, which is a string, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@filbertkm
Copy link
Collaborator Author

@thiemowmde suppose the order doesn't totally matter, but in SnakDeserializer we have:

this.newDataValue = function( dataValueType, data )

it is independent though from the order we order the params here, and suppose we could change. i just prefer the order to be same as there.

@thiemowmde
Copy link
Contributor

For reference:

  • Agree on the order. SnakSerializer.js also uses type, value.
  • I would feel a little bit better if the keys are the same as in UnDeserializableValue.php: type, value, error. But this is no reason to block this, since these names are not going anywhere if I'm correct.

made the error attribute of the value be a string, with
the error reason, for more consistency with the backend
implementation and for better ease of use.

also fixed more of the wording and variable names from
"ununserializable" to "undeserializable", for consistency purposes.

Bug: T99231
@filbertkm
Copy link
Collaborator Author

gone back again and made the order "value, type, error" throughout the value class and am adjusting the SnakSerializer. ( i really don't care, but suppose it's consistent with php is a good reason)

@filbertkm
Copy link
Collaborator Author

and squashed the commits

@thiemowmde
Copy link
Contributor

Thanks. +2 when the tests succeed.

@filbertkm
Copy link
Collaborator Author

@filbertkm
Copy link
Collaborator Author

https://phabricator.wikimedia.org/T96892 is the correct task

thiemowmde added a commit that referenced this pull request Jun 1, 2015
Implement UnDeserializableValue::newFromJSON and toJSON
@thiemowmde thiemowmde merged commit 1045653 into master Jun 1, 2015
@thiemowmde thiemowmde deleted the undeserializable branch June 1, 2015 18:35
@thiemowmde thiemowmde added this to the 0.7.0 milestone Jul 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants