The MU forums have moved to WordPress.org

What is global_terms and why is it messing my categories up to no end? (4 posts)

  1. re5et
    Member
    Posted 14 years ago #

    Every time I update a category it loses all of its children, which are seemingly just gone. I was quite lucky to run into this in development instead of on the production site.

    I followed the code from the admin where the 'editedcat' action takes place in /wp-admin/categories.php, then to the wp_update_category function in /wp-admin/includes/taxonomy.php, then to the wp_insert_category function in the same file, then to wp_update_term function in /wp-includes/taxonomy.php and finally down to the following line in that function:

    $term_id = apply_filters('term_id_filter', $term_id, $tt_id);

    In my example the category coming in to be edited was '8', a var_dump of $term_id and $tt_id showed

    int(8) string(1) "8"

    before the filter ran, and then after it showed:

    int(25) string(1) "8"

    And then every child category of 8 was reporting its parent category as 25, which i assume is because the category i was editing did indeed have an id of 25 in wp_sitecategories, but its id remained the same ( 8 ) in what appears to being used for the code on that blog when category selection is done, both in the admin, and the general loop. All of its children went to some other parent.

    After some debugging, it appears that the global_terms function in /wp-includes/wpmu-functions.php which is added as a filter by /wp-includes/wpmu-default-filters.php

    In any case, its ridiculously screwed up now.

    I have commented out the line that adds the filter in /wp-includes/wpmu-default-filters.php because it only seemed to be doing harm. I can now update categories without all of the sub-cats / posts disappearing at least. Which leads me to a couple of questions:

    1] What is the name of goodness is going on with the global_terms filter
    2] and can expect any other backlash that anyone can think of by commenting that out?

  2. re5et
    Member
    Posted 14 years ago #

    How is it possible that I am the only one this has affected?

    Anyone else experience anything like this?

  3. elebail
    Member
    Posted 14 years ago #

    Hello,

    I have the same problem With WPMU 2.8.6.

    I'm also looking for a solution.

    Regards,
    Eric

  4. elebail
    Member
    Posted 14 years ago #

    Hello,

    After more search I found why there is that Filter.

    The main goal of this filter is: In WPMU you have more X blogs.
    This filter update the category ID to set the same ID for all the categories with the same slug on all the blogs.

    For exemple the "test" category will have the same ID on all the blogs.

    I posted a solution on topic:
    http://mu.wordpress.org/forums/topic/11389

    Regrads,
    Eric Le Bail

About this Topic