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

WordPress Trac noreply at wordpress.org
Fri Sep 15 19:32:03 UTC 2023


#56922: Template / Template parts revision / autosave REST API are broken
--------------------------------------+-----------------------
 Reporter:  spacedmonkey              |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  6.4
Component:  REST API                  |     Version:  4.7
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  rest-api
--------------------------------------+-----------------------

Comment (by antonvlasenko):

 == Test Report ==
 This report confirms that the specified PR addresses the issue.

 PR tested: https://github.com/WordPress/wordpress-develop/pull/5194

 === Environment ===
 - WordPress: 6.4-alpha-56267-src
 - PHP: 7.3.33
 - Server: Apache/2.4.57 (Unix) PHP/7.3.33
 - Database: mysqli (Server: 5.7.43)
 - Browser: Safari 16.6 (macOS)
 - Theme: Twenty Twenty-Three 1.2
 - MU-Plugins: None activated
 - Plugins:
   * JSON Basic Authentication 0.1

 === Steps to Reproduce ===
 1. Navigate to Appearance -> Editor.
 2. Create a new template part (also known as "pattern").
 3. Save the template part multiple times, making slight modifications to
 the template before each save. For instance, add new blocks or alter the
 text.
 4. Identify the ID of your template part in the `wp_posts` table. You can
 use the following SQL query to find the ID of the template part you just
 created:
 {{{
 SELECT
     ID
 FROM
     wp_posts
 WHERE
     post_type = 'wp_template_part'
 ORDER BY post_date DESC
 LIMIT 1;
 }}}
 5. Record the ID value.
 6. Install and activate the https://github.com/WP-API/Basic-Auth plugin to
 simplify the authentication of REST requests.
 7. 🐞 Make a REST request to the template parts endpoint. Replace
 `admin:password` with your admin credentials and `<template_part_id>` with
 the ID value from step 5.
 {{{
 #!bash
 curl http://path.to.your.wordpress.server/wp-json/wp/v2/template-
 parts/<template_part_id>/revisions -u "admin:password"
 }}}
 8. The following response will be received:
 {{{
 #!js
 {"code":"rest_template_not_found","message":"No templates exist with that
 id.","data":{"status":404}}
 }}}

 === Actual Results ===
 When testing the patch to ensure it functions as intended:
 - ✅ A REST request should return a list of the revisions for your
 template part. For example:
 {{{
 #!js
 [{"author":1,"date":"2023-09-12T12:14:30","date_gmt":"2023-09-12T12:14:30","id":10,"modified":"2023-09-12T12:14:30","modified_gmt":"2023-09-12T12:14:30","parent":7,"slug":"7-revision-v1","guid":{"rendered":"http:\/\/wordpress.test\/?p=10","raw":"http:\/\/wordpress.test\/?p=10"},"title":{"raw":"Template
 Part","rendered":"Template Part"},"content":{"raw":"<!-- wp:paragraph
 -->\n<p>A simple p. #3<\/p>\n<!-- \/wp:paragraph -->","rendered":"\n<p>A
 simple p. #3<\/p>\n"},"_links":{"parent":[{"href":"http:\/\/wordpress.test
 \/wp-json\/wp\/v2\/template-
 parts\/7"}]}},{"author":1,"date":"2023-09-12T12:14:21","date_gmt":"2023-09-12T12:14:21","id":9,"modified":"2023-09-12T12:14:21","modified_gmt":"2023-09-12T12:14:21","parent":7,"slug":"7-revision-v1","guid":{"rendered":"http:\/\/wordpress.test\/?p=9","raw":"http:\/\/wordpress.test\/?p=9"},"title":{"raw":"Template
 Part","rendered":"Template Part"},"content":{"raw":"<!-- wp:paragraph
 -->\n<p>A simple p. #2<\/p>\n<!-- \/wp:paragraph -->","rendered":"\n<p>A
 simple p. #2<\/p>\n"},"_links":{"parent":[{"href":"http:\/\/wordpress.test
 \/wp-json\/wp\/v2\/template-
 parts\/7"}]}},{"author":1,"date":"2023-09-12T12:14:08","date_gmt":"2023-09-12T12:14:08","id":8,"modified":"2023-09-12T12:14:08","modified_gmt":"2023-09-12T12:14:08","parent":7,"slug":"7-revision-v1","guid":{"rendered":"http:\/\/wordpress.test\/?p=8","raw":"http:\/\/wordpress.test\/?p=8"},"title":{"raw":"Template
 Part","rendered":"Template Part"},"content":{"raw":"<!-- wp:paragraph
 -->\n<p>A simple p.<\/p>\n<!-- \/wp:paragraph -->","rendered":"\n<p>A
 simple p.<\/p>\n"},"_links":{"parent":[{"href":"http:\/\/wordpress.test
 \/wp-json\/wp\/v2\/template-parts\/7"}]}}]%
 }}}

 In conclusion, the proposed patch successfully addresses the issue. You
 can also test the templates endpoint for further verification.

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


More information about the wp-trac mailing list