Make WordPress Core

Opened 19 months ago

Last modified 18 months ago

#57810 new defect (bug)

Should wp_insert_post() function call 'wp_insert_post' action with 'update' equals true after creating post for the first time.

Reported by: zenithcity's profile zenithcity Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.1.1
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

The wp_insert_post() function calls 'wp_insert_post' action hook with 'update' equals true when creating post for the first time.

Post was created using the Gutenberg editor.

/* $update should only be true when updating post */
do_action( 'wp_insert_post', $post_ID, $post, $update );

Attachments (4)

Screenshot_20230226_014746.2.png (191.2 KB) - added by zenithcity 19 months ago.
Screenshot 2023-03-12 033810.png (190.3 KB) - added by zenithcity 18 months ago.
Screenshot 2023-03-12 034657.png (289.7 KB) - added by zenithcity 18 months ago.
Added var_dump to inspect value of $update in do_action( 'wp_insert_post', $post_ID, $post, $update );
Screenshot 2023-03-12 040407.png (128.3 KB) - added by zenithcity 18 months ago.

Download all attachments as: .zip

Change History (9)

#1 follow-up: @zenithcity
19 months ago

Please anyone who can remove an attachment should help me unlink the first added attachment (Screenshot_20230226_014746.png) from this ticket. I can't see the delete attachment button.

This ticket was mentioned in Slack in #core-test by ironprogrammer. View the logs.


18 months ago

#3 in reply to: ↑ 1 ; follow-up: @ironprogrammer
18 months ago

  • Keywords reporter-feedback added

Thank you for the the report, @zenithcity!

Regarding the question around the $update parameter, the passing of $update in this manner has been around for some time (additional context), and would likely remain for backward compatibility reasons.

Are you able to provide more detail as to the console error/invalid JSON response? Is the wp_insert_post hook being used by custom code?

Please anyone who can remove an attachment should help me unlink the first added attachment (Screenshot_20230226_014746.png) from this ticket. I can't see the delete attachment button.

The first attachment has been removed as requested.

#4 @zenithcity
18 months ago

  • Keywords reporter-feedback removed

Thank you removing the first attachment as requested, @ironprogrammer

So, all plugins are disabled and using the latest WordPress default theme. I added a var_dump('create: $update) directly to where the do_action is fired and created a new post to test, the result is shown on the screenshot.

@zenithcity
18 months ago

Added var_dump to inspect value of $update in do_action( 'wp_insert_post', $post_ID, $post, $update );

#5 in reply to: ↑ 3 @zenithcity
18 months ago

Replying to ironprogrammer:

Thank you for the the report, @zenithcity!

Regarding the question around the $update parameter, the passing of $update in this manner has been around for some time (additional context), and would likely remain for backward compatibility reasons.

Are you able to provide more detail as to the console error/invalid JSON response? Is the wp_insert_post hook being used by custom code?

Please anyone who can remove an attachment should help me unlink the first added attachment (Screenshot_20230226_014746.png) from this ticket. I can't see the delete attachment button.

The first attachment has been removed as requested.

There's no error in console and the JSON response of the publish post action is valid.

Note: See TracTickets for help on using tickets.