Skip to:
Content

BuddyPress.org

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#8633 closed defect (bug) (fixed)

Pagination broken in `BP_Blogs_Blog::get()`

Reported by: r-a-y's profile r-a-y Owned by: r-a-y's profile r-a-y
Milestone: 10.1.0 Priority: normal
Severity: major Version: 10.0.0
Component: Blogs Keywords: has-patch
Cc:

Description

In #8488, date queries were added for the blogs component. Also some refactoring was done to the blogs stack so we could pass an array instead of multiple function arguments.

There is a bug during the refactoring that broke pagination when fetching the blogs loop (apologies!). For large sites, this can cause timeouts on the Sites Directory.

In BP_Blogs_Blog::get(), the "per page" argument was previously $limit, while in bp_blogs_get_blogs(), the "per page" argument is $r['per_page']. When swapping to the function array, $r['limit'] doesn't exist, which caused no pagination 😅

I've attached a patch, which fixes this issue.

Attachments (1)

8633.01.patch (2.6 KB) - added by r-a-y 2 years ago.

Download all attachments as: .zip

Change History (6)

@r-a-y
2 years ago

#1 @imath
2 years ago

Hi @r-a-y thanks a lot for your patch, it looks good, I'm just wondering if you missed a $limit replacement in the bp_blogs_get_random_blogs() function, could you look at it. Otherwise, it's good to be committed to me 👍

#2 @r-a-y
2 years ago

I'm just wondering if you missed a $limit replacement in the bp_blogs_get_random_blogs() function, could you look at it.

Ahh, yes. I did miss this replacement. Will add it in when I commit it.

This ticket was mentioned in Slack in #buddypress by imath. View the logs.


2 years ago

#4 @r-a-y
2 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 13235:

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 (10-branch)

#5 @r-a-y
2 years ago

In 13236:

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)

Note: See TracTickets for help on using tickets.