Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include drafts in finding pages key recursively #6354

Draft
wants to merge 1 commit into
base: develop-minor
Choose a base branch
from

Conversation

distantnative
Copy link
Member

This PR …

Let's think hard if this could cause any regressions or is a breaking change (not just fixing a bug).

Fixes

Ready?

  • In-code documentation (wherever needed)
  • Unit tests for fixed bug/feature
  • Tests and checks all pass

For review team

  • Add lab and/or sandbox examples (wherever helpful)
  • Add changes & docs to release notes draft in Notion

@distantnative distantnative added the type: bug 🐛 Is a bug; fixes a bug label Mar 23, 2024
@distantnative distantnative added this to the 4.2.0 milestone Mar 23, 2024
@distantnative distantnative requested a review from a team March 23, 2024 14:05
@distantnative distantnative self-assigned this Mar 23, 2024
@distantnative distantnative linked an issue Mar 23, 2024 that may be closed by this pull request
Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... There would suddenly no longer be a difference between HasChildren::find() and HasChildren::findPageOrDraft() anymore, right? I feel like there could be use cases where one would want to explicitly only find published pages. So this would be a breaking change and also one that wouldn't be intended I think.

Maybe we need to introduce a separate recursive finding mode that uses childrenAndDrafts(). That could then be specifically used by HasChildren::findPageOrDraft(), also allowing us to get rid of the separate search in both collections.

One way could be to have a new marker prop for Pages that keeps track of whether the collection is children, drafts or childrenAndDrafts. The same collection type would then be used in the findByKeyRecursive() method.

@distantnative distantnative added the needs: help 🙏 Really needs some help on this label Mar 24, 2024
@bastianallgeier bastianallgeier modified the milestones: 4.2.0, 4.2.x Mar 27, 2024
@distantnative distantnative marked this pull request as draft May 2, 2024 10:11
@distantnative distantnative removed this from the 4.2.x milestone May 11, 2024
@distantnative distantnative force-pushed the fix/6339-find-pages-drafts-recursive branch from 94ea2a4 to 8960b69 Compare July 24, 2024 09:28
@distantnative
Copy link
Member Author

distantnative commented Jul 24, 2024

@lukasbestle Revisiting this, I am wondering if we need to just adapt HasChildren::find() to filter the result of drafts.

Because in general, I think this PR would be the more correct behavior: Drafts and pages can only have unique IDs. So when trying to access a page with a key-path, it's currently weird that we completely ignore a page (draft) that actually matches the specified path. And this is just because of its page status. This creates a greater separation between pages and drafts than there should be. Drafts shouldn't be automatically included when returning collections, e.g. to avoid putting them in templates while they're still drafts. But when we explicitly look them up with a key, it's weird that we ignore them so much and say "oh, well, you didn't explicitly ask for drafts" (as if drafts aren't pages, too). 😅

I'm totally happy to move this to v5 as breaking change. But I think it would be good to change this.

@distantnative distantnative added needs: decision 🗳 Requires a decision to proceed and removed needs: help 🙏 Really needs some help on this labels Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: decision 🗳 Requires a decision to proceed type: bug 🐛 Is a bug; fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

$site->findPageOrDraft() does not work for nested drafts
3 participants