Make WordPress Core

Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#16702 closed defect (bug) (fixed)

is_blog_user() bug on Multisite

Reported by: mattyrob's profile MattyRob Owned by: ryan's profile ryan
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.0
Component: Multisite Keywords: dev-feedback
Focuses: Cc:

Description

I've just installed a fresh WordPress 3.1 with Multisite enable and configured and there seems to be a glitch in is_blog_user().

It looks for a capability with a key name of the site prefix . blog_id . _capabilties.

But, the first installed blog on an MU site is installed without the blog_id in the key name.

On my test site for example I have a the main site WPMU and 2 sub site Test1 and Test2.

In the usermeta table there are capability keynames as follows:

wpmu_capabilities (relating the my WPMU site)
wpmu_1_capabilities (relating to Test1)
wpmu_2_capabilities (relating to Test2)

So, is_blog_user() returns false for all users of WPMU as the function is looking for the wrong key name.

Attachments (6)

16702.diff (1.7 KB) - added by solarissmoke 14 years ago.
16702.patch (1.7 KB) - added by SergeyBiryukov 13 years ago.
16702.2.patch (1.8 KB) - added by SergeyBiryukov 13 years ago.
Move into ms-deprecated.php instead of deprecated.php
16702.3.patch (670 bytes) - added by SergeyBiryukov 13 years ago.
16702.4.patch (3.0 KB) - added by SergeyBiryukov 13 years ago.
16702.5.patch (3.0 KB) - added by SergeyBiryukov 13 years ago.

Download all attachments as: .zip

Change History (27)

#1 @nacin
14 years ago

Yeah, we should be using $wpdb->get_blog_prefix() there.

It looks like it's @since MU, rather than 3.0. I'd recommending using get_blogs_of_user() then look through that, for now. We don't use this function in core and I'd be inclined to deprecate it simply for its simply horrible name.

#2 @nacin
14 years ago

  • Version changed from 3.1 to 3.0

@solarissmoke
14 years ago

#3 @solarissmoke
14 years ago

  • Keywords has-patch added

You can also use get_users() and look through that.

#4 @MattyRob
13 years ago

  • Keywords needs-refresh dev-feedback added

Switched to using get_blogs_of_user() as suggested, all works fine.

+1 to commit the proposed patch, deprecate is_blog_user() and close this ticket.

#5 @SergeyBiryukov
13 years ago

  • Keywords needs-refresh removed
  • Milestone changed from Awaiting Review to 3.3

Refreshed for 3.3.

@SergeyBiryukov
13 years ago

Move into ms-deprecated.php instead of deprecated.php

#6 follow-up: @ryan
13 years ago

Let's keep this as a wrapper for get_blogs_of_user(). We can deprecate later when we are energetic enough to come up with a better name.

#7 in reply to: ↑ 6 @SergeyBiryukov
13 years ago

Replying to ryan:

Let's keep this as a wrapper for get_blogs_of_user().

Done in 16702.3.patch.

#9 @ryan
13 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [19004]:

Turn is_blog_user() into a convenience wrapper around get_blogs_of_user(). Fixes is_blog_user() for blog prefixes that do not contain a blog ID. Props SergeyBiryukov. fixes #16702

#10 @nacin
13 years ago

In [19005]:

is_blog_user() is from MU. see #16702.

#11 @scribu
13 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

There's another function: is_user_member_of_blog() which is already a wrapper around get_blogs_of_user().

#12 @scribu
13 years ago

  • Keywords has-patch removed

We should deprecate one or the other. is_blog_user() is shorter, but is_user_member_of_blog() is more descriptive. Coin toss?

#13 follow-up: @scribu
13 years ago

We can make is_blog_user() a wrapper for is_user_member_of_blog(), since the later requires a user id.

#14 in reply to: ↑ 13 @SergeyBiryukov
13 years ago

Replying to scribu:

We can make is_blog_user() a wrapper for is_user_member_of_blog()

That's what I initially was going to do, but that function seems to be only available in Multisite, while is_blog_user() is available on a single site too.

#15 @scribu
13 years ago

Well, both functions come from MU. It's silly to have one available all the time and one only for multisite.

IMO, we should make is_user_member_of_blog() available all the time.

#16 @scribu
13 years ago

Or just deprecate the fool, since we have a replacement.

#17 follow-up: @ryan
13 years ago

I forgot about is_user_member_of_blog(). Move it to user.php, make is_blog_user() wrap it, and deprecate is_blog_user(). How's that sound?

#18 in reply to: ↑ 17 @SergeyBiryukov
13 years ago

Replying to ryan:

I forgot about is_user_member_of_blog(). Move it to user.php, make is_blog_user() wrap it, and deprecate is_blog_user(). How's that sound?

Done in 16702.4.patch.

#19 @nacin
13 years ago

Let's also make $user_id for is_user_member_of_blog() default to 0, thus the current user. Then someone could call is_user_member_of_blog() and be told about the current user's relationship to the current blog. Basically identical to is_blog_user() now but a bit more flexible in the long run.

#20 @ryan
13 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In [19016]:

Turn is_blog_user() into a wrapper around is_user_member_of_blog() and deprecate. Make user_id optional for is_user_member_of_blog(). Props SergeyBiryukov. fixes #16702

#21 @ryan
13 years ago

[UT458] covers multisite. Need some single site ones.

Note: See TracTickets for help on using tickets.