Changes to bp_has_activities() queries in BP 2.1

Activity queries were largely overhauled in BuddyPress 2.0, leading to major performance improvements. These improvements were focused on the paginated query, the SELECT that contained a LIMIT clause based on the per_page value. The remaining bottleneck for activity pages on large installations was the other SELECT COUNT(*) query performed in BP_Activity_Activity::get() to get the total number of items matching the query params, a query that is much less amenable to optimization. The kicker is that the value returned by this query is almost never used in BuddyPress; the most common use for the total count figure is to generate pagination HTML, but by default, BuddyPress does not show true pagination for activity anywhere on the front end – just a generic “Load More” button at the bottom of the stream.

BuddyPress 2.1 will include changes to address this bottleneck. (See #5629 and r8491.) The SELECT COUNT(*) query will no longer take place by default, and the logic for displaying the “Load More” button has been altered to work without this query. Most sites will not notice any difference (except for the increase in speed!). However, there are a few cases where developers may need to make modifications to preserve some functionality:

  • noscript support – The “Load More” button on activity page uses Javascript. To cover browsers with JS disabled, a <noscript> block appeared in the activity-loop.php template that contained traditional pagination markup. This pagination will no longer generate properly as of BP 2.1. In BP’s bp-legacy templates, we have removed the <noscript> block and altered the “Load More” href to be populated by bp_activity_load_more_link(). However, if your theme is a bp-default derivative, or if you have overridden activity-loop.php in your theme, you will need to make the mods yourself to support non-JS browsers. Either reproduce the core change, or add count_total=count_query to the bp_has_activities() arguments.
  • Custom activity queries – If you have built a plugin or another customization that uses BP’s activity query functions (bp_has_activities(), bp_activity_get(), BP_Activity_Activity::get()), and if your customization relies on the 'total' or 'total_activity_count' value, you’ll need to make the necessary modifications to work properly with BP 2.1. In most cases, this just means passing 'count_total' => 'count_query' as one of the function args.

Apologies to those for whom this will cause an inconvenience – normally we try not to break backward compatibility for any reason, but it was impossible to ensure that all installations would receive the performance benefits without affecting a certain subset of installations (we did try to minimize impact).

Questions? Please ask in the comments below.

#activity, #bp_activity_activity, #bp_activity_get, #bp_has_activities

Quick #2.1 update: we’re still…

Quick #2.1 update: we’re still scoping out the big-ticket items for 2.1, and should have more to confirm on in the next week or so, but as of yesterday (May 14th), the 2.1 dev cycle has formally kicked off. Here are the dates for this release’s milestones that we agreed on:

1) “merge” deadline (when major features should be in): July 9th 2014
2) beta: August 6th 2014
3) release: August 27th 2014

If you’re looking to get involved and contribute to BuddyPress, or just learn a bit more about what that entails, I’ll be posting a recap on this blog within the next week, with some easy and productive ways you can help us build and support BuddyPress 2.1.

Attachments in BuddyPress

We all know there’s a lot of expectations about adding a “media feature” to BuddyPress core. Team wants to do the right choices about it so this feature behave nicely with existing plugins dealing in this area, and so that custom components will be able to use it for their particular needs.

For a detailled story of our discussions, you can check the trac ticket 5429.

During the 2.0 dev-cycle, we’ve decided to move this feature into a plugin.

A month ago, i’ve published the very first version of BP Attachments: a component to help others deal with media/files. This version is available on github and we are very interested by your feedbacks/contributions about it.

This plugin is requiring at least BuddyPress 2.0 and WordPress 3.9.

The github repository also includes a wiki where i’ve described how to install/activate it and the way it works. So far the plugin can deal with Group and Member’s attachments & avatars.

If you’re dreaming about having such a feature in BuddyPress, help us make it come true!

Get involved:

  • you can simply test it, report bugs, enhancements, or thoughts.
  • as a plugin author, you can help us check there are no conflicts (such as duplicate names in functions)
  • if you want to join the adventure by pulling requests or suggesting patches, that would be awesome!

Usefull links:

BP 2.0.1 is out: http://buddypress.org/2014/05/buddypress-2-0-1/

BP 2.0.1 is out: http://buddypress.org/2014/05/buddypress-2-0-1/

Using bp_parse_args() to filter BuddyPress template loops

In BuddyPress 2.0, one of the coolest things for developers is the bp_parse_args() function.  This function is copied over from our cousin, bbPress.

What this allows developers is the chance to filter various parameters before they are passed for further rendering.

I’ve just created a codex article explaining how to use bp_parse_args() to filter BP’s template loops here:

http://codex.buddypress.org/plugindev/using-bp_parse_args-to-filter-buddypress-template-loops/

If anyone has any questions about the codex article, please drop a comment below and I’ll try to answer it.

Now, go and read the codex and grab a slice of pizza!

#2-0

BuddyPress 2.0 “Juliana” has been…

BuddyPress 2.0 “Juliana” has been released: http://buddypress.org/2014/04/buddypress-2-0-juliana/

Special thanks to the readers of this blog who have helped with development and testing during this dev period. Go enjoy a slice of pizza!

Grunt coming to BuddyPress after 2.0 release

Shortly after BuddyPress 2.0 is released, we’re going to be updating BuddyPress’ development trunk (buddypress.svn.wordpress.org/trunk) to a Grunt-powered build system. Most people won’t even notice, but for developers and contributors, this means a small workflow change.

TL;DR – keep reading if:

  • You develop plugins for BuddyPress
  • You are a core contributor
  • You run a checkout of trunk on a production site

Continue reading

#2-0, #2-1, #grunt