Opened 7 years ago
Closed 3 months ago
#45801 closed defect (bug) (worksforme)
Duplicate post publish action
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 5.0.2 |
| Component: | Posts, Post Types | Keywords: | |
| Focuses: | Cc: |
Description
I'll try to keep this short. Action "publish_to_publish" is being called twice when updating a published post under some circumstances. Web server registers two calls (one to index.php, one to /wp-admin/post.php). First call appears to update the content and non-meta data. Second call updates data from meta blocks.
Specifics: Any theme or plugin that adds meta data to a post forces a second call to the update process with the meta block data.
Problem: Any plugin that performs actions based on "publish_to_publish" is being called twice. In my specific instance the Better Notifications for WordPress plugin sends notifications mails doubled.
Wordpress version: 5.0.2
Theme: Customify, no plugins
Or
Theme: TwentyNineteen, and Plugin: Profile Builder
Basically anything that adds meta-data to a post object causes a second, duplicate, action.
If meta-data updates should trigger a second action, how can a plugin detect that there has been an additional call?
Reproduction Report
Description
❌ This can't validates that the issue can be reproduced.
Environment
Reproduciton instructions
publish_to_publishActual Results
Additional Notes
Supplemental Artifacts
add_action( 'post_updated', 'bb_testing_add_update_meta', 10, 1 ); function bb_testing_add_update_meta( $post_ID ) { if ( wp_is_post_autosave( $post_ID ) || wp_is_post_revision( $post_ID ) ) { return; } $timestamp = current_time( 'mysql' ); add_post_meta( $post_ID, '_bb_testing_last_' . $timestamp, $timestamp ); }