Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#12820 closed defect (bug) (fixed)

get_blog_prefix() does not return prefix for current blog when no blog ID is passed

Reported by: ryan Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version:
Component: Multisite Keywords:
Focuses: Cc:


get_blog_prefix() is called without a blog_id arg in several places, notably in wp-admin/includes/user.php when creating level_keys. Since get_blog_prefix() does not return the current prefix when blog ID is not passed and is_multisite(), the keys are wrong. I suspect these places should use $wpdb->prefix.

There's also a call to get_blog_prefix() with no args in ms-settings.php. This results in $table_prefix being assigned base_prefix. I think is expected but should be verified.

Attachments (1)

12820.diff (786 bytes) - added by ryan 12 years ago.

Download all attachments as: .zip

Change History (9)

#1 @ryan
12 years ago

MU returned prefix if no blog ID was given. 3.0 currently returns base_prefix. We should return prefix to be compat with MU.

12 years ago

#2 @nacin
12 years ago

Looks about right. Related fix, [13121]

#3 @wpmuguru
12 years ago

(In [13949]) have get_blog_prefix() default to the prefix of the current blog, see #12820

#4 @wpmuguru
12 years ago

I wanted to leave this one open for a few days just in case there was an issue that cropped up as a result of the change.

#5 follow-up: @nacin
12 years ago

Cool, I haven't seen any problems anywhere yet. Using null would have made more sense than -1, though.

#6 in reply to: ↑ 5 @wpmuguru
12 years ago

Replying to nacin:

Cool, I haven't seen any problems anywhere yet. Using null would have made more sense than -1, though.

That was changed from a to a 0 on the grounds of datatype consistency (way back when). So I used the -1 to maintain that. The null makes more sense to me as well but technically is not a number.

#7 @nacin
12 years ago

Technically, null is nothing. :) Using null as a default is much cleaner than passing -1. PHP is loosely typed and using a default value like this is very common in WordPress.

#8 @nacin
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.