Conversation
…roved query syntax
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Security | 4 high |
🟢 Metrics 0 duplication
Metric Results Duplication 0
TIP This summary will be updated as you push new changes. Give us feedback
Fluf22
left a comment
There was a problem hiding this comment.
Worth noting in the upgrade guide: since the engine now uses the filters key instead of numericFilters, any manual ->with(['filters' => '...']) will be overwritten by the engine's computed filters. Users who were combining with(['filters' => ...]) alongside where() clauses need to move everything into where() calls instead.
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function search(Builder $builder) | ||
| { | ||
| return $this->performSearch($builder, array_filter([ | ||
| 'numericFilters' => $this->filters($builder), | ||
| 'filters' => $this->filters($builder), | ||
| 'hitsPerPage' => $builder->limit, | ||
| ])); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function paginate(Builder $builder, $perPage, $page) | ||
| { | ||
| return $this->performSearch($builder, [ | ||
| 'numericFilters' => $this->filters($builder), | ||
| 'filters' => $this->filters($builder), | ||
| 'hitsPerPage' => $perPage, | ||
| 'page' => $page - 1, | ||
| ]); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function map(Builder $builder, $results, $searchable) | ||
| { | ||
| if (count($results['hits']) === 0) { | ||
| return $searchable->newCollection(); | ||
| } | ||
|
|
||
| return app(ModelsResolver::class)->from($builder, $searchable, $results); | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function lazyMap(Builder $builder, $results, $searchable) | ||
| { | ||
| return LazyCollection::make($this->map($builder, $results, $searchable)); | ||
| } |
There was a problem hiding this comment.
Those are not needed anymore since they are exactly the same than the grand-parent class: https://github.com/laravel/scout/blob/11.x/src/Engines/AlgoliaEngine.php#L99-L122
| public function whereBetween($field, array $values): self | ||
| { | ||
| return $this->where("$field:", "{$this->transform($values[0])} TO {$this->transform($values[1])}"); | ||
| return parent::where($field, ':', [$this->transform($values[0]), $this->transform($values[1])]); |
There was a problem hiding this comment.
This is worth documenting, I believe, since it's a non-standard entry in $wheres: for operator ':', the value is an array instead of scalar.
It works because filters() has the matching match arm, but anyone iterating $builder->wheres expecting the standard Scout v11 format will have a surprise
Describe your change
Upgrade Laravel Scout from v10 to v11 [API-364](https://algolia.atlassian.net/browse/API-364)
This PR upgrades laravel/scout from ^10.11.6 to ^11.0.0, removing the legacy numericFilters array-based filtering and replacing it with Scout v11's native filters string syntax. Where conditions are now stored using Scout v11's structured ['field', 'operator', 'value'] format and $whereIns property, removing all manual $wheres manipulation.
Breaking Changes