Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#56501 closed defect (bug) (invalid)

wp_after_insert_post hook, $post_before and $post showing same values

Reported by: wpfed's profile wpfed Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.6
Component: REST API Keywords:
Focuses: rest-api Cc:

Description (last modified by SergeyBiryukov)

wp_after_insert_post hook, $post_before and $post showing same values.

WordPress 6.0.2
Gutenberg 14.0.2
PHP 7.4.28
Windows 10
Chrome

According to this: [49732]

It should "Pass the previous state of the post as a parameter to the wp_after_insert_post hook"

Change History (4)

#1 @SergeyBiryukov
3 years ago

  • Description modified (diff)
  • Version changed from 6.0.2 to 5.6

Hi there, thanks for the ticket!

Appears to be introduced in [49731] / #45114 for WordPress 5.6, setting the version accordingly.

Last edited 3 years ago by SergeyBiryukov (previous) (diff)

#2 @wpfed
3 years ago

Thank you @SergeyBiryukov, I also am linking related issue here https://github.com/WordPress/gutenberg/issues/15777

#3 @wpfed
3 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Sorry, it does work! I was just hitting it at wrong time. I was testing it using dump(tracy debugger):

bdump($post->post_title);
bdump($post_before->post_title);

That's when the values were all the same but when I did a check like so it returned different values!

if($post->post_title !== $post_before->post_title){
 bdump($post->post_title);
 bdump($post_before->post_title);
}
else {
 bdump('same title');
}

Looks like this can be closed.

#4 @SergeyBiryukov
3 years ago

  • Milestone Awaiting Review deleted

No worries, thanks for the follow-up!

Note: See TracTickets for help on using tickets.