sherlock
sherlock copied to clipboard
json_decode() Errors
An exception should be thrown if PHP fails to decode a json string. It's possible for ElasticSearch to return a bad string.
In ES one can insert a record as follows: curl -XPOST -d '{ field : "data"}'
When the correct way would be: curl -XPOST -d '{ "field" : "data"}'
Note the double quotes around the field name. ES accepts this and returns "ok", "true". When querying from the PHP client ES returns the faulty json string and the client isn't able to decode it, the program execution continues and stops with a 'Call to undefined method query() in Sherlock/Sherlock'
Interesting, this is indeed bad behavior. Sherlock should definitely throw exceptions on json errors, rather than allowing execution to continue. I'll look into it later this week when I get a chance.