Bug description
where('column', $value) and whereIn('column', [$value]) return different results for the same value, because they compare differently:
IteratorBuilder::filterWhereIn() has the same case-sensitive behaviour via in_array(), so this isn't specific to the Stache driver.
I don't have a view on which is correct, but the two should presumably agree. whereNotIn / filterTestNotEquals have the same split.
How to reproduce
On any Statamic site, with an entry whose slug is my-page:
use Statamic\Facades\Entry;
Entry::query()->where('slug', 'MY-PAGE')->count(); // 1
Entry::query()->whereIn('slug', ['MY-PAGE'])->count(); // 0
Entry::query()->where('slug', 'my-page')->count(); // 1
Entry::query()->whereIn('slug', ['my-page'])->count(); // 1
Logging
- Statamic 6.24.2 (verified unchanged in v6.32.0)
- Laravel 12.64.0, PHP 8.4
- Stache (flat file) and Iterator builders both affected
Why it bit us
SEO Pro's redirects sit on both methods: creating a redirect validates uniqueness with where('source', …) while serving one matches with whereIn('source', …). The result is that a redirect for /TimberWalk 404s when the stored source is /Timberwalk/, and the CP simultaneously refuses to let an editor create the missing redirect because its uniqueness check thinks one already exists. Filed separately against seo-pro, but the underlying disagreement is here.
Bug description
where('column', $value)andwhereIn('column', [$value])return different results for the same value, because they compare differently:where()goes throughfilterTestEquals(), which lowercases both sides:https://github.com/statamic/cms/blob/v6.32.0/src/Query/Builder.php#L775-L778
whereIn()goes throughfilterWhereIn(), which uses anarray_flip+isset()lookup — case-sensitive, since PHP array keys are:https://github.com/statamic/cms/blob/v6.32.0/src/Stache/Query/Builder.php#L158-L165
IteratorBuilder::filterWhereIn()has the same case-sensitive behaviour viain_array(), so this isn't specific to the Stache driver.I don't have a view on which is correct, but the two should presumably agree.
whereNotIn/filterTestNotEqualshave the same split.How to reproduce
On any Statamic site, with an entry whose slug is
my-page:Logging
Why it bit us
SEO Pro's redirects sit on both methods: creating a redirect validates uniqueness with
where('source', …)while serving one matches withwhereIn('source', …). The result is that a redirect for/TimberWalk404s when the stored source is/Timberwalk/, and the CP simultaneously refuses to let an editor create the missing redirect because its uniqueness check thinks one already exists. Filed separately against seo-pro, but the underlying disagreement is here.