Open wanze opened 2 years ago
Hi @wanze, thanks for bringing this to my attention! To be honest, I don't really actively maintain this addon anymore since the release of Statamic 3. I'm happy to merge a PR with this change as at first glance this seems fine to me. Thanks!
Description
Fetch returns unpublished content when using
filter=published
in combination with non-defaultlocale
. For example, a call to!/Fetch/collection/project?&limit=6&offset=0&locale=fr&filter=published
will return unpublished entries of theproject
collection for French.Problem
Fetch::filterData()
does not respect localized data. Thus, filtering by published status is always performed on entries of the default locale.Possible solution
For a quick fix, I extended
Fetch::filterData()
to localize the data before passing it toFetch::filterPublished()
orFetch::filterUnpublished()
.Not sure if this fixes it for other data, but it seems to work for collections.
Cheers