Skip to content

Conversation

@Krzemo
Copy link
Contributor

@Krzemo Krzemo commented Jan 7, 2025

Fixes #11323

A chain of though here ....

  1. Collection filtering in EntryQueryBuilder.php:
public function where($column, $operator = null, $value = null, $boolean = 'and')
{
    if ($column === 'collection') {
        $this->collections[] = $operator;
        return $this;
    }
    // ...
}

When someone does a collection query {{ collection:blog }} (Entry::query()->where('collection', 'blog')), the collection condition is intercepted and stored in a separate $collections property instead of being handled as a normal where clause.

  1. Then in the status queries in EntryQueryBuilder.php:
protected function addCollectionWhereToStatusQuery($query, $collection): void
{
    // Using collectionHandle instead of collection because we intercept collection
    // and put it on a property. In this case we actually want the indexed value.
    $query->where('collectionHandle', $collection);
}

The code explicitly uses 'collectionHandle' because it needs to bypass the interception of 'collection' queries that happens in the where() method.

Seems like we should only have 'collectionHandle' because:

  1. It's what's actually used for index-based lookups
  2. 'collection' queries get handled through a different mechanism
  3. Having both would duplicate data unnecessarily
  4. Creating it during Stache::warm() ensures it's available when needed for status queries

I hope Im right here ...

@Krzemo Krzemo changed the title Changing Stache index name from collection to collectionHandle [5.x] Changing Stache index name from collection to collectionHandle Jan 7, 2025
@jasonvarga jasonvarga merged commit 5627f7b into statamic:5.x Sep 24, 2025
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A Stache index file with wrong filename gets created on Stache:warm()

2 participants