Skip to:
Content

BuddyPress.org

Changeset 9354


Ignore:
Timestamp:
01/13/2015 10:14:37 PM (9 years ago)
Author:
imath
Message:

Make sure sorting blogs alphabetically is fetching items

Since r9328 we have changed the table aliases used in the sql query to get the blogs, but we forgot to edit the order clause so that the alphabetical type uses the new table alias (bm_name).

Fixes #6118

Location:
trunk
Files:
2 edited

Legend:

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

    r9351 r9354  
    157157                break;
    158158            case 'alphabetical':
    159                 $order_sql = "ORDER BY bm2.meta_value ASC";
     159                $order_sql = "ORDER BY bm_name.meta_value ASC";
    160160                break;
    161161            case 'newest':
  • trunk/tests/phpunit/testcases/blogs/class-bp-blogs-blog.php

    r9328 r9354  
    132132        wpmu_delete_blog( $b, true );
    133133    }
     134
     135    /**
     136     * @group get_order_by
     137     */
     138    public function test_get_order_by() {
     139        if ( ! is_multisite() ) {
     140            return;
     141        }
     142
     143        $old_user = get_current_user_id();
     144
     145        $u = $this->factory->user->create();
     146        $this->set_current_user( $u );
     147        $bs = array(
     148            'foobar' => $this->factory->blog->create( array(
     149                'title' => 'Foo Bar Blog',
     150                'user_id' => $u,
     151                'path' => '/path' . rand() . time() . '/',
     152            ) ),
     153            'barfoo' => $this->factory->blog->create( array(
     154                'title' => 'Bar foo Blog',
     155                'user_id' => $u,
     156                'path' => '/path' . rand() . time() . '/',
     157            ) ),
     158        );
     159
     160        bp_blogs_record_existing_blogs();
     161
     162        // make the blog public or it won't turn up in generic results
     163        foreach ( $bs as $b ) {
     164            update_blog_option( $b, 'blog_public', '1' );
     165        }
     166
     167        // Used to make sure barfoo is older than foobar
     168        $b_time = date_i18n( 'Y-m-d H:i:s', strtotime( '-5 minutes' ) );
     169
     170        /* Alphabetical */
     171        $blogs = BP_Blogs_Blog::get( 'alphabetical', false, false, $u );
     172        $blog_ids = wp_list_pluck( $blogs['blogs'], 'blog_id' );
     173        $this->assertEquals( array( $bs['barfoo'], $bs['foobar'] ), $blog_ids );
     174
     175        /* Newest */
     176        update_blog_details( $bs['barfoo'], array( 'registered' => $b_time ) );
     177        $blogs = BP_Blogs_Blog::get( 'newest', false, false, $u );
     178        $blog_ids = wp_list_pluck( $blogs['blogs'], 'blog_id' );
     179        $this->assertEquals( array( $bs['foobar'], $bs['barfoo'] ), $blog_ids );
     180
     181        /* Active */
     182        bp_blogs_update_blogmeta( $bs['barfoo'], 'last_activity', $b_time );
     183        $blogs = BP_Blogs_Blog::get( 'active', false, false, $u );
     184        $blog_ids = wp_list_pluck( $blogs['blogs'], 'blog_id' );
     185        $this->assertEquals( array( $bs['foobar'],$bs['barfoo'] ), $blog_ids );
     186
     187        /* Random */
     188        $blogs = BP_Blogs_Blog::get( 'random', false, false, $u );
     189        $this->assertTrue( 2 == count( $blogs['blogs'] ) );
     190
     191        $this->set_current_user( $old_user );
     192
     193        foreach ( $bs as $d ) {
     194            wpmu_delete_blog( $d, true );
     195        }
     196    }
    134197}
Note: See TracChangeset for help on using the changeset viewer.