Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

#6717 closed defect (bug) (fixed)

bp_core_get_directory_pages() with BP_ENABLE_MULTIBLOG returns wrong pages

Reported by: wpdennis's profile wpdennis Owned by: boonebgorges's profile boonebgorges
Milestone: 2.5 Priority: normal
Severity: normal Version:
Component: Core Keywords: has-patch needs-testing commit
Cc:

Description

bp_core_get_directory_pages() tries to load the pages from cache:

$pages = wp_cache_get( 'directory_pages', 'bp' );

The cache group "bp" is added as a global cache group in BP_Core->setup_cache_groups().

If I enable BP_ENABLE_MULTIBLOG, bp_core_get_directory_pages() would return pages from the current blog id:

$posts_table_name = bp_is_multiblog_mode() ? $wpdb->posts : $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'posts';

Since "bp" is a global cache group bp_core_get_directory_pages() doesn't return the right results, if another blog called it first and the cached result isn't expired (which means it's wrong pretty much always except for the first blog).

I think with BP_ENABLE_MULTIBLOG enabled the cache group shouldn't be global.

I ranked this ticket as "blocker" since it's absolutely not possible to configure a BP_ENABLE_MULTIBLOG enabled installation without hacks.

Attachments (1)

6717.diff (627 bytes) - added by boonebgorges 9 years ago.

Download all attachments as: .zip

Change History (6)

#1 @wpdennis
9 years ago

  • Severity changed from blocker to normal

Still playing with BP_ENABLE_MULTIBLOG, but bp_core_get_directory_pages() doesn't seem to be a blocker, as I thought initially.

#2 follow-up: @boonebgorges
9 years ago

  • Keywords has-patch needs-testing added; dev-feedback removed
  • Milestone changed from Awaiting Review to 2.5

Thanks for the report, wpdennis. I've confirmed the problem.

I scanned through to look at how the 'bp' cache group is being used. It acts like BP's junk drawer for miscellaneous items to cache. This particular key is the only one I saw that look like ought to be multiblog-aware. See 6717.diff.

This is a relatively minor change, but we are very late in the cycle, so I'd like to push it to 2.5, to allow for testing. In the meantime, you can work around this problem by copying the logic of bp_core_get_directory_pages() to an mu-plugin or bp-custom.php, correcting the cache group, and using that function to filter 'bp_core_get_directory_pages'.

@boonebgorges
9 years ago

#3 @DJPaul
9 years ago

  • Keywords commit added

Looks good

#4 in reply to: ↑ 2 @wpdennis
9 years ago

Replying to boonebgorges:

Thanks for the report, wpdennis. I've confirmed the problem.

[...] In the meantime, you can work around this problem by copying the logic of bp_core_get_directory_pages() to an mu-plugin or bp-custom.php, correcting the cache group, and using that function to filter 'bp_core_get_directory_pages'.

Thanks Boone,

hooked your patch and it solved the issue as far as i can tell.

I think to avoid old cache values the cache group in bp_core_clear_directory_pages_cache_page_edit() and bp_core_clear_directory_pages_cache_settings_edit() needs to be altered, too.

#5 @boonebgorges
9 years ago

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

In 10365:

Use a non-global cache group for bp-pages.

Using a global cache group for bp-pages breaks BP_ENABLE_MULTIBLOG
installations.

Props wpdennis.
Fixes #6717.

Note: See TracTickets for help on using tickets.