Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/16/2020 04:30:46 AM (4 years ago)
Author:
r-a-y
Message:

Members: When marking a user as a spammer, do not mark sites as spam if the site has more than one administrator.

Previously on a multisite install, we would mark all the spammer's
sites as spam. This is pretty aggressive and could unintentionally
mark legitmiate sites as spam as well.

To address this, we now only mark a site as spam if the spammer is the
sole administrator of the site.

See #8316 (for trunk).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/members/functions.php

    r12606 r12665  
    538538        $this->assertSame( 'bp_make_ham_user', $this->filter_fired );
    539539
     540    }
     541
     542    /**
     543     * @group bp_core_process_spammer_status
     544     * @ticket BP8316
     545     */
     546    public function test_bp_core_process_spammer_status_ms_should_only_spam_sites_with_one_admin() {
     547        if ( ! is_multisite() ) {
     548            $this->markTestSkipped();
     549        }
     550
     551        $u1 = self::factory()->user->create();
     552        $u2 = self::factory()->user->create();
     553
     554        $b1 = self::factory()->blog->create( array( 'user_id' => $u1 ) );
     555
     556        // Add user 2 to site as administrator.
     557        add_user_to_blog( $b1, $u2, 'administrator' );
     558
     559        // Mark user 2 as a spammer.
     560        bp_core_process_spammer_status( $u2, 'spam' );
     561
     562        // Ensure site isn't marked as spam because there is more than one admin.
     563        $site = get_site( $b1 );
     564        $this->assertEmpty( $site->spam );
    540565    }
    541566
Note: See TracChangeset for help on using the changeset viewer.