From b344fc388e89eb6f0926547217806adea8418cfa Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 17 May 2024 14:58:24 +0100 Subject: [PATCH 1/4] Update example in collection tag docs --- content/collections/tags/collection.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/content/collections/tags/collection.md b/content/collections/tags/collection.md index 820ea12be..071e676d2 100644 --- a/content/collections/tags/collection.md +++ b/content/collections/tags/collection.md @@ -214,14 +214,8 @@ There are several different ways to use this filtering parameter. They are expla By default, only `published` entries are included. Entries can be queried against `draft`, `scheduled`, or `expired` status with [conditions](#conditions) on `status` like this: ``` -// Include draft entries -{{ collection:blog status:in="published|draft" }} - -// Only include expired entries -{{ collection:blog status:is="expired" }} - -// Exclude published entries -{{ collection:blog status:not_in="published" }} +// Only include published entries +{{ collection:blog status:is="published" }} ``` :::tip From 299fd5fe7810a4d2d545b53ceaaaf58d2503e2be Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 17 May 2024 14:58:55 +0100 Subject: [PATCH 2/4] Draft section in upgrade guide around querying entry statuses --- content/collections/docs/4-to-5.md | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/content/collections/docs/4-to-5.md b/content/collections/docs/4-to-5.md index bf1b51569..91bdece34 100644 --- a/content/collections/docs/4-to-5.md +++ b/content/collections/docs/4-to-5.md @@ -377,6 +377,60 @@ If you use this `{{ glide filename="" }}` parameter, you'll need to remove remov If you are hot-linking to any images rendered with manually set filenames in this way, you'll also need to correct those links. +### Entry statuses can now only be queried using the `is`/`equals` condition +**Affects any apps filtering entries by `status`. Either via the `{{ collection }}` tag, our PHP repositories, the REST API or the GraphQL API.** + +Previously, when querying entries, you could use any condition to filter entries. + +```antlers +{{ collection:blog status:in="published|draft" }} +``` + +```php +Entry::query() + ->where('collection', 'blog') + ->whereIn('status', ['published', 'draft']) + ->get(); +``` + +However, in v5, as part of improvements to how statuses work behind the schenes, statuses can now only be filtered using the `is` / `equals` conditions. + +```antlers +{{ collection:blog status:is="published" }} +``` + +```php +Entry::query() + ->where('collection', 'blog') + ->where('status', 'published') + ->get(); +``` + +``` +/api/collections/blog/entriesfilter[status]=published +``` + +```graphql +{ + entries( + collection: "blog" + filter: { + status: { equals: "published" } + } + ) { + data { + title + status + excerpt + } + } +} +``` + +:::tip Note +If you need to filter by multiple statuses at once, you will need to do multiple queries and merge the results. +::: + ## Zero impact changes These are items that you can completely ignore. They are suggestions on how to improve your code using newly added features. From 254fb50467a1746cc0867d2c8c68b2efc3dd6637 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 17 May 2024 15:01:24 +0100 Subject: [PATCH 3/4] remove examples --- content/collections/docs/4-to-5.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/content/collections/docs/4-to-5.md b/content/collections/docs/4-to-5.md index 91bdece34..bbca52f50 100644 --- a/content/collections/docs/4-to-5.md +++ b/content/collections/docs/4-to-5.md @@ -380,18 +380,7 @@ If you are hot-linking to any images rendered with manually set filenames in thi ### Entry statuses can now only be queried using the `is`/`equals` condition **Affects any apps filtering entries by `status`. Either via the `{{ collection }}` tag, our PHP repositories, the REST API or the GraphQL API.** -Previously, when querying entries, you could use any condition to filter entries. - -```antlers -{{ collection:blog status:in="published|draft" }} -``` - -```php -Entry::query() - ->where('collection', 'blog') - ->whereIn('status', ['published', 'draft']) - ->get(); -``` +Previously, when querying entries, you could use *any* condition to filter entries. However, in v5, as part of improvements to how statuses work behind the schenes, statuses can now only be filtered using the `is` / `equals` conditions. From 78861ecc832d2a03dfff31d8c438497c97f3c84f Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Wed, 22 May 2024 10:06:58 -0400 Subject: [PATCH 4/4] tweaks --- content/collections/docs/4-to-5.md | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/content/collections/docs/4-to-5.md b/content/collections/docs/4-to-5.md index bbca52f50..065791234 100644 --- a/content/collections/docs/4-to-5.md +++ b/content/collections/docs/4-to-5.md @@ -377,48 +377,52 @@ If you use this `{{ glide filename="" }}` parameter, you'll need to remove remov If you are hot-linking to any images rendered with manually set filenames in this way, you'll also need to correct those links. -### Entry statuses can now only be queried using the `is`/`equals` condition -**Affects any apps filtering entries by `status`. Either via the `{{ collection }}` tag, our PHP repositories, the REST API or the GraphQL API.** +### Entries may now only be queried by a single status +**Affects any apps or addons filtering entries by `status`.** Previously, when querying entries, you could use *any* condition to filter entries. -However, in v5, as part of improvements to how statuses work behind the schenes, statuses can now only be filtered using the `is` / `equals` conditions. +However, in v5, as part of improvements to how statuses work behind the schenes, statuses can now only be filtered using the `is` / `equals` conditions, and the `whereStatus` query method. Some examples: +Collection tag: ```antlers -{{ collection:blog status:is="published" }} +{{ collection:blog status:in="published" }} {{# [tl! --] #}} +{{ collection:blog status:is="published" }} {{# [tl! ++] #}} ``` +PHP: ```php Entry::query() ->where('collection', 'blog') - ->where('status', 'published') + ->where('status', 'published') // [tl! --] + ->whereStatus('published') // [tl! ++] ->get(); ``` -``` -/api/collections/blog/entriesfilter[status]=published +REST API: +```php +/api/collections/blog/entries?filter[status:in]=published // [tl! --] +/api/collections/blog/entries?filter[status]=published // [tl! ++] ``` +GraphQL API: ```graphql { entries( collection: "blog" filter: { - status: { equals: "published" } + status: { in: "published" } #[tl! --] + status: "published" #[tl! ++] } ) { data { title - status - excerpt } } } ``` -:::tip Note -If you need to filter by multiple statuses at once, you will need to do multiple queries and merge the results. -::: +Let us know if you need to query by multiple statuses by opening a [GitHub issue](https://github.com/statamic/cms). ## Zero impact changes