-
Notifications
You must be signed in to change notification settings - Fork 737
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
Fix json_decode problem #1005
Fix json_decode problem #1005
Conversation
…bigintConversion config parameter to the connection, provide tests for both
))); | ||
$response->setJsonBigintConversion(true); | ||
|
||
$this->assertTrue(is_array($response->getData())); |
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 test would also pass without the setJonBigintVersion(true), right?
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.
Yes, this test would also pass without L215, but L215 makes the difference :)
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.
I'm fine with the test. But I assume this test would also have passed without the code changes you made? It is more for me to understand if we test if the bug was actually fixed or if we test that we can use the function without any side affects?
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.
No, it wouldn't since the return value of https://github.com/ruflin/Elastica/pull/1005/files#diff-b364251d02e70310f3c6e443372397d3L208 would be \stdClass
and not an array and there is not conversion or casting happening till the end of method.
@theDisco Thanks. Can you also update the CHANGELOG.md? |
@ruflin Sure, done. |
@@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file based on the | |||
|
|||
### Bugfixes | |||
- Function score query: corrected the `score_method` `average` to `avg` #975 | |||
- Set `json_decode()` assoc parameter to true in `Elastica\Response` #1005 |
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.
Sorry to bring this up again. But isn't the affect here, that if BIG_INT is enabled or not could be that the response object looks different?
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.
BIG_INT_* setting converts integers bigger than PHP_INT_MAX to a string, so yes, the response will be different (well some data types will be different), but it is the only way to deal with this without overflowing the integer.
@theDisco Thanks for the contribution. We should definitively discuss if we should use |
@ruflin if you look at the implementation of // extract arguments
$args = func_get_args();
// default to decoding into an assoc array
if (sizeof($args) === 1) {
$args[] = true;
}
// run decode
$array = call_user_func_array('json_decode', $args); And no, passing true would not have any side effects. |
@theDisco Ugh :-( Surprising that nobody of us spotted that in the past. But that is great news. |
As discussed in #1003 here is the PR that should at least make elastica to work properly when bigintConversion setting is set to true.