Make WordPress Core

Changeset 36138


Ignore:
Timestamp:
12/31/2015 05:15:23 PM (9 years ago)
Author:
rachelbaker
Message:

Feeds: Comments on attachments display in the site-wide comments RSS feed.

Individual attachment pages already have their own RSS comment feed, and would be expected to be included in the site-wide comments RSS feed.

Props jbrinley.
Fixes #15610

Location:
trunk
Files:
3 edited

Legend:

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

    r36128 r36138  
    31943194            } else { // Other non singular e.g. front
    31953195                $cjoin = "JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )";
    3196                 $cwhere = "WHERE post_status = 'publish' AND comment_approved = '1'";
     3196                $cwhere = "WHERE ( post_status = 'publish' OR ( post_status = 'inherit' && post_type = 'attachment' ) ) AND comment_approved = '1'";
    31973197                $cgroupby = '';
    31983198            }
  • trunk/tests/phpunit/tests/query/conditionals.php

    r35679 r36138  
    5656        $this->go_to( get_post_comments_feed_link( $post_id ) );
    5757        $this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
     58    }
     59
     60    function test_attachment_comments_feed() {
     61        $attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) );
     62        self::factory()->comment->create_post_comments( $attachment_id, 2 );
     63        $this->go_to( get_post_comments_feed_link( $attachment_id ) );
     64        $this->assertQueryTrue( 'is_feed', 'is_attachment', 'is_single', 'is_singular', 'is_comment_feed' );
    5865    }
    5966
  • trunk/tests/phpunit/tests/query/results.php

    r35242 r36138  
    704704        $this->assertCount( 0, $result2 );
    705705    }
     706
     707    /**
     708     * @ticket 15610
     709     */
     710    public function test_main_comments_feed_includes_attachment_comments() {
     711        $attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) );
     712        $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $attachment_id, 'comment_approved' => '1' ) );
     713
     714        $this->q->query( array( 'withcomments' => 1, 'feed' => 'feed' ) );
     715
     716        $this->assertTrue( $this->q->have_comments() );
     717
     718        $feed_comment = $this->q->next_comment();
     719        $this->assertEquals( $comment_id, $feed_comment->comment_ID );
     720    }
    706721}
Note: See TracChangeset for help on using the changeset viewer.