[buddypress-trac] [BuddyPress Trac] #6059: BP_Activity_Activity:get() doesn't respect 'max' parameter
buddypress-trac
noreply at wordpress.org
Mon Dec 8 21:56:13 UTC 2014
#6059: BP_Activity_Activity:get() doesn't respect 'max' parameter
--------------------------+------------------------------
Reporter: dcavins | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Activity | Version:
Severity: minor | Resolution:
Keywords: |
--------------------------+------------------------------
Changes (by dcavins):
* cc: david.cavins@… (added)
Comment:
Here are some examples of how "max" is currently used:
** Activity **
`bp_has_activities()` accepts a max and plugs it in for per_page sometimes
{{{
// Do not exceed the maximum per page
if ( !empty( $max ) && ( (int) $per_page > (int) $max ) )
$per_page = $max;
}}}
`BP_Activity_Activity:get()` uses max to modify the found-items count
only.
** Blogs **
`bp_has_blogs()` allows max to override per_page in some cases.
{{{
// Set per_page to maximum if max is enforced
if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int)
$r['max'] ) ) {
$r['per_page'] = (int) $r['max'];
}
}}}
`BP_Blogs_Blog::get()`, `search_blogs()` don't have a 'max' parameter
{{{
* @param int|bool $limit Optional. The maximum records to return.
* Default: false.
* @param int|bool $page Optional. The page of records to return.
* Default: false (unlimited results).
}}}
$limit here is used like 'per_page':
{{{
$pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d",
intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';
}}}
** Friends, Members **
`bp_has_members()` accepts a max and uses it like `bp_has_blogs()` (the
comment is incorrect):
{{{
// Set per_page to max if max is larger than per_page
if ( !empty( $r['max'] ) && ( $r['per_page'] > $r['max'] ) ) {
$r['per_page'] = $r['max'];
}
}}}
`BP_Friends_Friendship::search_friends()`: 'Limit' is used as per_page.
`BP_User_Query` doesn't accept max. It accepts page and per_page.
** Groups **
`bp_has_groups()` accepts max and passes the unmodified value to
`BP_Groups_Template`.
`BP_Groups_Template::__construct` accepts 'max' and uses it only to modify
the found-group count.
`BP_Groups_Group::filter_user_groups()`, `search_groups()`: 'Limit' is
used as per_page.
`BP_Groups_Group::get()` doesn't accept a max. Uses 'per-page' and 'page'.
{{{
* @type int $per_page Optional. Number of items to return per
page
* of results. Default: null (no limit).
* @type int $page Optional. Page offset of results to return.
* Default: null (no limit).
}}}
`BP_Groups_Membership_Requests_Template` uses 'max' only to modify the
found-group count.
** Messages **
`bp_has_message_threads()` accepts max and passes the unmodified value to
`BP_Messages_Box_Template`.
`BP_Messages_Box_Template` accepts a 'max' which is used to modify the
found-messages count only.
** Notifications **
`bp_has_notifications()` accepts 'max' but adds this brutally honest note:
{{{
// these are additional arguments that are not available in
// BP_Notifications_Notification::get()
'max' => false,
}}}
`BP_Notifications_Template` accepts a 'max' which is used to modify the
found-messages count only.
----
I dug around in the logs, but couldn't get a handle on any big thoughts.
It was interesting to go through a bunch of commits found by git pickaxe,
though. It seems like the more recently remodeled code doesn't use 'max'
at all--`BP_User_Query` and `bp_has_notifications()` for instance.
In my case, I was hoping to use the max arg with `bp_activity_get()` to
find certain activity items to exclude from
`bp_legacy_theme_ajax_querystring`. But I didn't need every result, just
the first hundred or so out of the possible tens of thousands. So "max"
makes sense to me in a utility function like `bp_activity_get()`, but
less so in `bp_has_activities()` which is meant to be used as a loop.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6059#comment:2>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list