Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#6193 closed defect (bug) (fixed)

Displaying member types within members loop fails

Reported by: imath's profile imath Owned by: boonebgorges's profile boonebgorges
Milestone: 2.2.1 Priority: normal
Severity: normal Version: 2.2
Component: Members Keywords: has-patch
Cc:

Description

I've been pinged by this topic https://buddypress.org/support/topic/bp_get_member_type-is-not-working-in-the-loop/ then tried to understand what was going wrong.

I think the problem is due to the fact bp_members_prefetch_member_type() is caching a string and bp_get_member_type() needs an array as it uses array_pop()

So i suggest the attached patch to be sure to cache all potentiel member types assigned to a user.

Attachments (2)

6193.patch (975 bytes) - added by imath 10 years ago.
6193.unittests.patch (2.2 KB) - added by imath 10 years ago.

Download all attachments as: .zip

Change History (8)

@imath
10 years ago

#1 @imath
10 years ago

  • Keywords has-patch added

Sorry, i wasn't able to run the unit tests to check everything was ok, will do soon

#2 @boonebgorges
10 years ago

  • Milestone changed from Awaiting Review to 2.2.1

This definitely needs unit tests. Thanks for the catch.

#3 @imath
10 years ago

6193.unittests.patch only contains the unittests.

#4 @boonebgorges
10 years ago

Thanks, imath. Just to clarify a bit for posterity's sake: The 2.2 implementation of member type caches was meant to store arrays of member types; see bp_get_member_type() for an example. However, the prefetch function (and its unit test) was mistakenly written to cache string values.

I'm going to rewrite the logic here to be just a little bit less opaque, and fix it in trunk and on the branch.

#5 @boonebgorges
10 years ago

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

In 9447:

When prefetching member types in the loop, cache arrays instead of strings.

Member type caches should always be arrays of all member types for a user.

Props imath.
Fixes #6193.

#6 @boonebgorges
10 years ago

In 9448:

When prefetching member types in the loop, cache arrays instead of strings.

Member type caches should always be arrays of all member types for a user.

Props imath.
Fixes #6193 for the 2.2 branch.

Note: See TracTickets for help on using tickets.