#5834 closed defect (bug) (fixed)
Notice while activating a member (with no role on any blogs) on a multisite config
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Blogs | Keywords: | |
Cc: |
Description
Multisite config with users & blogs registration opened
Steps to reproduce :
- register a dummy account by making sure you don't request a blog
- with a super admin account, go to the Manage Signups screen and activate the member.
Notice error in bp_blogs_add_user_to_blog()
using array_keys()
at line 862. I think as the member has no role on any blogs the check for the user meta $wpdb->get_blog_prefix( $blog_id ). 'capabilities'
simply returns an empty string.
Casting this to an array is fixing the issue, see attached patch.
Attachments (4)
Change History (26)
#3
in reply to:
↑ 2
@
11 years ago
Replying to boonebgorges:
This seems like a fine fix to me. A unit test would be nice.
Thanks for your feedback 5834.unit_tests.patch is 5834.patch + 2 tests :
- one to test user accounts activation on regular/multisite configs
- one other to test user accounts + blogs activation on multisite config.
#4
follow-up:
↓ 5
@
11 years ago
Thanks, imath. Those tests look good and are nice to have, but they pass even without your patch to bp_blogs_add_user_to_blog()
. Can you write a test just for this function that fails before your fix?
#5
in reply to:
↑ 4
@
11 years ago
Replying to boonebgorges:
but they pass even without your patch to
bp_blogs_add_user_to_blog()
.
Oops my bad the last patch contains the previous one, i should have not include the fix in the patch sorry :(
If you checkout the changes to blogs functions file you should see tests failing
#7
@
11 years ago
*including*
Just checked and added 5834.solo_tests.patch so it's easier to only apply the tests.
The problem only occurs on multisite configs actually so make sure to use the -c tests/phpunit/multisite.xml
option to see the tests failing.
On regular configs each member has a role, so there's no problem.
#10
@
11 years ago
- Owner set to imath
- Resolution set to fixed
- Status changed from new to closed
In 8965:
#11
@
11 years ago
- Keywords has-patch commit removed
- Resolution fixed deleted
- Status changed from closed to reopened
Looks like this broke another signup-related test https://travis-ci.org/buddypress/BuddyPress/builds/33634198 My bad, I should have run the whole suite before adding the 'commit' tag. imath, can you have another look?
#13
@
11 years ago
Weird it's one of the tests i've added BP_Tests_BP_Signup::test_activate_user_accounts_with_blogs
but it's working fine for me ?
#14
@
11 years ago
Are you running all the tests together? There must be some global stuff bleeding through, or some other test not cleaning up properly.
#15
@
11 years ago
Replying to boonebgorges:
Are you running all the tests together? There must be some global stuff bleeding through, or some other test not cleaning up properly.
Just did, and saw there was a trouble :( Searching what is the trouble..
#16
@
11 years ago
The problem is i use path blogone, blogthree
and in WP_UnitTest_Factory_For_Blog
it sets testpath1 for the first blog without taking in account the signup 'path' attribute. But for the 3rd blog it's taking in account the path attribute of the signup ?!?
i've tried many things like setting the domain, path, title to nothing for blogone, it keeps on creating a blog having a path set to testpath1
The only way i got it to work was to set blogone's path to 'testpath' knowing at the end the blogone's path would be 'testpath1'. Very strange :(
But then if only testing --group BP_Signup it dramatically fails :(
#17
@
11 years ago
- Keywords 2nd-opinion added
Ok i think we cannot trust the first signup, so in 5834.cant-trust-first-signup.patch, i suggest to avoid taking it in account.
I've double checked by running all tests and --group BP_Signup twice and it's working.
Boone, can you check it ?
#18
@
11 years ago
- Keywords 2nd-opinion removed
and in WP_UnitTest_Factory_For_Blog it sets testpath1 for the first blog without taking in account the signup 'path' attribute. But for the 3rd blog it's taking in account the path attribute of the signup ?!?
I don't really follow this. Where in your BP_Signup tests are you actually creating blogs? And why would that blog creation happen with WP_UnitTest_Factory_For_Blog?
Worst case scenario, you should go back to the drawing board and make your test smaller. You're running a big long test with signups. The bug here, however, is in bp_blogs_add_user_to_blog()
Write the smallest possible test that demonstrates the error:
$u = $this->factory->user->create(); $b = $this->factory->blog->create(); $result = bp_blogs_add_user_to_blog( $u, $b ); $this->assertSame( null, $result );
This test kinda stinks because bp_blogs_add_user_to_blog() doesn't return any value on success, but that's an item for a separate ticket. The point is that this tests something much closer to the problem, and skirts your signup issue.
It's also happening if a user registered a blog.