Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#54498 closed defect (bug) (fixed)

New FSE REST Endpoints may need to manually call `wp_after_insert_post()`

Reported by: peterwilsoncc's profile peterwilsoncc Owned by: spacedmonkey's profile spacedmonkey
Milestone: 5.9 Priority: normal
Severity: normal Version: 5.9
Component: REST API Keywords: has-patch
Focuses: rest-api Cc:

Description

The following REST API endpoints used for FSE store data in the post table and may need to be altered to manually call wp_after_insert_post() after disabling it as part of the call to wp_insert_post() and related functions.

The purpose of the wp_after_insert_post hook (fired by the function of the same name) is to fire after all data for a post has been updated: the post object, the terms and the meta data.

  • WP_REST_Global_Styles_Controller::update_item() may update meta data after the call to wp_update_post()
  • WP_REST_Menu_Items_Controller both for create and update methods. This may require changes to the signature for wp_update_nav_menu_item()
  • WP_REST_Templates_Controller both for create and update methods.

I've put this on the 5.9 milestone for consideration as it relates to the FSE features.

Change History (13)

This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.


3 years ago

This ticket was mentioned in Slack in #core-restapi by antonvlasenko. View the logs.


3 years ago

#3 @spacedmonkey
3 years ago

  • Focuses rest-api added
  • Keywords needs-patch added
  • Owner set to spacedmonkey
  • Status changed from new to assigned
  • Version set to trunk

This ticket was mentioned in Slack in #core-restapi by zieladam. View the logs.


3 years ago

This ticket was mentioned in PR #1951 on WordPress/wordpress-develop by spacedmonkey.


3 years ago
#5

  • Keywords has-patch added; needs-patch removed

#8 @spacedmonkey
3 years ago

@peterwilsoncc @TimothyBlynJacobs I have created PRs for all the endpoints. I created PRs for all the different endpoints for easier review.

Once, I get a positive review from any of the PRs, I will commit the changes, as this change is simple and harmless.

I created a related issue #54520 on a very similar matter. I would also like to get eyes on this as well.

This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.


3 years ago

#10 @peterwilsoncc
3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

This was committed in [52276] but with the wrong ticket annotation:

REST API: Fire wp_after_insert_post later in new post object endpoints.

In the new menu items, global items and template controllers manually call the function wp_after_insert_post() to manually fire the action of the same name after all potential data is updated.

This accounts for the use case in which a theme or plugin developer has modified the endpoints use of either taxonomy or meta data.

The new parameter $fire_after_hooks is added to wp_update_nav_menu_item() to control whether the wp_after_insert_post action is fired when it in turn calls wp_insert_post().

Props spacedmonkey, peterwilsoncc, zieladam.

Note: See TracTickets for help on using tickets.