Index: src/wp-includes/feed-atom.php
===================================================================
--- src/wp-includes/feed-atom.php	(revisione 34355)
+++ src/wp-includes/feed-atom.php	(copia locale)
@@ -78,10 +78,13 @@
 	 * @since 2.0.0
 	 */
 	do_action( 'atom_entry' );
+
+    if ( has_comments_link() ) :
 		?>
 		<link rel="replies" type="<?php bloginfo_rss('html_type'); ?>" href="<?php the_permalink_rss() ?>#comments" thr:count="<?php echo get_comments_number()?>"/>
 		<link rel="replies" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link(0, 'atom') ); ?>" thr:count="<?php echo get_comments_number()?>"/>
 		<thr:total><?php echo get_comments_number()?></thr:total>
+    <?php endif; ?>
 	</entry>
 	<?php endwhile ; ?>
 </feed>
Index: src/wp-includes/feed-rss2.php
===================================================================
--- src/wp-includes/feed-rss2.php	(revisione 34355)
+++ src/wp-includes/feed-rss2.php	(copia locale)
@@ -83,8 +83,10 @@
 	<item>
 		<title><?php the_title_rss() ?></title>
 		<link><?php the_permalink_rss() ?></link>
-		<comments><?php comments_link_feed(); ?></comments>
-		<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
+    <?php if ( has_comments_link() ) : ?>
+        <comments><?php comments_link_feed(); ?></comments>
+    <?php endif; ?>
+        <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
 		<dc:creator><![CDATA[<?php the_author() ?>]]></dc:creator>
 		<?php the_category_rss('rss2') ?>
 
@@ -100,8 +102,10 @@
 		<content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
 	<?php endif; ?>
 <?php endif; ?>
+    <?php if ( has_comments_link() ) : ?>
 		<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
 		<slash:comments><?php echo get_comments_number(); ?></slash:comments>
+    <?php endif; ?>
 <?php rss_enclosure(); ?>
 	<?php
 	/**
Index: src/wp-includes/feed.php
===================================================================
--- src/wp-includes/feed.php	(revisione 34355)
+++ src/wp-includes/feed.php	(copia locale)
@@ -260,6 +260,17 @@
 }
 
 /**
+ * Whether we have to show comments links because the post type supports it and comments are open
+ * @param int|WP_Post|null $post Optional. Post ID or post object. Default is global $post.
+ * @return bool
+ */
+function has_comments_link( $post = null ) {
+    $has_comments_link = ( post_type_supports( get_post_type( $post ), 'comments' ) && comments_open( $post ) );
+
+    return apply_filters( 'has_comments_link', $has_comments_link );
+}
+
+/**
  * Display the feed GUID for the current comment.
  *
  * @since 2.5.0
Index: tests/phpunit/tests/feed/rss2.php
===================================================================
--- tests/phpunit/tests/feed/rss2.php	(revisione 34355)
+++ tests/phpunit/tests/feed/rss2.php	(copia locale)
@@ -148,6 +148,9 @@
 			$comments_link = xml_find( $items[$key]['child'], 'comments' );
 			$this->assertEquals( get_permalink( $post) . '#respond', $comments_link[0]['content'] );
 
+            // Ticket https://core.trac.wordpress.org/ticket/9134
+            $this->assertTrue( has_comments_link() );
+
 			// pub date
 			$pubdate = xml_find( $items[$key]['child'], 'pubDate' );
 			$this->assertEquals( strtotime( $post->post_date_gmt ), strtotime( $pubdate[0]['content'] ) );
@@ -201,4 +204,29 @@
 			$this->assertEquals( html_entity_decode( get_post_comments_feed_link( $post->ID) ), $comment_rss[0]['content'] );
 		}
 	}
+
+    // @ticket 9134
+    function test_has_comments_link() {
+        $post_id = wp_insert_post(
+            array(
+                'post_author' => 1,
+                'post_status' => 'publish',
+                'post_content' => rand_str(),
+                'post_title' => rand_str(),
+                'post_status' => 'open'
+            )
+        );
+        $this->assertTrue( has_comments_link( $post_id ) );
+
+        $post_id = wp_insert_post(
+            array(
+                'post_author' => 1,
+                'post_status' => 'publish',
+                'post_content' => rand_str(),
+                'post_title' => rand_str(),
+                'comment_status' => 'closed'
+            )
+        );
+        $this->assertFalse( has_comments_link( $post_id ) );
+    }
 }
