Multi db and MuTags0.2b

Hi.
I had used the MuTags0.2b plugin and then made the Multi db change.
Although I defined the additional wp_global_tags tags the MuTags didn't work.

This is the solution I found in case some of you have the same problem.

You have to do the following changes:
1. File wp-includes/wp-db.php, in order to add the global_tags table as a table located into the main database
Change the Line ~216
if( $this->blogs != '' && preg_match("/(" . $this->blogs . "|" . $this->users . "|" . $this->usermeta . "|" . $this->site . "|" . $this->sitemeta . "|" . $this->sitecategories . ")/i",$query) ) {

with

if( $this->blogs != '' && preg_match("/(" . $this->blogs . "|" . $this->users . "|" . $this->usermeta . "|" . $this->site . "|" . $this->global_tags . "|" . $this->sitemeta . "|" . $this->sitecategories . ")/i",$query) ) {

2. File /wp-content/mu-plugins/MuTags.php
~ ln 484 change the function mu_query with this:

function mu_query($blog_id, $term_id, $post_date, $post_ID, $taxonomy) {
global $wpdb;
$sql_query =$wpdb->get_results("INSERT IGNORE INTO $this->dbtable
(tag_id, blog_id, post_id, post_date, taxonomy)
VALUES
('$term_id', '$blog_id', '$post_ID', '$post_date', '$taxonomy')");
return $sql_query;
}

3. Same File /wp-content/mu-plugins/MuTags.php
ln 501 change the function mu_delete_post with this:
function mu_delete_post($post_ID) {
global $blog_id;
global $wpdb;
$post_type = get_post_field('post_type', $post_ID);
$post_status = get_post_field('post_status', $post_ID);

if ($post_type = 'post') {
$sql_query = $wpdb->get_results("DELETE FROM $this->dbtable
WHERE post_id = $post_ID
AND blog_id = $blog_id");
}
}

4. Same File /wp-content/mu-plugins/MuTags.php
ln 739 -752 on function ImportWptags
Changes these lines with the following

if($type == 'tags') {
$delete = $wpdb->get_results("DELETE FROM $this->dbtable WHERE taxonomy <> '1'");
$taxonomy = "post_tag";
$taxonomyid = "0";
}
if($type == 'cats') {
$delete = $wpdb->get_results("DELETE FROM $this->dbtable WHERE taxonomy <> '0'");
$taxonomy = "category";
$taxonomyid = "1";
}

5. If you still get errors or no results, you should also comment the line 766 die('There was an error');

Hope this is helpful to someone.

Cheers
Lena

  • stergatu
    • Site Builder, Child of Zeus

    Yes, I did and the table wp_global_tags was moved into the global database as it should be.
    The problem was that it didn't got updated with the data of new posts

    The problem was occured for 2 reasons:

    1. wp-db.php has hardcoded the tables which should considerd as globals on line Line ~216.
    I guess this is very easy to change be simple adding a foreach look for the global tables.

    2. MuTags v0.6 in the above functions didn't use the $wpdb parameter for the queries and so the database didn't switch to the global as it should be for the inserts, updates, deletes of the global_tags.
    The only changes I did there were to add the $wpdb as global parameters and change the query to $wpdb->get results etc.

    P.S.
    Same case as MuTags is the Counterize plugin.

    Lena

  • drmike
    • DEV MAN’s Mascot

    MuTags v0.6 in the above functions didn't use the $wpdb parameter for the queries

    We had the same problem with the yellow swordfish forums plugin as it's hardcoded for the usermeta tables. I forget why but the author siad it was done for a reason. You have to edit a couple of lines and rehardcode it.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.