Make WordPress Core

Opened 6 years ago

Closed 6 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 6 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 @ryan6 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.

@ryan6 years ago

comment:2 @nacin6 years ago

Looks about right. Related fix, [13121]

comment:3 @wpmuguru6 years ago

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

comment:4 @wpmuguru6 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.

comment:5 follow-up: @nacin6 years ago

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

comment:6 in reply to: ↑ 5 @wpmuguru6 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.

comment:7 @nacin6 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.

comment:8 @nacin6 years ago

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