Changeset 36353
- Timestamp:
- 01/20/2016 04:32:22 AM (9 years ago)
- Location:
- branches/4.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.4
-
branches/4.4/src/wp-includes/comment-template.php
r36158 r36353 1286 1286 'status' => 'approve', 1287 1287 'post_id' => $post->ID, 1288 'hierarchical' => 'threaded',1289 1288 'no_found_rows' => false, 1290 1289 'update_comment_meta_cache' => false, // We lazy-load comment meta for performance. 1291 1290 ); 1291 1292 if ( get_option('thread_comments') ) { 1293 $comment_args['hierarchical'] = 'threaded'; 1294 } else { 1295 $comment_args['hierarchical'] = false; 1296 } 1292 1297 1293 1298 if ( $user_ID ) { … … 1336 1341 1337 1342 // Trees must be flattened before they're passed to the walker. 1338 $comments_flat = array(); 1339 foreach ( $_comments as $_comment ) { 1340 $comments_flat[] = $_comment; 1341 $comment_children = $_comment->get_children( array( 1342 'format' => 'flat', 1343 'status' => $comment_args['status'], 1344 'orderby' => $comment_args['orderby'] 1345 ) ); 1346 1347 foreach ( $comment_children as $comment_child ) { 1348 $comments_flat[] = $comment_child; 1343 if ( $comment_args['hierarchical'] ) { 1344 $comments_flat = array(); 1345 foreach ( $_comments as $_comment ) { 1346 $comments_flat[] = $_comment; 1347 $comment_children = $_comment->get_children( array( 1348 'format' => 'flat', 1349 'status' => $comment_args['status'], 1350 'orderby' => $comment_args['orderby'] 1351 ) ); 1352 1353 foreach ( $comment_children as $comment_child ) { 1354 $comments_flat[] = $comment_child; 1355 } 1349 1356 } 1357 } else { 1358 $comments_flat = $_comments; 1350 1359 } 1351 1360 -
branches/4.4/tests/phpunit/tests/comment/commentsTemplate.php
r36041 r36353 690 690 return $commenter; 691 691 } 692 693 /** 694 * @ticket 35378 695 */ 696 public function test_hierarchy_should_be_ignored_when_threading_is_disabled() { 697 $now = time(); 698 $p = self::factory()->post->create(); 699 $comment_1 = self::factory()->comment->create( array( 700 'comment_post_ID' => $p, 701 'comment_content' => '1', 702 'comment_approved' => '1', 703 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), 704 ) ); 705 $comment_2 = self::factory()->comment->create( array( 706 'comment_post_ID' => $p, 707 'comment_content' => '2', 708 'comment_approved' => '1', 709 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), 710 ) ); 711 $comment_3 = self::factory()->comment->create( array( 712 'comment_post_ID' => $p, 713 'comment_content' => '3', 714 'comment_approved' => '1', 715 'comment_parent' => $comment_1, 716 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), 717 ) ); 718 719 update_option( 'comment_order', 'asc' ); 720 update_option( 'thread_comments', 0 ); 721 722 $this->go_to( get_permalink( $p ) ); 723 $found = get_echo( 'comments_template' ); 724 725 // Find the found comments in the markup. 726 preg_match_all( '|id="comment-([0-9]+)|', $found, $matches ); 727 728 $found_cids = array_map( 'intval', $matches[1] ); 729 $this->assertSame( array( $comment_2, $comment_3, $comment_1 ), $found_cids ); 730 } 692 731 }
Note: See TracChangeset
for help on using the changeset viewer.