-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-274: Fix zval_to_bson() encoding of BSON\Serializable objects #40
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
Conversation
It is really difficult to understand the effect of this change in the modified test case. |
} | ||
zval_to_bson(retval, flags, &child, NULL TSRMLS_CC); | ||
bson_append_document_end(bson, &child); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For PHPC-275: this conditional and the preceding (!obj_data)
conditional (when zend_call_method()
fails) are the relevant changes for the bson-encode_error-002.phpt
test case.
The attached |
13bd5ba
to
2cc2ecc
Compare
tmp_ht->nApplyCount++; | ||
} | ||
if (Z_TYPE_P(obj_data) != IS_ARRAY) { | ||
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "Expected %s() to return an array, %s given", BSON_SERIALIZE_FUNC_NAME, zend_get_type_by_const(Z_TYPE_P(obj_data))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an UnexpectedValueException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to UnexpectedValueException please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm |
Previously, only BSON\Persistable objects were handled.
This also refactors the handling to be consistent with zval_to_bson().
PHPC-274: Fix zval_to_bson() encoding of BSON\Serializable objects
Previously, only BSON\Persistable objects were handled.