Closed bakerkretzmar closed 2 years ago
Awesome, thanks!
We have just updated our application the the latest version of this package (v2.0.2 -> v2.0.3) which includes this PR and it is causing all indexing operations to fail for us.
We get the follow exception whenever an indexing operation is performed...
BadMethodCallException: Method Illuminate\Database\Eloquent\Collection::searchable does not exist.
Surely this stems from the removal of this line?
/ping @bakerkretzmar @DevinCodes
On further investigation, it seems that this stems from the fact that we don't use the Searchable
trait on our models, as we don't want to create individual Model indexes. We only want the aggregated index.
Interesting. Now that Scout Extended is not using the macros at all it probably doesn't make any difference to add that back. Thanks for the ping, looks like @DevinCodes is about to PR a fix but let me know if you need anything else 👍🏻 sorry about that!
No worries. I guess we are all using this in various different ways and it is sometime tricky to think of everyone else's use cases.
PR #310 fixes the issue for us 👍
Fingers crossed for a fast merge. Maybe some tests would be good around this issue.
@JayBizzle Do you have, by any chance, a short snippet we could use to reproduce this, please?
I'll make sure to merge and release this today so we can fix this asap, but I'd like to add a test if possible to prevent this from occurring again.
I'll try and put together example this evening, but basically it would involve creating an Aggregator
, of which the Models
defined do not use the use the Searchable
trait.
Thanks, I've been able to reproduce it indeed, #310 will resolve the issue. I'll merge and release, and take time to write tests for this later in the week to prevent this from creeping in again.
Thank you both for your help on this!
We just release v2.0.4 with a fix for this, sorry for the inconvenience!
Describe your change
This PR adds an
unsearchable
method to Scout Extended'sAggregatorCollection
class. This ensures that any time an Aggregator is removed from search, it gets removed using thequeueRemoveFromSearch
method on itself or on the baseAggregator
class it extends, never the method in Scout's baseSearchable
trait.The issue is demonstrated with a failing test in the first commit, the fix is included in the second commit and that test should then pass.
I also removed the manual re-registration of the Collection macros in the aggregator, since it's now unnecessary—for
searchable
, Scout Extended's behaviour is the same as Scout's, and forunsearchable
, Scout Extended now doesn't use a macro at all.What problem is this fixing?
Any time any Searchable Eloquent model boots, it registers Scout's base
searchable
andunsearchable
Collection macros. Scout Extended's Aggregators also register these same macros, overriding Scout's, specifically to avoid queuing the removal of deleted models. If any Searchable model boots after an Aggregator`, Scout's macros will be re-registered, overriding Scout Extended's. Fixes #305.cc @DevinCodes