Make WordPress Core

Opened 14 months ago

Last modified 12 months ago

#59635 assigned enhancement

Revise the regular expressions defining endpoints for template revisions, template autosaves, template part revisions, and template part autosaves endpoints

Reported by: antonvlasenko's profile antonvlasenko Owned by: antonvlasenko's profile antonvlasenko
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.4
Component: REST API Keywords: has-patch has-unit-tests
Focuses: rest-api Cc:

Description

Currently known issues:

  1. The controllers expect the template_id and template_part_id to always follow the format theme_name//<template(_part)_name>. In practice, it's not possible to retrieve a template or template part using only their template name (i.e., post_name). The get_block_template() function, employed by both REST controllers, presumes that the ID is divided into two parts separated by //. The theme's name must always be included in the request alongside the template (part) name.
  1. The controllers also should not accept URLs that consist of more than two parts; for example, theme_name//<template(_part)_name//some_arbitrary_value shouldn't be allowed. (props @ironprogrammer).
  1. Inline comments in the controller classes need to be fixed to correctly reflect the format of accepted URLs.
  1. Unit tests need to be added to cover the cases mentioned above.

Follow-up from https://core.trac.wordpress.org/ticket/56922 and https://github.com/WordPress/wordpress-develop/pull/3533.

Change History (4)

#1 @antonvlasenko
14 months ago

I'd like to work on a patch for these issues because I'm familiar with the specifics.

#2 @antonvlasenko
14 months ago

I'm thinking to myself, maybe it's fine to have the current regular expressions, as a theme can also be a child theme. Thus, the template ID could have the following structure: <parent_theme>/<child_theme>/template_name. I'm testing different scenarios.

UPD. No, parent_theme isn't needed. It's enough to specify the theme's name.

Last edited 14 months ago by antonvlasenko (previous) (diff)

This ticket was mentioned in PR #5724 on WordPress/wordpress-develop by @antonvlasenko.


12 months ago
#3

  • Keywords has-patch has-unit-tests added; needs-patch removed

This PR aims to refine regular expressions for the autosaves and revisions endpoints of templates and template parts.

Trac ticket: https://core.trac.wordpress.org/ticket/59635

#4 @antonvlasenko
12 months ago

Testing instructions for https://github.com/WordPress/wordpress-develop/pull/5724:

Ensure that the unit tests pass. The functionality is already covered by unit tests, so this PR does not require extensive testing. However, it does need a code review.

Note: See TracTickets for help on using tickets.