mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
REST API: Prevent duplicate firing of rest(_after)?_insert_attachment
actions.
Merges [43862] from the 5.0 branch to trunk. Props danielbachhuber, peterwilsoncc. Fixes #45269. See #42864. Built from https://develop.svn.wordpress.org/trunk@44225 git-svn-id: http://core.svn.wordpress.org/trunk@44055 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7ffb7340f5
commit
58fdce722c
@ -237,9 +237,6 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
|
||||
$attachment = get_post( $request['id'] );
|
||||
|
||||
/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php */
|
||||
do_action( 'rest_insert_attachment', $data, $request, false );
|
||||
|
||||
$fields_update = $this->update_additional_fields_for_object( $attachment, $request );
|
||||
|
||||
if ( is_wp_error( $fields_update ) ) {
|
||||
|
@ -747,6 +747,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
||||
// Filter is fired in WP_REST_Attachments_Controller subclass.
|
||||
if ( 'attachment' === $this->post_type ) {
|
||||
$response = $this->prepare_item_for_response( $post, $request );
|
||||
return rest_ensure_response( $response );
|
||||
}
|
||||
|
||||
/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */
|
||||
do_action( "rest_after_insert_{$this->post_type}", $post, $request, false );
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.1-alpha-44224';
|
||||
$wp_version = '5.1-alpha-44225';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user