getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.31k stars 168 forks source link

Section parent throws error if the parent query returns a draft #1894

Closed texnixe closed 5 years ago

texnixe commented 5 years ago

Describe the bug Probably related to #1893, but the Panel throws an error when setting the parent of a pages section to site.find('somepage') and somepage is a draft. Doesn't happen with a published page in my setup.

Example:

type: pages
headline: Photography
parent: site.find("photography")
size: tiny
info: "{{ page.images.count }} image(s)"
layout: cards
template: album
empty: No albums yet
image:
  query: page.cover
  cover: true
  ratio: 5/4

To Reproduce Steps to reproduce the behavior:

  1. In a fresh Starterkit, go to the photography or notes page and change the status to draft
  2. See error

The section "drafts" could not be loaded: The parent for the query "site.find("notes")" cannot be found in the section "drafts"

This does not happen if the parent query is changed to site.childrenAndDrafts.find("photography"). I haven't tested if this issue existed before 3.2, maybe it's not a bug but expected behaviour after all (but then we should probably be more careful in the docs or in the setup of the Starterkit).

What is worse, the status of the page cannot be changed back to published after this happens.

Expected behavior The subpages should still be displayed and no error be thrown as a draft should be allowed to have subpages.

Kirby Version 3.2.0

Console output If you are working with the panel, please check the browser console for errors and send the output.

"The parent for the query \"site.find(\"notes\")\" cannot be found in the section \"listed\""

Bildschirmfoto 2019-07-01 um 16 09 57
bastianallgeier commented 5 years ago

This is a logical issue and not really a "bug". site.find does not find drafts. In versions prior to 3.2 no error was thrown, but this would still have led to an empty section. In 3.2. the error is new, but it just shows the same problem more clearly. I have no direct solution for this yet, than to replace site.find with kirby.page or site.findPageOrDraft

texnixe commented 5 years ago

I'm aware of that just wondering if we should adapt the Starterkit/documentation accordingly.

Let's close this here and I open a new one in the Starterkit.