Skip to:
Content

BuddyPress.org

Changeset 9839


Ignore:
Timestamp:
05/06/2015 04:36:24 AM (7 years ago)
Author:
r-a-y
Message:

Blogs: Delete blogmeta cache when editing a site on the "Network Admin > Sites" page.

Fixes an issue with the blog domain / path not being updated to reflect the
new domain / path for activity action links related to the updated site.

Fixes #6365.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-functions.php

    r9819 r9839  
    410410
    411411/**
     412 * Deletes the 'url' blogmeta for a site.
     413 *
     414 * Hooked to 'refresh_blog_details', which is notably used when editing a site
     415 * under "Network Admin > Sites".
     416 *
     417 * @since BuddyPress (2.3.0)
     418 *
     419 * @param int $site_id The site ID
     420 */
     421function bp_blogs_delete_url_blogmeta( $site_id = 0 ) {
     422    bp_blogs_delete_blogmeta( (int) $site_id, 'url' );
     423}
     424add_action( 'refresh_blog_details', 'bp_blogs_delete_url_blogmeta' );
     425
     426/**
    412427 * Record activity metadata about a published blog post.
    413428 *
  • trunk/tests/phpunit/testcases/blogs/cache.php

    r9819 r9839  
    289289        $this->assertEquals( 1, bp_blogs_total_blogs() );
    290290    }
     291
     292    /**
     293     * @group update_blog_details
     294     */
     295    public function test_update_blog_details_should_purge_blogmeta_cache() {
     296        if ( ! is_multisite() ) {
     297            return;
     298        }
     299
     300        $u = $this->factory->user->create();
     301
     302        $b1 = $this->factory->blog->create();
     303        bp_blogs_record_blog( $b1, $u, true );
     304
     305        // prime cache
     306        bp_blogs_get_blogmeta( $b1, 'url' );
     307        $this->assertNotEmpty( wp_cache_get( $b1, 'blog_meta' ) );
     308
     309        // updating blog details should purge cache
     310        update_blog_details( $b1, array(
     311            'domain' => 'awesome.com'
     312        ) );
     313
     314        // assert cache is purged
     315        $this->assertEmpty( wp_cache_get( $b1, 'blog_meta' ) );
     316    }
    291317}
Note: See TracChangeset for help on using the changeset viewer.