Make WordPress Core

Opened 12 months ago

Closed 11 months ago

Last modified 11 months ago

#58540 closed enhancement (fixed)

Templates API: return post modified datetime in response

Reported by: ramonopoly's profile ramonopoly Owned by: isabel_brison's profile isabel_brison
Milestone: 6.3 Priority: normal
Severity: normal Version: 6.3
Component: REST API Keywords: has-patch has-unit-tests gutenberg-merge add-to-field-guide
Focuses: Cc:

Description (last modified by milana_cap)

In order to display the latest modified date in the site editor for template and template parts we need to add modified to the template and template part objects in the rest response for WP_REST_Templates_Controller

See https://github.com/WordPress/gutenberg/issues/49597 for reference to the designs and context.

For theme templates, it will add the modified value when we have a post id (which is once the template is first save after user change)

The modified property will be returned when a template is created, updated and fetched.

Gutenberg PR that introduced this change to the plugin:

https://github.com/WordPress/gutenberg/pull/51362

Change History (12)

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


12 months ago
#1

  • Keywords has-patch has-unit-tests added

WIP

Adding 'modified' field and value (if available) to template rest APIcontroller

Synching Core with:

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

#2 @ramonopoly
12 months ago

  • Keywords gutenberg-merge added
  • Type changed from defect (bug) to enhancement
  • Version set to trunk

#3 @isabel_brison
12 months ago

  • Milestone changed from Awaiting Review to 6.3

#4 @isabel_brison
11 months ago

  • Owner set to isabel_brison
  • Resolution set to fixed
  • Status changed from new to closed

In 55992:

REST API: return post modified datetime for Templates.

Adds a modified field to the template and template part objects in the rest response for WP_REST_Templates_Controller.

Props ramonopoly, andrewserong, mukesh27, timothyblynjacobs.
Fixes #58540.

@isabel_brison commented on PR #4613:


11 months ago
#5

Committed in r55992 / 09a7c68.

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


11 months ago
#6

In https://github.com/WordPress/wordpress-develop/pull/4613 tests were added to cover changes to _build_block_template_result_from_post that reflect the new modified property.

The wrong object was used in the template part assertion.

This commit corrects that and fixes the failing tests.

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

@ramonopoly commented on PR #4613:


11 months ago
#7

Sorry @tellthemachines and @TimothyBJacobs

I just realized I added a breaking change to PHP unit tests on this line

It'll cause the tests to fail sometimes (when they don't run fast enough 😄 )

Fix here:

#8 @oandregal
11 months ago

In 55993:

Fix block template utils test: use template part instead of template object.

Note that the PHP unit tests didn't fail in the CI job because the date for both the template and template part was the same.

Props ramonopoly.
Fixes #58540.

#10 follow-up: @milana_cap
11 months ago

  • Description modified (diff)
  • Keywords add-to-field-guide added

#11 in reply to: ↑ 10 @milana_cap
11 months ago

Description modified (diff)

@ramonopoly I didn't mean to change your description. I think it's my settings to ignore emojis which automatically removed it when I just wanted to add a keyword. I'm sorry this happened (this is the first time it happened to me).

Last edited 11 months ago by milana_cap (previous) (diff)

#12 @ramonopoly
11 months ago

@ramonopoly I didn't mean to change your description. I think it's my settings to ignore emojis which automatically removed it when I just wanted to add a keyword. I'm sorry this happened (this is the first time it happened to me).

No worries at all! :)

Note: See TracTickets for help on using tickets.