Make WordPress Core

Ticket #36824: 36824.8.diff

File 36824.8.diff, 5.7 KB (added by boonebgorges, 7 years ago)
  • src/wp-includes/comment.php

    diff --git src/wp-includes/comment.php src/wp-includes/comment.php
    index 4c78eb9b6a..4766651b47 100644
    function discover_pingback_server_uri( $url, $deprecated = '' ) { 
    25792579function do_all_pings() {
    25802580        global $wpdb;
    25812581
    2582         // Do pingbacks
    2583         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" ) ) {
    2584                 delete_metadata_by_mid( 'post', $ping->meta_id );
    2585                 pingback( $ping->post_content, $ping->ID );
     2582        // Determine which classes support trackbacks and pingbacks
     2583        $ping_types = get_post_types_by_support( 'trackbacks' );
     2584
     2585        // Do pingbacks.
     2586        $pings = get_posts(
     2587                array(
     2588                        'post_type'        => $ping_types,
     2589                        'suppress_filters' => false,
     2590                        'nopaging'         => true,
     2591                        'meta_value'       => '_pingme',
     2592                        'fields'           => 'ids',
     2593                )
     2594        );
     2595
     2596        foreach ( $pings as $ping ) {
     2597                delete_post_meta( $ping, '_pingme' );
     2598                pingback( null, $ping );
    25862599        }
    25872600
    2588         // Do Enclosures
    2589         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" ) ) {
    2590                 delete_metadata_by_mid( 'post', $enclosure->meta_id );
    2591                 do_enclose( $enclosure->post_content, $enclosure->ID );
     2601        // Do enclosures.
     2602        $enclosures = get_posts(
     2603                array(
     2604                        'post_type'        => get_post_types( array( 'publicly_queryable' => true ) ),
     2605                        'suppress_filters' => false,
     2606                        'nopaging'         => true,
     2607                        'meta_key'         => '_encloseme',
     2608                        'fields'           => 'ids',
     2609                )
     2610        );
     2611
     2612        foreach ( $enclosures as $enclosure ) {
     2613                delete_post_meta( $enclosure, '_encloseme' );
     2614                do_enclose( null, $enclosure );
    25922615        }
    25932616
    2594         // Do Trackbacks
    2595         $trackbacks = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'" );
    2596         if ( is_array( $trackbacks ) ) {
    2597                 foreach ( $trackbacks as $trackback ) {
    2598                         do_trackbacks( $trackback );
    2599                 }
     2617        // Do trackbacks.
     2618        $trackbacks = get_posts(
     2619                array(
     2620                        'post_type'        => $ping_types,
     2621                        'suppress_filters' => false,
     2622                        'nopaging'         => true,
     2623                        'to_ping'          => true,
     2624                        'fields'           => 'ids',
     2625                )
     2626        );
     2627
     2628        foreach ( $trackbacks as $trackback ) {
     2629                do_trackbacks( $trackback );
    26002630        }
    26012631
    26022632        //Do Update Services/Generic Pings
  • src/wp-includes/functions.php

    diff --git src/wp-includes/functions.php src/wp-includes/functions.php
    index 60229ee10b..20d36688ad 100644
    function wp_extract_urls( $content ) { 
    562562 * pingbacks and trackbacks.
    563563 *
    564564 * @since 1.5.0
     565 * @since 4.9.7 `$post` can be a WP_Post object.
    565566 *
    566567 * @global wpdb $wpdb WordPress database abstraction object.
    567568 *
    568  * @param string $content Post Content.
    569  * @param int    $post_ID Post ID.
     569 * @param string      $content Post Content. If empty will retrieve from post.
     570 * @param int|WP_Post $post    Post object or ID.
    570571 */
    571 function do_enclose( $content, $post_ID ) {
     572function do_enclose( $content, $post ) {
    572573        global $wpdb;
    573574
     575        $post = get_post( $post );
     576        if ( ! $post ) {
     577                return false;
     578        }
     579
     580        if ( ! $content ) {
     581                $content = $post->post_content;
     582        }
     583
    574584        //TODO: Tidy this ghetto code up and make the debug code optional
    575585        include_once( ABSPATH . WPINC . '/class-IXR.php' );
    576586
    577587        $post_links = array();
    578588
    579         $pung = get_enclosed( $post_ID );
     589        $pung = get_enclosed( $post->ID );
    580590
    581591        $post_links_temp = wp_extract_urls( $content );
    582592
    583593        foreach ( $pung as $link_test ) {
    584594                if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post
    585                         $mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $link_test ) . '%' ) );
     595                        $mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $link_test ) . '%' ) );
    586596                        foreach ( $mids as $mid ) {
    587597                                delete_metadata_by_mid( 'post', $mid );
    588598                        }
    function do_enclose( $content, $post_ID ) { 
    591601
    592602        foreach ( (array) $post_links_temp as $link_test ) {
    593603                if ( ! in_array( $link_test, $pung ) ) { // If we haven't pung it already
    594                         $test = @parse_url( $link_test );
     604                        $test = wp_parse_url( $link_test );
    595605                        if ( false === $test ) {
    596606                                continue;
    597607                        }
    function do_enclose( $content, $post_ID ) { 
    612622         * @since 4.4.0
    613623         *
    614624         * @param array $post_links An array of enclosure links.
    615          * @param int   $post_ID    Post ID.
     625         * @param int   $post_id    Post ID.
    616626         */
    617         $post_links = apply_filters( 'enclosure_links', $post_links, $post_ID );
     627        $post_links = apply_filters( 'enclosure_links', $post_links, $post->ID );
    618628
    619629        foreach ( (array) $post_links as $url ) {
    620                 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 ) . '%' ) ) ) {
     630                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 ) . '%' ) ) ) {
    621631
    622632                        if ( $headers = wp_get_http_headers( $url ) ) {
    623633                                $len           = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0;
    function do_enclose( $content, $post_ID ) { 
    640650                                }
    641651
    642652                                if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types ) ) {
    643                                         add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
     653                                        add_post_meta( $post->ID, 'enclosure', "$url\n$len\n$mime\n" );
    644654                                }
    645655                        }
    646656                }