Opened 4 years ago
Last modified 3 years ago
#10545 new defect (bug)
_publish_post_hook (adding to postmeta existing hooks)
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Optimization | Version: | 2.8.1 |
| Severity: | normal | Keywords: | has-patch, publish_post_hook, pings, postmeta |
| 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 (6)
comment:1
markjaquith — 3 years ago
- Milestone changed from 2.9 to 3.0
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.
I'm not really sure why it was removing the postmeta... something was somewhere.
Lew
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: