Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#56501 closed defect (bug) (invalid)

wp_after_insert_post hook, $post_before and $post showing same values

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

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
4 years ago

  • Description modified (diff)
  • Version 6.0.2 → 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 4 years ago by SergeyBiryukov (previous) (diff)

#2 @wpfed
4 years ago

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

#3 @wpfed
4 years ago

  • Resolution → invalid
  • Status new → 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
4 years ago

  • Milestone Awaiting Review

No worries, thanks for the follow-up!

Note: See TracTickets for help on using tickets.