You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have collections that were working fine in Statamic 4 through the REST API (and the Eloquent driver for entries).
After upgrading to Statamic 5, almost everything seems to work, except that the Rest API is returning empty pagination results.
If you request a certain entry id it works fine, but if you use the /entries endpoint it returns nothing.
Diving into the statamic code, I see the date query part in vendor/statamic/cms/src/Stache/Query/QueriesEntryStatus.php in the method addCollectionStatusLogicToQuery.
It looks at different date-behaviour settings because the default 'published = true' filter is added.
But on that collection, all the date settings are disabled:
How to reproduce
I don't know if the eloquent driver is important here, but I think it is.
So, use the eloquent driver to store entries in a database.
Create a collection with date: false (or the date property absent). In other words, the option in the CP 'Enable publish dates' is disabled. Create some entries in it. The date column in the database is now NULL for these entries. But mark them as published! The published column in the database should be a 1.
Use the /api/collections/<collectionname>/entries endpoint from the REST API, and you get a response with empty data property. No entries are returned.
What seems to happen is this is in our collection YAML:
date_behavior:
past: publicfuture: private
but without any date property.
What happened is at some time we had the date behaviour toggle enabled, and made some settings.
After that, we disabled the hole date behaviour section by just disabling the toggle in the CP.
But the REST API query code ignores the date property in the YAML, and just looks at date_behavior.
I find it hard to explain here :).
Basically, there is a big toggle to enable or disable the whole 'date behaviour' section in the CP while editing a collection. This toggles the date property true / false. And then the 'date behaviour' section appears, and you can make settings. These settings are stored in the date_behavior property. What happens if you turn the whole 'date behaviour' section off again, is that only the date property is toggled off.
Previous, in Statamic 4, that was enough. But the query code in Statamic 5 ignores the date property, and looks at the left overs in the date_behavior property anyway.
14 hours ago! 😂 .
I was fighting with this yesterday, couldn't find another issue. So first thing this morning I created an issue for it.. Someone beat me to it :).
Bug description
We have collections that were working fine in Statamic 4 through the REST API (and the Eloquent driver for entries).
After upgrading to Statamic 5, almost everything seems to work, except that the Rest API is returning empty pagination results.
If you request a certain entry id it works fine, but if you use the
/entries
endpoint it returns nothing.Diving into the statamic code, I see the date query part in
vendor/statamic/cms/src/Stache/Query/QueriesEntryStatus.php
in the methodaddCollectionStatusLogicToQuery
.It looks at different date-behaviour settings because the default 'published = true' filter is added.
But on that collection, all the date settings are disabled:
How to reproduce
I don't know if the eloquent driver is important here, but I think it is.
So, use the eloquent driver to store entries in a database.
Create a collection with
date: false
(or the date property absent). In other words, the option in the CP 'Enable publish dates' is disabled. Create some entries in it. Thedate
column in the database is nowNULL
for these entries. But mark them aspublished
! Thepublished
column in the database should be a 1.Use the
/api/collections/<collectionname>/entries
endpoint from the REST API, and you get a response with emptydata
property. No entries are returned.What seems to happen is this is in our collection YAML:
but without any
date
property.What happened is at some time we had the date behaviour toggle enabled, and made some settings.
After that, we disabled the hole date behaviour section by just disabling the toggle in the CP.
But the REST API query code ignores the
date
property in the YAML, and just looks atdate_behavior
.I find it hard to explain here :).
Basically, there is a big toggle to enable or disable the whole 'date behaviour' section in the CP while editing a collection. This toggles the
date
property true / false. And then the 'date behaviour' section appears, and you can make settings. These settings are stored in thedate_behavior
property. What happens if you turn the whole 'date behaviour' section off again, is that only thedate
property is toggled off.Previous, in Statamic 4, that was enough. But the query code in Statamic 5 ignores the
date
property, and looks at the left overs in thedate_behavior
property anyway.Logs
No response
Environment
Installation
Other (please explain)
Additional details
No clue how this project is installed, it was at Laravel 10 / Statamic 4 when I joined on it.
The text was updated successfully, but these errors were encountered: