Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[5.x] Changing Stache index name from collection to collectionHandle #11324

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from

Conversation

Krzemo
Copy link

@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
# for free to join this conversation on GitHub. Already have an account? # 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()
1 participant