Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/18/2022 11:06:15 PM (3 years ago)
Author:
r-a-y
Message:

Blogs: Fix pagination in BP_Blogs_Blog::get().

As part of #8488, we refactored BP_Blogs_Blog::get() to use an array
as the main function argument instead of passing multiple function
arguments.

In BP_Blogs_Blog::get(), the "per page" argument was previously
$limit, while in bp_blogs_get_blogs(), the "per page" argument
passed to BP_Blogs_Blog::get() is $r['per_page']. When swapping
over to the array function argument, $r['limit'] does not exist,
which broke pagination and would return all blogs instead.

This commit fixes the pagination problem by renaming the array key
from $r['limit'] to $r['per_page'].

Props imath.

Fixes #8633 (trunk)

File:
1 edited

Legend:

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

    r13184 r13236  
    12541254 * @see BP_Blogs_Blog::get() for a description of parameters and return values.
    12551255 *
    1256  * @param int|null $limit See {@BP_Blogs_Blog::get()}.
     1256 * @param int|null $per_page See {@BP_Blogs_Blog::get()}.
    12571257 * @param int|null $page  See {@BP_Blogs_Blog::get()}.
    12581258 * @return array See {@BP_Blogs_Blog::get()}.
    12591259 */
    1260 function bp_blogs_get_random_blogs( $limit = null, $page = null ) {
     1260function bp_blogs_get_random_blogs( $per_page = null, $page = null ) {
    12611261    return BP_Blogs_Blog::get(
    12621262        array(
    1263             'type'  => 'random',
    1264             'limit' => $limit,
    1265             'page'  => $page
     1263            'type'     => 'random',
     1264            'per_page' => $per_page,
     1265            'page'     => $page
    12661266        )
    12671267    );
Note: See TracChangeset for help on using the changeset viewer.