Ok, I found the culprit, but not the true reason (thatās beyond my technical understanding of Kirbyās inner workings):
After meticulously debugging my project, it turned out that calling site()->index(true)
from within a page.update:after
hook would not contain drafts for one particular page type only. I then went through the entire blueprint (by removing small portions, one at a time) and eventually learned that this field caused the odd behaviour:
tags:
type: tags
label: Tags
options: query
query: site.index.pluck("tags", ",", true)
When the page.update:after
hook is triggered after updating a page where above field is present in the blueprint, site()->index(true)
would only contain listed pages. Triggering the same hook from any page whose blueprint does not include that field, drafts are included in the collection returned. As soon as I remove this field, site()->index(true)
returns the complete index of the site, including drafts, also for the blueprint in question.
I was able to narrow it down even further: the problem seems to stem from the query: site.index.pluck("tags", ",", true)
ā as soon as I replace that with any query that does not involve index
(e.g. query: site.children.pluck("tags", ",", true)
, which is of course nonsensical, but just for proof-of-concept), the index call from within that hook works as expected.
Did I just encounter a very odd bug here, @byybora ? To summarize: it appears that the collection returned by site()->index(true)
does not include drafts as specified if called by a page.update:after
hook for a page whose blueprint includes an option query that makes use of index
.