-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
[Feature] Templates APIRelated to API powering block template functionality in the Site EditorRelated to API powering block template functionality in the Site Editor[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended[Type] RegressionRelated to a regression in the latest releaseRelated to a regression in the latest release
Description
Description
Using saveEntityRecord() to save a template stopped working in a recent update of Gutenberg.
I believe the issue was introduced in #67125 (cc @ellatrix), specifically where the wp_template rest_base is modified:
gutenberg/lib/compat/wordpress-6.9/template-activate.php
Lines 3 to 15 in 99d25fb
| // How does this work? | |
| // 1. For wp_template, we remove the custom templates controller, so it becomes | |
| // a normal posts endpoint, modified slightly to allow auto-drafts. | |
| add_filter( 'register_post_type_args', 'gutenberg_modify_wp_template_post_type_args', 10, 2 ); | |
| function gutenberg_modify_wp_template_post_type_args( $args, $post_type ) { | |
| if ( 'wp_template' === $post_type ) { | |
| $args['rest_base'] = 'wp_template'; | |
| $args['rest_controller_class'] = 'Gutenberg_REST_Templates_Controller'; | |
| $args['autosave_rest_controller_class'] = null; | |
| $args['revisions_rest_controller_class'] = null; | |
| } | |
| return $args; | |
| } |
Step-by-step reproduction instructions
- Switch your theme to TT4.
- Add this code snippet somewhere in your site/plugin:
const { saveEntityRecord } = dispatch( coreStore );
saveEntityRecord(
'postType',
'wp_template',
{
id: 'twentytwentyfour//home',
content: 'test',
},
{
throwOnError: true,
}
);- With Gutenberg disabled, notice a query to
/wp-json/wp/v2/templates/twentytwentyfour//homeis done, and it works. With Gutenberg enabled, the query is done to/wp-json/wp/v2/wp_template/twentytwentyfour//homeand it returns this error:No route was found matching the URL and request method..
Screenshots, screen recording, code snippet
No response
Environment info
- Gutenberg
nightlyortrunk. - WP 6.8.2.
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
kmanijak and straku
Metadata
Metadata
Assignees
Labels
[Feature] Templates APIRelated to API powering block template functionality in the Site EditorRelated to API powering block template functionality in the Site Editor[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended[Type] RegressionRelated to a regression in the latest releaseRelated to a regression in the latest release