Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    Oops. Trying again:

    /**
    * In WP 3.5+, get_blogs_of_user() is much slower than in previous versions. As
    * a result, if you have a certain number of blogs, running get_blogs_of_user()
    * will create a memory timeout. This is a particular problem because
    * get_blogs_of_user() is called on every page, because of the toolbar.
    *
    * Ideally, there would be a way to short-circuit get_blogs_of_user(), or even
    * to prevent WordPress from calling get_blogs_of_user() while loading the
    * toolbar. But there is not. As a workaround, this function intercepts a key
    * step in get_blogs_of_user() – the get_user_meta() call that gets all of a
    * user’s metadata. If we determine that this request is coming from
    * get_blogs_of_user() (which we do by examining the debug_backtrace(), a truly
    * awful technique), AND that it’s one of the generic meta queries used by
    * get_blogs_of_user(), AND that the current user has more than 75 blogs, THEN
    * we strip all of the blog capability keys from the array of metadata,
    * tricking get_blogs_of_user() into thinking that the current user has no
    * blogs at all.
    */
    function bbg_admin_bar_hack( $check, $object_id, $meta_key, $single ) {
    // Only fire when looking at get_user_meta() with no params
    if ( ! $meta_key ) {

    // check to see whether this came from get_blogs_of_user()
    $db = debug_backtrace();
    $is_get_blogs_of_user = false;
    foreach ( $db as $dbk => $dbv ) {
    if ( ‘get_blogs_of_user’ == $dbv['function'] ) {
    $is_get_blogs_of_user = true;
    break;
    }
    }

    if ( $is_get_blogs_of_user ) {
    // Get the real metadata, but don’t recurse
    remove_filter( ‘get_user_metadata’, ‘bbg_admin_bar_hack’, 10, 4 );
    $meta = get_user_meta( $object_id );
    add_filter( ‘get_user_metadata’, ‘bbg_admin_bar_hack’, 10, 4 );

    // How many blogs does this user have?
    static $blog_count_of_user;
    if ( ! isset( $blog_count_of_user ) && is_user_logged_in() ) {
    $blog_count_of_user = 0;
    foreach ( $meta as $mk => $mv ) {
    if ( ‘capabilities’ === substr( $mk, -12 ) ) {
    $blog_count_of_user++;
    }
    }
    }

    // We only care about those with counts > 75
    if ( $blog_count_of_user > 75 ) {
    static $clean_keys;
    if ( isset( $clean_keys ) ) {
    return $clean_keys;
    } else {
    foreach ( $meta as $mk => $mv ) {
    if ( ‘capabilities’ === substr( $mk, -12 ) ) {
    unset( $meta[ $mk ] );
    }
    }

    $clean_keys = $meta;
    return $meta;
    }
    }
    }

    }

    return $check;
    }
    add_filter( ‘get_user_metadata’, ‘bbg_admin_bar_hack’, 10, 4 );

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    @boone figured this out for me, and hacked together a fix which I’ve pasted below.

    `

    $dbv ) {
    if ( ‘get_blogs_of_user’ == $dbv['function'] ) {
    $is_get_blogs_of_user = true;
    break;
    }
    }

    if ( $is_get_blogs_of_user ) {
    // Get the real metadata, but don’t recurse
    remove_filter( ‘get_user_metadata’, ‘bbg_admin_bar_hack’, 10, 4 );
    $meta = get_user_meta( $object_id );
    add_filter( ‘get_user_metadata’, ‘bbg_admin_bar_hack’, 10, 4 );

    // How many blogs does this user have?
    static $blog_count_of_user;
    if ( ! isset( $blog_count_of_user ) && is_user_logged_in() ) {
    $blog_count_of_user = 0;
    foreach ( $meta as $mk => $mv ) {
    if ( ‘capabilities’ === substr( $mk, -12 ) ) {
    $blog_count_of_user++;
    }
    }
    }

    // We only care about those with counts > 75
    if ( $blog_count_of_user > 75 ) {
    static $clean_keys;
    if ( isset( $clean_keys ) ) {
    return $clean_keys;
    } else {
    foreach ( $meta as $mk => $mv ) {
    if ( ‘capabilities’ === substr( $mk, -12 ) ) {
    unset( $meta[ $mk ] );
    }
    }

    $clean_keys = $meta;
    return $meta;
    }
    }
    }

    }

    return $check;
    }
    add_filter( ‘get_user_metadata’, ‘bbg_admin_bar_hack’, 10, 4 );

    `

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    Yeah, I realize all that. It was a temporary step. In php.ini it’s 128m and it’s been fine. This just helped me figure out where the problem lay if not how to solve it.

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    I ultimately discovered some additional issues: search (members and sites) was not working in Chrome and FF (but was in Safari), and I was unable to click through to subsequent pages on site and member listings… spinning wheel and all that. This wasn’t true all of the time, but was most of the time.

    I tracked the problem down to the fact that we were requiring SSL Admin on our install… changed that to SSL Login, and the problem resolved. Curious if anyone else has this issue as well…

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    I should note I tried the bp-default theme, and deactivated all other plugins.

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    Thanks a bunch for responding… all profile activity on this site is behind login, so a link wouldn’t get you to where the error is. Do you have any suggested tests?

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    Thanks, Paul– I hadn’t clicked into edit existing fields so didn’t see the toggles there.

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    What was it?

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    Fixed:

    `
    function DisplayedUserEmail() {
    global $bp;
    echo ‘

    ‘ . ‘
    ‘ . ‘

    ‘ . ‘

    ‘ . ‘

    ‘ . ‘Email Address: ‘ . ‘ ‘ . $bp->displayed_user->userdata->user_email . ‘

    ‘ . ‘

    ‘;
    }

    add_action( ‘bp_after_profile_field_content’, ‘DisplayedUserEmail’ );
    `

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    I get “There was an error when creating the topic” when the group is public, and “Sorry, there were no forum topics found” when I then click on “Forums.” If I switch settings to private/hidden, all the test forum posts reappear.

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    (that trick didn’t work for me… now running 3.1.1 and 1.2.8)

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    bumpitty bump bump

    Avatar of lwaltzer
    lwaltzer
    Participant

    @lwaltzer

    Bump. And glad I’m not the only one who’s getting this. :)

    @Paul I’m getting the latter activation URL. And, though BP runs only on one blog, it’s only Network Activate-able as a plugin.

    *update*: It’s a WordPress core bug: http://core.trac.wordpress.org/ticket/14718

Viewing 13 replies - 1 through 13 (of 13 total)