Make WordPress Core

Ticket #36824: 36824.5.2.diff

File 36824.5.2.diff, 5.0 KB (added by dshanske, 7 years ago)
  • src/wp-includes/comment.php

    diff --git src/wp-includes/comment.php src/wp-includes/comment.php
    index 7055db7..81ab0c6 100644
    function discover_pingback_server_uri( $url, $deprecated = '' ) { 
    24462446function do_all_pings() {
    24472447        global $wpdb;
    24482448
     2449        $ping_types = get_post_types_by_support( 'trackbacks' );
     2450
    24492451        // Do pingbacks
    2450         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")) {
    2451                 delete_metadata_by_mid( 'post', $ping->meta_id );
    2452                 pingback( $ping->post_content, $ping->ID );
     2452        $pings = get_posts(
     2453                array(
     2454                        'post_type' => $ping_types,
     2455                        'suppress_filters' => false,
     2456                        'nopaging' => true,
     2457                        'meta_value' => '_pingme',
     2458                        'fields' => 'ids'
     2459                )
     2460        );
     2461        foreach ( $pings as $ping ) {
     2462                delete_post_meta( $ping, '_pingme' );
     2463                pingback( null, $ping );
    24532464        }
    24542465
    24552466        // Do Enclosures
    2456         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")) {
    2457                 delete_metadata_by_mid( 'post', $enclosure->meta_id );
    2458                 do_enclose( $enclosure->post_content, $enclosure->ID );
     2467        $enclosures = get_posts(
     2468                array(
     2469                        'post_type' => get_post_types( array( 'publicly_queryable' => true ) ),
     2470                        'suppress_filters' => false,
     2471                        'nopaging' => true,
     2472                        'meta_value' => '_encloseme',
     2473                        'fields' => 'ids'
     2474                )
     2475        );
     2476        foreach ( $enclosures as $enclosure ) {
     2477                delete_post_meta( $enclosure, '_encloseme' );
     2478                do_enclose( null, $enclosure );
    24592479        }
    24602480
    24612481        // Do Trackbacks
    2462         $trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'");
    2463         if ( is_array($trackbacks) )
    2464                 foreach ( $trackbacks as $trackback )
    2465                         do_trackbacks($trackback);
     2482        $trackbacks = get_posts(
     2483                array(
     2484                        'post_type' => $ping_types,
     2485                        'suppress_filters' => false,
     2486                        'nopaging' => true,
     2487                        'to_ping' => true,
     2488                        'fields' => 'ids'
     2489                )
     2490        );
     2491        foreach ( $trackbacks as $trackback ) {
     2492                do_trackbacks( $trackback );
     2493        }
    24662494
    24672495        //Do Update Services/Generic Pings
    24682496        generic_ping();
    function wp_handle_comment_submission( $comment_data ) { 
    30133041                 * @param int $comment_post_ID Post ID.
    30143042                 */
    30153043                do_action( 'comment_on_draft', $comment_post_ID );
    3016                
     3044
    30173045                if ( current_user_can( 'read_post', $comment_post_ID ) ) {
    30183046                        return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 );
    30193047                } else {
  • src/wp-includes/functions.php

    diff --git src/wp-includes/functions.php src/wp-includes/functions.php
    index 03c6126..b584e3d 100644
    function wp_extract_urls( $content ) { 
    550550 * pingbacks and trackbacks.
    551551 *
    552552 * @since 1.5.0
     553 * @since 4.9.0 $post_id can be a WP_Post object.
    553554 *
    554555 * @global wpdb $wpdb WordPress database abstraction object.
    555556 *
    556  * @param string $content Post Content.
    557  * @param int    $post_ID Post ID.
     557 * @param string $content Post Content. If empty will retrieve from post.
     558 * @param int|WP_Post    $post_id Post object or ID.
    558559 */
    559 function do_enclose( $content, $post_ID ) {
     560function do_enclose( $content, $post_id ) {
    560561        global $wpdb;
     562        $post = get_post( $post_id );
     563        if ( ! $post ) {
     564                return false;
     565        }
    561566
     567        if ( empty( $content ) ) {
     568                $content = $post->post_content;
     569        }
     570         
    562571        //TODO: Tidy this ghetto code up and make the debug code optional
    563572        include_once( ABSPATH . WPINC . '/class-IXR.php' );
    564573
    565574        $post_links = array();
    566575
    567         $pung = get_enclosed( $post_ID );
     576        $pung = get_enclosed( $post->ID );
    568577
    569578        $post_links_temp = wp_extract_urls( $content );
    570579
    function do_enclose( $content, $post_ID ) { 
    597606         * @since 4.4.0
    598607         *
    599608         * @param array $post_links An array of enclosure links.
    600          * @param int   $post_ID    Post ID.
     609         * @param int   $post_id    Post ID.
    601610         */
    602         $post_links = apply_filters( 'enclosure_links', $post_links, $post_ID );
     611        $post_links = apply_filters( 'enclosure_links', $post_links, $post->ID );
    603612
    604613        foreach ( (array) $post_links as $url ) {
    605                 if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $url ) . '%' ) ) ) {
     614                if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $url ) . '%' ) ) ) {
    606615
    607616                        if ( $headers = wp_get_http_headers( $url) ) {
    608617                                $len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0;
    function do_enclose( $content, $post_ID ) { 
    625634                                }
    626635
    627636                                if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
    628                                         add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
     637                                        add_post_meta( $post->ID, 'enclosure', "$url\n$len\n$mime\n" );
    629638                                }
    630639                        }
    631640                }