[wp-trac] [WordPress Trac] #56922: Template / Template parts revision / autosave REST API are broken

WordPress Trac noreply at wordpress.org
Thu Oct 27 17:58:21 UTC 2022


#56922: Template / Template parts revision / autosave REST API are broken
--------------------------+----------------------------
 Reporter:  spacedmonkey  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Future Release
Component:  REST API      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:  rest-api      |
--------------------------+----------------------------
 The REST API endpoints for autosave and revisions the template and
 template part are broken. The URL structure for template and template part
 are different from other post controllers.

 Standard post controller.
 {{{#!php
 '/' . $this->rest_base . '/(?P<id>[\d]+)',
 }}}


 Template / template parts.
 {{{#!php
 '/%s/(?P<id>%s%s)',
                                 $this->rest_base,
                                 // Matches theme's directory:
 `/themes/<subdirectory>/<theme>/` or `/themes/<theme>/`.
                                 // Excludes invalid directory name
 characters: `/:<>*?"|`.
 '([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)',
                                 // Matches the template name.
                                 '[\/\w-]+'
 }}}

 Revision / autosave endpoints expects

 {{{#!php
 '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base,
 }}}

 Autosave endpoint expects.

 When doing a request like this.

 `wp/v2/template-parts/1480/revisions`

 Results in
 {{{#!php
 code
 :
 "rest_template_not_found"
 data
 :
 {status: 404}
 message
 :
 "No templates exist with that id."
 }}}

 As this post type needs a different url structure, a custom revision /
 autosave will need to be registered.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56922>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list