Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/27/2016 05:21:20 AM (9 years ago)
Author:
r-a-y
Message:

Blogs: Improve how bp_blogs_record_existing_blogs() operates.

When the "Repopulate blogs records" is used from the "Tools > BuddyPress"
page, on large site installs, this option isn't very effective.

This commit improves bp_blogs_record_existing_blogs() by:

  • Recording an offset so the blog record repopulation can be resumed on failure.
  • Only recording the root blog for the current user if run from single site. (See #6940.)
  • Fixing issues with blog count caches.
  • Giving each blog a better last activity timestamp by using the last_updated column from the wp_blogs DB table.
  • Supporting passing selected blog IDs in case a dev wants to re-record specific blogs.

Fixes #6370.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/blogs/functions.php

    r10545 r10815  
    985985    }
    986986
     987    /**
     988     * @group bp_blogs_record_existing_blogs
     989     */
     990    public function test_bp_blogs_record_existing_blogs_limit() {
     991        if ( ! is_multisite() ) {
     992            return;
     993        }
     994
     995        $old_user = get_current_user_id();
     996
     997        $u = $this->factory->user->create();
     998        $this->set_current_user( $u );
     999
     1000        // Create three sites.
     1001        $this->factory->blog->create_many( 3, array(
     1002            'user_id' => $u
     1003        ) );
     1004
     1005        // Record each site one at a time
     1006        bp_blogs_record_existing_blogs( array(
     1007            'limit' => 1
     1008        ) );
     1009
     1010        // Assert!
     1011        $blogs = bp_blogs_get_blogs( array(
     1012            'user_id' => $u
     1013        ) );
     1014        $this->assertSame( 3, (int) $blogs['total'] );
     1015
     1016        $this->set_current_user( $old_user );
     1017    }
     1018
    9871019    protected function activity_exists_for_post( $post_id ) {
    9881020        $a = bp_activity_get( array(
Note: See TracChangeset for help on using the changeset viewer.