Make WordPress Core

Ticket #36824: 36824.4.diff

File 36824.4.diff, 4.4 KB (added by spacedmonkey, 9 years ago)
  • src/wp-includes/comment.php

     
    22662266function do_all_pings() {
    22672267        global $wpdb;
    22682268
     2269        $post_types = get_post_types( array( 'publicly_queryable' => true ) );
     2270
    22692271        // Do pingbacks
    2270         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")) {
    2271                 delete_metadata_by_mid( 'post', $ping->meta_id );
     2272        $pings = get_posts( array( 'post_type' => $post_types, 'suppress_filters' => false, 'posts_per_page' => -1, 'meta_value' => '_pingme' ) );
     2273        foreach ( $pings as $ping ) {
     2274                delete_post_meta( $ping->ID, '_pingme' );
    22722275                pingback( $ping->post_content, $ping->ID );
    22732276        }
    22742277
    22752278        // Do Enclosures
    2276         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")) {
    2277                 delete_metadata_by_mid( 'post', $enclosure->meta_id );
     2279        $enclosures = get_posts( array( 'post_type' => $post_types, 'suppress_filters' => false, 'posts_per_page' => -1, 'meta_value' => '_encloseme' ) );
     2280        foreach ( $enclosures as $enclosure ) {
     2281                delete_post_meta( $enclosure->ID, '_encloseme' );
    22782282                do_enclose( $enclosure->post_content, $enclosure->ID );
    22792283        }
    22802284
    22812285        // Do Trackbacks
    2282         $trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'");
    2283         if ( is_array($trackbacks) )
    2284                 foreach ( $trackbacks as $trackback )
    2285                         do_trackbacks($trackback);
     2286        $trackbacks = get_posts( array( 'post_type' => $post_types, 'suppress_filters' => false, 'posts_per_page' => -1, 'to_ping' => true, 'fields' => 'ids' ) );
     2287        foreach ( $trackbacks as $trackback ) {
     2288                do_trackbacks( $trackback );
     2289        }
    22862290
    22872291        //Do Update Services/Generic Pings
    22882292        generic_ping();
  • src/wp-includes/query.php

     
    15771577         *     @type array        $tax_query               An associative array of WP_Tax_Query arguments.
    15781578         *                                                 See WP_Tax_Query->queries.
    15791579         *     @type string       $title                   Post title.
     1580         *     @type string       $to_ping                 Post ping status. Default false.
    15801581         *     @type bool         $update_post_meta_cache  Whether to update the post meta cache. Default true.
    15811582         *     @type bool         $update_post_term_cache  Whether to update the post term cache. Default true.
    15821583         *     @type bool         $lazy_load_term_meta     Whether to lazy-load term meta. Setting to false will
     
    16211622                $qv['pagename'] = trim( $qv['pagename'] );
    16221623                $qv['name'] = trim( $qv['name'] );
    16231624                $qv['title'] = trim( $qv['title'] );
     1625
    16241626                if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
    16251627                if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']);
    16261628                if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']);
     
    25652567                        else
    25662568                                $q['post_type'] = '';
    25672569                }
     2570                if ( ! isset( $q['to_ping'] ) ) {
     2571                        $q['to_ping'] = false;
     2572                }
    25682573                $post_type = $q['post_type'];
    25692574                if ( empty( $q['posts_per_page'] ) ) {
    25702575                        $q['posts_per_page'] = get_option( 'posts_per_page' );
     
    30933098                        $post_type_object = get_post_type_object ( 'post' );
    30943099                }
    30953100
     3101                if ( $q['to_ping'] ) {
     3102                        $where .= " AND {$wpdb->posts}.to_ping <> ''";
     3103                }
     3104
    30963105                $edit_cap = 'edit_post';
    30973106                $read_cap = 'read_post';
    30983107
  • tests/phpunit/tests/post/query.php

     
    388388                $actual_posts = $q->get_posts();
    389389                $this->assertEqualSets( $requested, $actual_posts );
    390390        }
     391       
     392        /**
     393         * Tests the to_ping attribute of WP_Query.
     394         *
     395         * @ticket 36824
     396         */
     397        public function test_to_ping() {
     398                $q = new WP_Query();
    391399
     400                $post_ids[0] = self::factory()->post->create( array(
     401                                                'to_ping' => 'http://www.example.com' ) );
     402                $q->query( array(
     403                                'to_ping' => '',
     404                                'fields' => 'ids' ) );
     405                $actual_posts = $q->get_posts();
     406                $this->assertSame( $post_ids, $actual_posts );
     407        }
     408
     409
    392410        /**
    393411         * @ticket 36687
    394412         */