Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/09/2015 04:06:51 PM (10 years ago)
Author:
boonebgorges
Message:

Search consistently against blog title and description in BP_Blogs_Blog::get().

Previously, the description field was only being matched for the 'total' query,
with the result that pagination and other count-based results did not match the
blogs actually returned by the query.

This changeset reworks the syntax a bit, to avoid the duplicated logic when
using search terms, and to use proper JOIN syntax instead of commas.

Props jreeve.
Fixes #5858.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/blogs/class-bp-blogs-blog.php

    r9139 r9328  
    3838
    3939        $this->set_current_user( $old_user );
     40        wpmu_delete_blog( $b, true );
     41    }
     42
     43    /**
     44     * @ticket BP5858
     45     */
     46    public function test_get_with_search_terms_should_match_description() {
     47        if ( ! is_multisite() ) {
     48            return;
     49        }
     50
     51        $old_user = get_current_user_id();
     52
     53        $u = $this->factory->user->create();
     54        $this->set_current_user( $u );
     55        $b = $this->factory->blog->create( array(
     56            'title' => 'The Foo Bar Blog',
     57            'domain' => __METHOD__,
     58            'user_id' => $u,
     59        ) );
     60        update_blog_option( $b, 'blogdescription', 'Full of foorificness' );
     61        bp_blogs_record_existing_blogs();
     62
     63        // make the blog public or it won't turn up in generic results
     64        update_blog_option( $b, 'blog_public', '1' );
     65
     66        $blogs = BP_Blogs_Blog::get( 'active', false, false, 0, 'Full' );
     67        $blog_ids = wp_list_pluck( $blogs['blogs'], 'blog_id' );
     68
     69        $this->assertEquals( array( $b ), $blog_ids );
     70        $this->assertEquals( 1, $blogs['total'] );
     71
     72        $this->set_current_user( $old_user );
     73        wpmu_delete_blog( $b, true );
    4074    }
    4175
     
    6599
    66100        $this->set_current_user( $old_user );
     101        wpmu_delete_blog( $b, true );
    67102    }
    68103
     
    95130
    96131        $this->set_current_user( $old_user );
     132        wpmu_delete_blog( $b, true );
    97133    }
    98134}
Note: See TracChangeset for help on using the changeset viewer.