This repository has been archived by the owner on May 13, 2021. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would suggest to check if the
$results
parameter is aSearchResult
object before and then casting the object to an array.e.g.
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.
Correct me if I'm wrong, but if in the custom search we use
rawSearch()
instead ofsearch()
we can keepcount($results['hits'])
instead of->getHitsCount()
?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.
@shokme correct. but I think as you mentioned in #87 (comment) that the PHP SDK (I didn't check on this) changed, it may be that other integrations are broken or will break if updated to the newer versions.
With my change we could also fix older integrations that copied the example from the docs with
->search()
in their custom query.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.
@shokme the only change needed to work with the new behaviour would be my suggestion from #86 (comment)
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 don't remember everything about the PHP SDK changes, but it safe as long as it allow us to work with arrays and as I remember it will.
if we do this change, we should do it for every case (I didn't check if there is more than just that one) that can throw the object as array error.
We should find a away to have the
->toArray()
conversion earlier than in each methods ?Anyway, it is hard to me to find time at the moment. So I can't work on making everything perfect right now.
If you have free time and want to do it feel free to open another PR that will apply your change on every case that could throw an object as array error.(if this is the only one let me now and I will merge it of course)
Thank you for your time !