Skip to:

Opened 2 months ago

Closed 3 weeks ago

#9136 closed defect (bug) (fixed)

Blogs loop not working property when blog has no description

Reported by: lenasterg's profile lenasterg Owned by: imath's profile imath
Milestone: 14.0.0 Priority: normal
Severity: normal Version:
Component: Blogs Keywords: has-patch 2nd-opinion


I noticed that the queries used in bp-blogs/classes/class-bp-blogs-blog.php
in lines
and don't
return blogs that don't have a 'description'.
Also due to many LEFT JOINS the queries for largescale installations are slow.
In the proposed pull request,
the LEFT JOIN for bm_description:

  • is needed only if we have search_terms
  • it uses LEFT JOIN ... ON (b.blog_id = bm_description.blog_id AND bm_description.meta_key = 'description') so if a blog doesn't have a description in wp_bp_user_blogs_blogmeta it will be included in the results


Change History (6)

This ticket was mentioned in PR #272 on buddypress/buddypress by @lenasterg.

2 months ago

  • Keywords has-patch added

This patch:

  • Uses one less LEFT JOIN when we don't use any search terms for blogs.
  • Blogs which don't have a description in wp_bp_user_blogs_blogmeta it will also be included in the results.

Trac ticket:

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

6 weeks ago

#3 @imath
6 weeks ago

  • Milestone changed from Awaiting Review to 14.0.0

Thanks for reminding this ticket in Slack @lenasterg I doubt we can include the fix into 12.5 but I’ll check it for sure during 14.0.0 dev cycle.

#4 @imath
4 weeks ago

  • Keywords 2nd-opinion added

Hi @lenasterg

I've looked into this. With a regular BuddyPress usage, I can't reproduce and the unit tests we perform after each PR or commit can't too.

We do not provide any UI or ways to edit records we have into the wp_bp_user_blogs_blogmeta table. Data are simply there to have a single table to get all sites options which are in many wp_{site_id}_options table in a WordPress multisite config.

These records are updated each time you update a site option from the WordPress General option screen for example.

So the description blogmeta always exists. It can only be empty if the site has no description, but even in this case sites with empty descriptions are included into results.

If into the wp_bp_user_blogs_blogmeta table you have no description meta key for sites with empty blogdescription, try to repopulate blog records using this repair tool. If it's not fixing the issue, there's probably a plugin or a script which is messing with BuddyPress on your setup.

That being said, you are right we should improve these queries and probably enjoy WP_Network_Query.

Your suggestion doesn't seem to hurt according to unit tests so unless there's a strong opinion, I'll probably commit your PR.

#5 @lenasterg
3 weeks ago

Thanks @imath.
I hope there won't be any opinion against my PR.

Last edited 3 weeks ago by lenasterg (previous) (diff)

#6 @imath
3 weeks ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 13902:

Blogs: slightly improve the query to get network sites

Only include the sql part to query according to site descriptions when needed: when a search is performed.

Props lenasterg

Fixes #9136

Note: See TracTickets for help on using tickets.