Multi-DB 2.7.1 does not delete some tables when you delete a blog

Hi,

I am still testing Multi-DB, version 2.7.1 suppose to fix this issue, but not for me!

to make sure, I create a fresh MU Install (also 2.7.1) – created few blogs and then tried to delete, visually blog is removed since its removed from the global tables but all blog specific tables are left in the database..

_comments

_links

_options

_….

I am using 16 db config

  • Barry
    • DEV MAN’s Mascot

    Hi

    Thanks for the heads up, we are using a slightly modified version over at blogs.mu that removes the tables correctly. I will do a check for relevant differences and post the changes required here until we can get a new version of the multi-db class up for download.

    Rgds

    Barry

  • scharles
    • WPMU DEV Initiate

    Update:

    After debugging a bit I noticed that $drop_tables on line 50 of mu.php is empty!

    And surely that’s why the blog tables does not get deleted.

    Dont you think its related to Multi-DB?

    Basically show tables fails here "$drop_tables = $wpdb->get_results("show tables LIKE ‘". $wpdb->base_prefix . $blog_id . "_%’", ARRAY_A);"

    I am very new to WPMU, and PHP so I might be wrong here.

  • Barry
    • DEV MAN’s Mascot

    I think it may be the multi-db system, or more specifically a combination of that and the strangely formated sql statement used in the delete_blog function.

    "SHOW TABLES LIKE ‘WP_1_%’

    Give me a few minutes and I’ll track down the required changes

  • scharles
    • WPMU DEV Initiate

    Ok, I found the problem.

    Here: $drop_tables = $wpdb->get_results("show tables LIKE ‘". $wpdb->base_prefix . $blog_id . "_%’", ARRAY_A);

    My osx server php engine seems to parse "_%" differently as it might on other OS’s, it does not see "" as an escape and simply create an invalid query "show tables LIKE ‘wp_3_%’" resulting in this warning "PHP Warning: reset() [function.reset]: Passed variable is not an array or object in /Library/WebServer/Documents/broadkast/wp-admin/includes/mu.php on line 51"

    I had to remove and from the query to make it work on osx panther.

    I just wanted to post here anyways, I know this is a WPMU issue and not a Multi-DB – atleast I know now :wink:

    Cheers,

    Sam

  • Barry
    • DEV MAN’s Mascot

    Removing the is certainly part of the solution, not 100% sure why it is in the query in the first place. I have certainly never come across that SQL syntax before.

    The other part is to edit the following lines in db.php:

    Line 929 should become:

    preg_match("|[0-9]{1,20}_?|",$base_table_name,$base_match);

    Line 931 should become:

    if(preg_match("|" . $original_table_prefix . "[0-9]{1,20}_?" . $base_table_name . "|",$match,$match) == true) {

    Note the only changes to those two lines from the originals is a ? added towards the end of each preg_match string.