Ticket #36824: 36824.9.diff
File 36824.9.diff, 6.1 KB (added by , 7 years ago) |
---|
-
src/wp-includes/comment.php
2579 2579 function do_all_pings() { 2580 2580 global $wpdb; 2581 2581 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 ); 2586 2599 } 2587 2600 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 ); 2592 2615 } 2593 2616 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 'meta_key' => '_tbme', 2624 'fields' => 'ids', 2625 ) 2626 ); 2627 2628 foreach ( $trackbacks as $trackback ) { 2629 do_trackbacks( $trackback ); 2630 delete_post_meta( $trackback, '_tbme' ); 2600 2631 } 2601 2632 2602 2633 //Do Update Services/Generic Pings -
src/wp-includes/functions.php
562 562 * pingbacks and trackbacks. 563 563 * 564 564 * @since 1.5.0 565 * @since 4.9.7 `$post` can be a WP_Post object. 565 566 * 566 567 * @global wpdb $wpdb WordPress database abstraction object. 567 568 * 568 * @param string $content Post Content.569 * @param int $post_ID PostID.569 * @param string $content Post Content. If empty will retrieve from post. 570 * @param int|WP_Post $post Post object or ID. 570 571 */ 571 function do_enclose( $content, $post _ID) {572 function do_enclose( $content, $post ) { 572 573 global $wpdb; 573 574 575 $post = get_post( $post ); 576 if ( ! $post ) { 577 return false; 578 } 579 580 if ( ! $content ) { 581 $content = $post->post_content; 582 } 583 574 584 //TODO: Tidy this ghetto code up and make the debug code optional 575 585 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 576 586 577 587 $post_links = array(); 578 588 579 $pung = get_enclosed( $post _ID );589 $pung = get_enclosed( $post->ID ); 580 590 581 591 $post_links_temp = wp_extract_urls( $content ); 582 592 583 593 foreach ( $pung as $link_test ) { 584 594 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 ) . '%' ) ); 586 596 foreach ( $mids as $mid ) { 587 597 delete_metadata_by_mid( 'post', $mid ); 588 598 } … … 591 601 592 602 foreach ( (array) $post_links_temp as $link_test ) { 593 603 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 ); 595 605 if ( false === $test ) { 596 606 continue; 597 607 } … … 612 622 * @since 4.4.0 613 623 * 614 624 * @param array $post_links An array of enclosure links. 615 * @param int $post_ IDPost ID.625 * @param int $post_id Post ID. 616 626 */ 617 $post_links = apply_filters( 'enclosure_links', $post_links, $post _ID );627 $post_links = apply_filters( 'enclosure_links', $post_links, $post->ID ); 618 628 619 629 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 ) . '%' ) ) ) { 621 631 622 632 if ( $headers = wp_get_http_headers( $url ) ) { 623 633 $len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0; … … 640 650 } 641 651 642 652 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" ); 644 654 } 645 655 } 646 656 } -
src/wp-includes/post.php
6373 6373 } 6374 6374 add_post_meta( $post_id, '_encloseme', '1' ); 6375 6375 6376 if ( ! empty( get_to_ping( $post_id ) ) ) { 6377 add_post_meta( $post_id, '_tbme', '1' ); 6378 } 6379 6376 6380 if ( ! wp_next_scheduled( 'do_pings' ) ) { 6377 6381 wp_schedule_single_event( time(), 'do_pings' ); 6378 6382 }