From a01835679a4b50c7a98b6bbf4cf34943acd2de7d Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 26 May 2020 14:49:06 +0000 Subject: [PATCH] Posts, Post Types: Pass the post object to the `delete_attachment` action. Also add the missing `$post` parameter to the `delete_post` and `deleted_post` actions in `wp_delete_attachment()`. See #30940. Built from https://develop.svn.wordpress.org/trunk@47856 git-svn-id: http://core.svn.wordpress.org/trunk@47632 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 10 ++++++---- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index b5eff61a06..20feed2c40 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -5717,10 +5717,12 @@ function wp_delete_attachment( $post_id, $force_delete = false ) { * Fires before an attachment is deleted, at the start of wp_delete_attachment(). * * @since 2.0.0 + * @since 5.5.0 Added the `$post` parameter. * - * @param int $post_id Attachment ID. + * @param int $post_id Attachment ID. + * @param WP_Post $post Post object. */ - do_action( 'delete_attachment', $post_id ); + do_action( 'delete_attachment', $post_id, $post ); wp_delete_object_term_relationships( $post_id, array( 'category', 'post_tag' ) ); wp_delete_object_term_relationships( $post_id, get_object_taxonomies( $post->post_type ) ); @@ -5743,13 +5745,13 @@ function wp_delete_attachment( $post_id, $force_delete = false ) { } /** This action is documented in wp-includes/post.php */ - do_action( 'delete_post', $post_id ); + do_action( 'delete_post', $post_id, $post ); $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); if ( ! $result ) { return false; } /** This action is documented in wp-includes/post.php */ - do_action( 'deleted_post', $post_id ); + do_action( 'deleted_post', $post_id, $post ); wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file ); diff --git a/wp-includes/version.php b/wp-includes/version.php index e027827a8a..0d0a7283ca 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-47855'; +$wp_version = '5.5-alpha-47856'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.