Make WordPress Core


Ignore:
Timestamp:
09/19/2019 01:48:54 AM (5 years ago)
Author:
boonebgorges
Message:

Improve do_enclose() logic on post publish.

Removing the direct SQL query in do_all_pings() improves filterability.

As part of this change, the signature of do_enclose() is changed so that
a null $content parameter can be passed, with the $content then inferred
from the $post passed in the second parameter. In addition, the second
parameter was modified so that a post ID or a WP_Post object can be
provided. These changes make it possible to trigger enclosure checks with
a post ID alone (as in do_all_pings()) and also brings the function
signature in line with do_trackbacks() and pingback().

Props dshanske, spacedmonkey, janw.oostendorp, mrmadhat, birgire.
See #36824.

File:
1 edited

Legend:

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

    r45932 r46175  
    26402640    }
    26412641
    2642     // Do Enclosures
    2643     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" ) ) {
    2644         delete_metadata_by_mid( 'post', $enclosure->meta_id );
    2645         do_enclose( $enclosure->post_content, $enclosure->ID );
     2642    // Do enclosures.
     2643    $enclosures = get_posts(
     2644        array(
     2645            'post_type'        => get_post_types(),
     2646            'suppress_filters' => false,
     2647            'nopaging'         => true,
     2648            'meta_key'         => '_encloseme',
     2649            'fields'           => 'ids',
     2650        )
     2651    );
     2652
     2653    foreach ( $enclosure as $enclosure ) {
     2654        delete_post_meta( $enclosure, '_encloseme' );
     2655        do_enclose( null, $enclosure->ID );
    26462656    }
    26472657
Note: See TracChangeset for help on using the changeset viewer.