Skip to content

where() is case-insensitive but whereIn() is case-sensitive #15463

Description

@theRealPadster

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions