The MU forums have moved to WordPress.org

Bug: Can't make multiple blogs simultaneously. (8 posts)

  1. Vimm
    Member
    Posted 17 years ago #

    I'm trying to create multiple blogs at once and I seem to be having a problem. I can create the first one just fine, but when I try to make additional blogs they get added to the wp_blogs table but their tables are never created. To make sure I'm not crazy I created this sample (using pre-populated variables):

    wpmu_create_blog($wpmu_domain, "/wpmu/blah1/", "Blah Blah 1", $user_id, $meta);
    wpmu_create_blog($wpmu_domain, "/wpmu/blah2/", "Blah Blah 2", $user_id, $meta);

    Sure enough, only the first blog was created yet the second blog is listed in wp_blogs. I'm heading out for the weekend but I really need to do this. Anyone have any idea why this won't work in MU-WP 1.2.3? If not I'll try to debug it on Monday.

  2. mysorehead
    Member
    Posted 17 years ago #

    Well I've said before how I'd do it.

    But, if you want to do it this way I'd take a look how the upgrade function works and completely copy their code. You could write your list of new blogs into a table or as an option (serialized) in the site options and then work your way through it as the upgrade script works it's way through the blog list.

    Richard

  3. drmiketemp
    Member
    Posted 17 years ago #

    So why is this a bug? You're trying to do something that WPMu wasn't designed for.

    There's a script over on the http://wpmudevorg.wordpress.com site for populating a wpmu install from a list of users. May want to check that out. I'd give you a link but I'm on a locked down terminal. I'm sure someone will take a potshot at me for not giving a link though.

  4. Vimm
    Member
    Posted 16 years ago #

    mysorehead:
    Are you referring to a WPMU version upgrade? Perhaps I should look at some other migration code and see how they did it.

    drmike:
    "You're trying to do something that WPMu wasn't designed for."

    Can you elaborate on that? I'm just trying to use WPMU to make multiple blogs....

    What I see is a function that says it makes a blog (wpmu_create_blog). Sans documentation, I expect a function to perform its namesake. In this case it works once but upon reuse leaves the database in an improper state. I can't imagine that is intentional behavior, and if so I'm extremely curious as to why.

    That script you mentioned sounds like it could be useful to look at. Here's the link:
    http://wpmudevorg.wordpress.com/project/Wordpress-WPMU-Blog-Site-Creation-Automation

    After looking it over it creates each blog by running a POST to the blog creation page. Doesn't seem as elegant to me, but it works.

    I'll go ahead and start debugging by commenting out all the MySQL error suppression and see what pops up.

  5. Vimm
    Member
    Posted 16 years ago #

    I think I got it figured out. The queries to create the new blog's tables are loaded into $wp_queries in upgrade-schema.php but it's loaded in-line, not via a function. This means it's only set once, so when you call wpmu_create_blog() a second time it still has the table values from the first time. I simply moved the declaration into a new function called populate_queries() and then call that from make_db_current_silent() in upgrade-functions.php.

    Viola! It works!

    For completeness I also added it to make_db_current().

    Is there an SVN repository for the code somewhere? Someone suggested using TortoiseSVN for making diffs and I'd be happy to diff up my changes and submit a trac ticket.

  6. Vimm
    Member
    Posted 16 years ago #

    Found the SVN, it wasn't hidden quite well enough. The ticket's made complete with diff.

    http://trac.mu.wordpress.org/ticket/394

  7. Brad101
    Member
    Posted 16 years ago #

    I've followed up from this here: http://mu.wordpress.org/forums/topic.php?id=7379&page&replies=1

    I can't seem to get Vimm's solution to work or it's not compatible with the latest version of MU. Appreciate any help.

  8. Vimm
    Member
    Posted 16 years ago #

    I've added an updated patch for WPMU 1.3. I really need to stop forgetting version numbers in my tickets.

About this Topic