Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/editor/src/components/page-attributes/parent.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const applyWithSelect = withSelect( ( select ) => {
parent_exclude: postId,
orderby: 'menu_order',
order: 'asc',
_fields: 'id,parent,title',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should not use getEntityRecords with something that change the result format like _fields / context because otherwise it will potentially break other parts of the UI relying on the same entities. Entities should have a consistent format in the store.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was thinking that I was missing something, and this was it. In this case, should we not use getEntityRecords, or would it be possible to create an "entity" specific for this? Thank you for the review!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe it's fine to have a specific apiFetch call here? cc @aduth

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've been thinking about this for another use-case, to try to limit the fields to omit post.content.rendered for the edited post, as a performance optimization.

The tricky part is the same as what you're experiencing here, in that the data can't be reused.

But I was under the impression it wouldn't necessarily break other usage, it would just treat it as a distinct query, where a separate request would would be made, and no reuse between known fields.

Ideally, I would like to explore some solution which tries to make the most reuse out of the known fields of a request, and only requests the sum difference from what's known. (See #15114)

In the meantime, I think this change is only worthwhile if we aren't using other fields elsewhere for the parent post. If we aren't, I would first check to confirm two _fields requests can coexist, albeit fetched separately. If we are, then it may not be a worthwhile optimization, or we should artificially align the _fields for what's needed across the two, so we can still take advantage of fields while only issuing one request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But I was under the impression it wouldn't necessarily break other usage, it would just treat it as a distinct query

Not if you use getEntityRecord to get a single entity, it will trigger the fetch request but will also return the existing cached value I think.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, well, that should definitely be fixed. Whether we decide to do that in parallel with introducing a specific apiRequest interim solution here or as a blocker (depending on the urgency of this issue), I don't have a strong preference.

};

return {
Expand Down