Changeset 7527
- Timestamp:
- 09/16/2026 06:35:31 AM (2 months ago)
- Location:
- branches/2.6
- Files:
-
- 2 edited
-
src/includes/users/capabilities.php (modified) (4 diffs)
-
tests/phpunit/testcases/users/functions/counts.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/2.6/src/includes/users/capabilities.php
r7514 r7527 605 605 } 606 606 607 // Get array of post types to mark as spam 608 $post_types = array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ); 609 $post_types = "'" . implode( "', '", $post_types ) . "'"; 607 // Process replies before topics so topic status helpers run last 608 $post_types = array( bbp_get_reply_post_type(), bbp_get_topic_post_type() ); 610 609 611 610 // Get array of statuses to mark as spam … … 619 618 bbp_switch_to_site( $blog_id ); 620 619 621 // Get topics and replies 622 $query = $bbp_db->prepare( "SELECT ID FROM {$bbp_db->posts} WHERE post_author = %d AND post_status IN ( {$post_statuses} ) AND post_type IN ( {$post_types} )", $user_id ); 623 $posts = $bbp_db->get_col( $query ); 624 625 // Loop through posts and spam them 626 if ( ! empty( $posts ) ) { 627 foreach ( $posts as $post_id ) { 628 629 // The routines for topics ang replies are different, so use the 630 // correct one based on the post type 631 switch ( get_post_type( $post_id ) ) { 632 633 case bbp_get_topic_post_type() : 634 bbp_spam_topic( $post_id ); 635 break; 636 637 case bbp_get_reply_post_type() : 638 bbp_spam_reply( $post_id ); 639 break; 620 foreach ( $post_types as $post_type ) { 621 622 // Get posts of this type 623 $query = $bbp_db->prepare( "SELECT ID FROM {$bbp_db->posts} WHERE post_author = %d AND post_status IN ( {$post_statuses} ) AND post_type = %s", $user_id, $post_type ); 624 $posts = $bbp_db->get_col( $query ); 625 626 // Loop through posts and spam them 627 if ( ! empty( $posts ) ) { 628 foreach ( $posts as $post_id ) { 629 630 // The routines for topics and replies are different, so use the 631 // correct one based on the post type 632 switch ( $post_type ) { 633 634 case bbp_get_topic_post_type() : 635 bbp_spam_topic( $post_id ); 636 break; 637 638 case bbp_get_reply_post_type() : 639 bbp_spam_reply( $post_id ); 640 break; 641 } 640 642 } 641 643 } … … 690 692 } 691 693 692 // Get array of post types to mark as spam 693 $post_types = array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ); 694 $post_types = "'" . implode( "', '", $post_types ) . "'"; 694 // Process replies before topics so topic status helpers run last 695 $post_types = array( bbp_get_reply_post_type(), bbp_get_topic_post_type() ); 695 696 696 697 // Get array of statuses to unmark as spam … … 704 705 bbp_switch_to_site( $blog_id ); 705 706 706 // Get topics and replies 707 $query = $bbp_db->prepare( "SELECT ID FROM {$bbp_db->posts} WHERE post_author = %d AND post_status IN ( {$post_statuses} ) AND post_type IN ( {$post_types} )", $user_id ); 708 $posts = $bbp_db->get_col( $query ); 709 710 // Loop through posts and spam them 711 if ( ! empty( $posts ) ) { 712 foreach ( $posts as $post_id ) { 713 714 // The routines for topics ang replies are different, so use the 715 // correct one based on the post type 716 switch ( get_post_type( $post_id ) ) { 717 718 case bbp_get_topic_post_type() : 719 bbp_unspam_topic( $post_id ); 720 break; 721 722 case bbp_get_reply_post_type() : 723 bbp_unspam_reply( $post_id ); 724 break; 707 foreach ( $post_types as $post_type ) { 708 709 // Get posts of this type 710 $query = $bbp_db->prepare( "SELECT ID FROM {$bbp_db->posts} WHERE post_author = %d AND post_status IN ( {$post_statuses} ) AND post_type = %s", $user_id, $post_type ); 711 $posts = $bbp_db->get_col( $query ); 712 713 // Loop through posts and unspam them 714 if ( ! empty( $posts ) ) { 715 foreach ( $posts as $post_id ) { 716 717 // The routines for topics and replies are different, so use the 718 // correct one based on the post type 719 switch ( $post_type ) { 720 721 case bbp_get_topic_post_type() : 722 bbp_unspam_topic( $post_id ); 723 break; 724 725 case bbp_get_reply_post_type() : 726 bbp_unspam_reply( $post_id ); 727 break; 728 } 725 729 } 726 730 } -
branches/2.6/tests/phpunit/testcases/users/functions/counts.php
r7468 r7527 621 621 'topic_meta' => array( 'forum_id' => $forum_id ), 622 622 ) ); 623 $ this->factory->reply->create( array(623 $reply_id = $this->factory->reply->create( array( 624 624 'post_author' => $user_id, 625 625 'post_parent' => $topic_id, … … 631 631 632 632 $this->assertTrue( bbp_make_spam_user( $user_id ) ); 633 $this->assertSame( bbp_get_spam_status_id(), get_post_status( $topic_id ) ); 634 $this->assertSame( bbp_get_spam_status_id(), get_post_status( $reply_id ) ); 633 635 $this->assertSame( 0, bbp_get_user_topic_count( $user_id, true ) ); 634 636 $this->assertSame( 0, bbp_get_user_reply_count( $user_id, true ) ); … … 639 641 640 642 $this->assertTrue( bbp_make_ham_user( $user_id ) ); 643 $this->assertSame( bbp_get_public_status_id(), get_post_status( $topic_id ) ); 644 $this->assertSame( bbp_get_public_status_id(), get_post_status( $reply_id ) ); 641 645 $this->assertSame( 1, bbp_get_user_topic_count( $user_id, true ) ); 642 646 $this->assertSame( 1, bbp_get_user_reply_count( $user_id, true ) );
Note:
See TracChangeset
for help on using the changeset viewer.