[buddypress-trac] [BuddyPress Trac] #7112: xprofile field cache is stale after update

buddypress-trac noreply at wordpress.org
Tue Jun 7 20:55:52 UTC 2016


#7112: xprofile field cache is stale after update
--------------------------+-----------------------------
 Reporter:  emrikol       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  API           |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 After running `BP_XProfile_Field::update_position()` (from a drag and drop
 move in `/wp-admin/users.php?page=bp-profile-setup` for example) the
 object cache is not updated or cleared for the field and subsqeuent calls
 to `xprofile_get_field()` will return old data.

 I'm able to reproduce this by:

 1. using a persistent object cache
 2. dragging and dropping fields around in the editor from one group to
 another
 3. refreshing and the fields act as if they've not moved groups
 4. flushing the object cache and refreshing the editor page
 5. viewing the fields have moved to the new groups they should be assigned
 to

 This is the temporary fix I've been using to address this problem:

 {{{
 --- a/plugins/buddypress/bp-xprofile/classes/class-bp-xprofile-field.php
 +++ b/plugins/buddypress/bp-xprofile/classes/class-bp-xprofile-field.php
 @@ -940,6 +940,9 @@ class BP_XProfile_Field {
                         $sql = $wpdb->prepare( "UPDATE {$table_name} SET
 group_id = %d WHERE parent_id = %d", $field_group_id, $field_id );
                         $wpdb->query( $sql );

 +                       // Clear old field cache
 +                       wp_cache_delete( $field_id, 'bp_xprofile_fields'
 );
 +
                         return $parent;
                 }

 }}}

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7112>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list