WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 21 months ago

#16568 closed defect (bug) (fixed)

Network install disables site when blog_id is not 1

Reported by: wpmuguru Owned by: nacin
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.0.5
Component: Multisite Keywords: has-patch commit
Focuses: Cc:

Description

This is an edge case and only occurs when MySQL is configured to skip numbers in auto number fields.

The network install inserts the blog record and allows MySQL to assign the blog_id. The blog prefix logic in wpdb depends on the blog_id of the main blog being 1.

The manual fix for this is to edit the DB and change the blog_id of the main blog to 1. Between being an edge case and a relatively easy fix, this isn't severe, imo.

Forum thread: http://wordpress.org/support/topic/database-error-when-enabling-mutlisite

Attachments (2)

16568.diff (774 bytes) - added by wpmuguru 4 years ago.
hard code blog id 1
16568.2.diff (839 bytes) - added by wpmuguru 3 years ago.
16568.diff refreshed for 3.5

Download all attachments as: .zip

Change History (7)

@wpmuguru4 years ago

hard code blog id 1

comment:1 @wpmuguru4 years ago

The alternative to hardcoding the blog id of 1 is to warn the user that they have to edit the DB. A more elaborate solution would be to add a constant with the blog id and use the constant in wpdb. That may create more trouble than the current issue is.

I'm proposing this because it is the simplest solution.

comment:2 @wpmuguru4 years ago

  • Keywords has-patch added

@wpmuguru3 years ago

16568.diff refreshed for 3.5

comment:3 @jeremyfelt22 months ago

  • Keywords dev-feedback added
  • Milestone changed from Future Release to 3.7

Moving to 3.7 for discussion. How common is it to change the autoincrement seed in MySQL?

comment:4 @nacin22 months ago

  • Keywords commit added; dev-feedback removed

How common is it to change the autoincrement seed in MySQL?

Probably very uncommon. But 16568.2.diff looks good and seems proper. At the very least, the code is clear as to the expectation. This isn't that dissimilar to setting the post ID when we do an import, via import_id in wp_insert_post().

comment:5 @nacin21 months ago

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

In 25038:

In populate_network(), insert the first site as blog_id 1, overriding any auto-increment DB seed. props wpmuguru, fixes #16568.

Note: See TracTickets for help on using tickets.