WordPress.org

Make WordPress Core

Changeset 18855


Ignore:
Timestamp:
10/01/11 08:38:33 (3 years ago)
Author:
duck_
Message:

Use metadata API in do_all_pings() to delete post meta (cleaner, plays better with cache). Remove redundant query to retrieve meta_id. See #18196.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r18836 r18855  
    16651665 
    16661666    // Do pingbacks 
    1667     while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { 
    1668         $mid = $wpdb->get_var( "SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme' LIMIT 1"); 
    1669         do_action( 'delete_postmeta', $mid ); 
    1670         $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->postmeta} WHERE meta_id = %d", $mid ) ); 
    1671         do_action( 'deleted_postmeta', $mid ); 
    1672         pingback($ping->post_content, $ping->ID); 
     1667    while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { 
     1668        delete_metadata_by_mid( 'post', $ping->meta_id ); 
     1669        pingback( $ping->post_content, $ping->ID ); 
    16731670    } 
    16741671 
    16751672    // Do Enclosures 
    1676     while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { 
    1677         $mid = $wpdb->get_var( $wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_encloseme'", $enclosure->ID) ); 
    1678         do_action( 'delete_postmeta', $mid ); 
    1679         $wpdb->query( $wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE meta_id =  %d", $mid) ); 
    1680         do_action( 'deleted_postmeta', $mid ); 
    1681         do_enclose($enclosure->post_content, $enclosure->ID); 
     1673    while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { 
     1674        delete_metadata_by_mid( 'post', $enclosure->meta_id ); 
     1675        do_enclose( $enclosure->post_content, $enclosure->ID ); 
    16821676    } 
    16831677 
Note: See TracChangeset for help on using the changeset viewer.