#10545 closed defect (bug) (worksforme)
_publish_post_hook (adding to postmeta existing hooks)
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.8.1 |
Component: | General | Keywords: | has-patch publish_post_hook pings postmeta |
Focuses: | Cc: |
Description
The problem that each time yuo press publish (assuming this is a save button) wp add to postmeta table new records even thay already exist now.
if ( get_option('default_pingback_flag') ) $wpdb->insert( $wpdb->postmeta, $data + array( 'meta_key' => '_pingme' ) ); $wpdb->insert( $wpdb->postmeta, $data + array( 'meta_key' => '_encloseme' ) );
shoud be (something like)
if ( get_option('default_pingback_flag') ){ get_post_meta($post_id, '_pingme') ? update_post_meta($post_id, '_pingme', 1) : add_post_meta($post_id, '_pingme', 1); get_post_meta($post_id, '_encloseme') ? update_post_meta($post_id, '_encloseme', 1) : add_post_meta($post_id, '_encloseme', 1);
Attachments (1)
Change History (8)
#3
@
13 years ago
We shouldn't be removing postmeta on a status change.
Regarding the patch, no need to check get_post_meta before choosing between update_post_meta and add_post_meta. update will add if the key/value doesn't exist.
I imagine there's a reason for a direct query there.
#4
@
13 years ago
I'm not really sure why it was removing the postmeta... something was somewhere.
Lew
#6
@
9 years ago
- Component changed from Optimization to General
- Keywords changed from has-patch, publish_post_hook, pings, postmeta to has-patch publish_post_hook pings postmeta
- Milestone Future Release deleted
- Resolution set to worksforme
- Status changed from new to closed
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
5 years ago
Note: See
TracTickets for help on using
tickets.
Verified issue... published post, set post to draft, republished post... kept adding postmeta to DB.
created patch with suggested fix from butuzov and tested.
Now it acts like this: