-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Core data revisions: extend support to other post types #56353
Changes from all commits
9a15a4f
2cfd3fb
0f11173
c12f97b
20bf780
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,16 @@ export const DEFAULT_ENTITY_KEY = 'id'; | |
const POST_RAW_ATTRIBUTES = [ 'title', 'excerpt', 'content' ]; | ||
|
||
// A hardcoded list of post types that support revisions. | ||
// Reflects post types in Core's src/wp-includes/post.php. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for highlighting where these are set in core! |
||
// @TODO: Ideally this should be fetched from the `/types` REST API's view context. | ||
const POST_TYPES_WITH_REVISIONS_SUPPORT = [ 'post', 'page' ]; | ||
const POST_TYPE_ENTITIES_WITH_REVISIONS_SUPPORT = [ | ||
'post', | ||
'page', | ||
'wp_block', | ||
'wp_navigation', | ||
'wp_template', | ||
'wp_template_part', | ||
]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current thinking is to extend the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just double-checking what you mean here (sorry if I'm missing context — so to speak!): that we have a hard-coded list of types here because calling That makes sense to me, and from looking up |
||
|
||
export const rootEntitiesConfig = [ | ||
{ | ||
|
@@ -308,7 +316,7 @@ async function loadPostTypeEntities() { | |
}, | ||
mergedEdits: { meta: true }, | ||
supports: { | ||
revisions: POST_TYPES_WITH_REVISIONS_SUPPORT.includes( | ||
revisions: POST_TYPE_ENTITIES_WITH_REVISIONS_SUPPORT.includes( | ||
postType?.slug | ||
), | ||
}, | ||
|
@@ -351,6 +359,7 @@ async function loadPostTypeEntities() { | |
}/${ parentId }/revisions${ | ||
revisionId ? '/' + revisionId : '' | ||
}`, | ||
revisionKey: isTemplate ? 'wp_id' : DEFAULT_ENTITY_KEY, | ||
ramonjd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
} ); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me this should continue to use the default entity key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean
DEFAULT_ENTITY_KEY
?The value is
id
, which doesn't work for template/template parts. To get the unique record id we have to refer to thewp_id
property.