• I’ve got WP 3.0.5 running in a subdomain install, with the domain mapping plugin. It’s been working fine. I created up 5 blogs initially, and then installed the subdomain mapping plugin, and got it working fine. Several weeks passed, with writing and plugin isntallation/removal and all the other little changes that take place over time, and now I’m trying to create another new site, and it’s failing.

    When I look at the DB tables, the information for the new site is showing up in the Network wide tables (wp_blogs, etc) but it’s failing to create the new wp_N_posts, wp_N_comments, (etc) tables that would hold the content for that particular blog. The DB user has all privileges on the table of the blog DB, and I don’t see any explicit errors showing up in the debug.log pertaining to the table creation — though a huge number of them appear when it tries to actually *do* anything with those (non-existent) tables.

    Any ideas?

Viewing 15 replies - 16 through 30 (of 59 total)
  • Thread Starter zaneselvans

    (@zaneselvans)

    It’s like it isn’t even *trying* to create the tables, rather than trying and failing. I don’t see anything related to the table creation debug.log. Is there some way to get it to print out the $wp_queries that is being used? I uncommented several echo lines in the dbDelta function inside upgrade.php, apparently meant to output the database queries being processed, but didn’t get the output anywhere I could see.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Try making a NEW database user in SQL and give it full permissions. Then update your wp-config.php to use that?

    Thread Starter zaneselvans

    (@zaneselvans)

    Poking around some more, at the beginning dbDelta if I output the contents of $queries to the error log, I get a nice big pile of table creation SQL statements. Near the end of dbDelta though, if I output the contents of $allqueries inside the loop where the actual query execution is being done by $wpdb, it’s empty. In fact, nothing inside that foreach loop gets executed, because there’s nothing in $allqueries to iterate over. So somewhere in between the queries are getting munged to nothing.

    Thread Starter zaneselvans

    (@zaneselvans)

    My guess is it’s detecting a table name collision because it’s confused about what blog it is, and the CREATE statements are getting filtered out because that table “already exists”. Here’s one of the CREATE TABLE statements from the error log:

    [15-Apr-2011 00:29:11] CREATE TABLE wp_terms (
    term_id bigint(20) unsigned NOT NULL auto_increment,
    name varchar(200) NOT NULL default '',
    slug varchar(200) NOT NULL default '',
    term_group bigint(10) NOT NULL default 0,
    PRIMARY KEY  (term_id),
    UNIQUE KEY slug (slug),
    KEY name (name)
    ) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

    Shouldn’t it be CREATE TABLE wp_48_terms, since 48 is the current blog_id? Or is that number automatically inserted by the $wpdb object when it executes the query?

    Thread Starter zaneselvans

    (@zaneselvans)

    The line that’s nuking $cqueries (the CREATE TABLE statements) is

    unset($cqueries[strtolower($table)]);

    $table is being set by an earlier call to:

    $wpdb->get_col(‘SHOW TABLES;’)

    so it is some kind of name collision, with the appropriate blog_id not being present in the CREATE TABLE statements, it thinks you’re trying to create tables that already exist, and so skips that step. Now, *why* is that the case? Where are the table names being set, and why aren’t they getting the blog_ids?

    still giving

    (@nonegiven)

    I am coming against this same error/bug/whatever too.

    New sub-domain blogs appear in Network Admin but not in the database or blogs.dir.

    What I find strange is the link to ‘Visit’ the failed blog in Network Admin > Sites > Sites is http://example.com/wp-admin/network/sites.php not http://blog2.example.com/ as should be.

    Scouring the web, it seems this comes up often. WP-MS really should kick out some kind of error when it comes across this.

    Thanks

    Thread Starter zaneselvans

    (@zaneselvans)

    Hmm. So when I try and access $wpdb->$blog_id it appears to be unset. It’s like the DB doesn’t think it’s running in a multi-site/network environment. If I access global $blog_id it’s correct. Even if I do switch_to_blog($blog_id), using the global $blog_id, $wpdb->$blog_id is still unset. Maybe the $wpdb object is getting instantiated in the wrong context somehow?

    Thread Starter zaneselvans

    (@zaneselvans)

    That bad link (to network/sites.php) is just what happens when no URL is inserted into that link — A link to a blank URL is the same as a link to the same page you’re on.

    I tried de-activating all of my network activated plugins, and I still couldn’t create a new blog.

    Creating a new DB user with all privileges and using it instead in wp-config.php also had no effect.

    I’m going bananas here. Anybody have any suggestions?

    still giving

    (@nonegiven)

    I can only say, I am feeling the same pain …

    To add, when I look at Update Network

    I get the error:

    Warning! Problem updating . Your server may not be able to connect to sites running on it. Error message: A valid URL was not provided.

    I don’t know if this is a clue … somewhere in the box, an incorrect URL has been added?

    Where does WP-MS actually keep a record of the ID number? I delete test blogs but the ID number keeps rising.

    Thanks

    Thread Starter zaneselvans

    (@zaneselvans)

    The blog_id is stored in the wp_blogs table. It’s an auto-increment value. The DB keeps track of the ID and increments each time a new set of blog tables is created; deleting them doesn’t decrement the counter.

    Thread Starter zaneselvans

    (@zaneselvans)

    If I really want to debug this, and find out what combination of stuff is screwing it up, what’s the right way to set up a testing/debugging environment? Creating and destroying broken blogs on my live network install is not optimal…

    Thread Starter zaneselvans

    (@zaneselvans)

    I think this problem might be related to this bug: https://core.trac.wordpress.org/ticket/12028

    Looking at the $wpdb object, just before dbDelta is called, everything looks fine, but $wp_queries doesn’t have the right table prefixes in the CREATE statements. It seems like there needs to be a way to force an update of $wp_queries using the current blog or a particular $wpdb object.

    Or maybe there is a way to do this already?

    Thread Starter zaneselvans

    (@zaneselvans)

    Well, I created a little wrapper function generate_wp_queries and put a copy of the queries from schema.php in it, and used it to create my new tables, and it seems to be working fine. But it’s ugly. I put the code back to the way it was afterward to avoid any future consequences of the change.

    what’s the right way to set up a testing/debugging environment? Creating and destroying broken blogs on my live network install is not optimal…

    Then set up a local install, or one on a spare domain in a spare account, or one in a subfolder account as a subfolder setup… lots of choices.

    Thread Starter zaneselvans

    (@zaneselvans)

    It seems to be related in some way to domain mapping unfortunately (at least, I didn’t have any trouble setting up additional blogs before I started domain mapping them, and some combination of turning mapping on and off seemed to resolve the issue temporarily last time I ran into the problem) and that doesn’t seem like an easy thing to play with in a local install.

    Though searching around it seems like there are a variety of instances in which this problem ($wp_queries not reflecting the appropriate tables) has come up, so I think it’s a more general problem, that’s probably better solved by providing an explicit query generation function, as suggested in the trac ticket, rather than relying on the global $wp_queries always having the right context when it’s defined.

Viewing 15 replies - 16 through 30 (of 59 total)
  • The topic ‘DB tables for new subdomain site fail to get created’ is closed to new replies.