Changeset 7526
- Timestamp:
- 09/16/2026 06:34:30 AM (5 days ago)
- Location:
- trunk
- 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
-
trunk/src/includes/users/capabilities.php
r7515 r7526 607 607 } 608 608 609 // Get array of post types to mark as spam 610 $post_types = array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ); 611 $post_types = "'" . implode( "', '", $post_types ) . "'"; 609 // Process replies before topics so topic status helpers run last 610 $post_types = array( bbp_get_reply_post_type(), bbp_get_topic_post_type() ); 612 611 613 612 // Get array of statuses to mark as spam … … 621 620 bbp_switch_to_site( $blog_id ); 622 621 623 // Get topics and replies 624 $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 ); 625 $posts = $bbp_db->get_col( $query ); 626 627 // Loop through posts and spam them 628 if ( ! empty( $posts ) ) { 629 foreach ( $posts as $post_id ) { 630 631 // The routines for topics ang replies are different, so use the 632 // correct one based on the post type 633 switch ( get_post_type( $post_id ) ) { 634 635 case bbp_get_topic_post_type() : 636 bbp_spam_topic( $post_id ); 637 break; 638 639 case bbp_get_reply_post_type() : 640 bbp_spam_reply( $post_id ); 641 break; 622 foreach ( $post_types as $post_type ) { 623 624 // Get posts of this type 625 $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 ); 626 $posts = $bbp_db->get_col( $query ); 627 628 // Loop through posts and spam them 629 if ( ! empty( $posts ) ) { 630 foreach ( $posts as $post_id ) { 631 632 // The routines for topics and replies are different, so use the 633 // correct one based on the post type 634 switch ( $post_type ) { 635 636 case bbp_get_topic_post_type() : 637 bbp_spam_topic( $post_id ); 638 break; 639 640 case bbp_get_reply_post_type() : 641 bbp_spam_reply( $post_id ); 642 break; 643 } 642 644 } 643 645 } … … 692 694 } 693 695 694 // Get array of post types to mark as spam 695 $post_types = array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ); 696 $post_types = "'" . implode( "', '", $post_types ) . "'"; 696 // Process replies before topics so topic status helpers run last 697 $post_types = array( bbp_get_reply_post_type(), bbp_get_topic_post_type() ); 697 698 698 699 // Get array of statuses to unmark as spam … … 706 707 bbp_switch_to_site( $blog_id ); 707 708 708 // Get topics and replies 709 $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 ); 710 $posts = $bbp_db->get_col( $query ); 711 712 // Loop through posts and spam them 713 if ( ! empty( $posts ) ) { 714 foreach ( $posts as $post_id ) { 715 716 // The routines for topics ang replies are different, so use the 717 // correct one based on the post type 718 switch ( get_post_type( $post_id ) ) { 719 720 case bbp_get_topic_post_type() : 721 bbp_unspam_topic( $post_id ); 722 break; 723 724 case bbp_get_reply_post_type() : 725 bbp_unspam_reply( $post_id ); 726 break; 709 foreach ( $post_types as $post_type ) { 710 711 // Get posts of this type 712 $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 ); 713 $posts = $bbp_db->get_col( $query ); 714 715 // Loop through posts and unspam them 716 if ( ! empty( $posts ) ) { 717 foreach ( $posts as $post_id ) { 718 719 // The routines for topics and replies are different, so use the 720 // correct one based on the post type 721 switch ( $post_type ) { 722 723 case bbp_get_topic_post_type() : 724 bbp_unspam_topic( $post_id ); 725 break; 726 727 case bbp_get_reply_post_type() : 728 bbp_unspam_reply( $post_id ); 729 break; 730 } 727 731 } 728 732 } -
trunk/tests/phpunit/testcases/users/functions/counts.php
r7467 r7526 622 622 'topic_meta' => array( 'forum_id' => $forum_id ), 623 623 ) ); 624 $ this->factory->reply->create( array(624 $reply_id = $this->factory->reply->create( array( 625 625 'post_author' => $user_id, 626 626 'post_parent' => $topic_id, … … 632 632 633 633 $this->assertTrue( bbp_make_spam_user( $user_id ) ); 634 $this->assertSame( bbp_get_spam_status_id(), get_post_status( $topic_id ) ); 635 $this->assertSame( bbp_get_spam_status_id(), get_post_status( $reply_id ) ); 634 636 $this->assertSame( 0, bbp_get_user_topic_count( $user_id, true ) ); 635 637 $this->assertSame( 0, bbp_get_user_reply_count( $user_id, true ) ); … … 640 642 641 643 $this->assertTrue( bbp_make_ham_user( $user_id ) ); 644 $this->assertSame( bbp_get_public_status_id(), get_post_status( $topic_id ) ); 645 $this->assertSame( bbp_get_public_status_id(), get_post_status( $reply_id ) ); 642 646 $this->assertSame( 1, bbp_get_user_topic_count( $user_id, true ) ); 643 647 $this->assertSame( 1, bbp_get_user_reply_count( $user_id, true ) );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)