Changeset 7812
- Timestamp:
- 02/06/2014 07:38:35 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-classes.php
r7800 r7812 302 302 // the xprofile table 303 303 } else { 304 $fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) );305 306 304 $this->uid_name = 'user_id'; 307 305 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$bp->profile->table_name_data} u"; 308 $sql['where'][] = "u.field_id = {$fullname_field_id}";306 $sql['where'][] = $wpdb->prepare( "u.field_id = %d", bp_xprofile_fullname_field_id() ); 309 307 $sql['orderby'] = "ORDER BY u.value"; 310 308 $sql['order'] = "ASC"; -
trunk/bp-xprofile/bp-xprofile-cache.php
r7791 r7812 59 59 add_action( 'xprofile_data_after_delete', 'xprofile_clear_profiledata_object_cache' ); 60 60 61 /** 62 * Clear fullname_field_id cache when bp-xprofile-fullname-field-name is updated. 63 * 64 * Note for future developers: Dating from an early version of BuddyPress where 65 * the fullname field (field #1) did not have a title that was editable in the 66 * normal Profile Fields admin interface, we have the bp-xprofile-fullname-field-name 67 * option. In many places throughout BuddyPress, the ID of the fullname field 68 * is queried using this setting. However, this is no longer strictly necessary, 69 * because we essentially hardcode (in the xprofile admin save routine, as well 70 * as the xprofile schema definition) that the fullname field will be 1. The 71 * presence of the non-hardcoded versions (and thus this bit of cache 72 * invalidation) is thus for backward compatibility only. 73 * 74 * @since BuddyPress (2.0.0) 75 */ 76 function xprofile_clear_fullname_field_id_cache() { 77 wp_cache_delete( 'fullname_field_id', 'bp_xprofile' ); 78 } 79 add_action( 'update_option_bp-xprofile-fullname-field-name', 'xprofile_clear_fullname_field_id_cache' ); 80 61 81 // List actions to clear super cached pages on, if super cache is installed 62 82 add_action( 'xprofile_updated_profile', 'bp_core_clear_cache' ); -
trunk/bp-xprofile/bp-xprofile-classes.php
r7808 r7812 1492 1492 $user_id = bp_displayed_user_id(); 1493 1493 1494 $field_name = bp_xprofile_fullname_field_name(); 1495 $data = xprofile_get_field_data( $field_name, $user_id ); 1494 $data = xprofile_get_field_data( bp_xprofile_fullname_field_id(), $user_id ); 1496 1495 1497 1496 return $data[$field_name]; -
trunk/bp-xprofile/bp-xprofile-filters.php
r7810 r7812 252 252 } 253 253 254 $fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) ); 255 $user_id_names = BP_XProfile_ProfileData::get_value_byid( $fullname_field_id, $user_query->user_ids ); 254 $user_id_names = BP_XProfile_ProfileData::get_value_byid( bp_xprofile_fullname_field_id(), $user_query->user_ids ); 256 255 257 256 // Loop through names and override each user's fullname -
trunk/bp-xprofile/bp-xprofile-functions.php
r7730 r7812 438 438 return false; 439 439 440 $fullname = xprofile_get_field_data( bp_xprofile_fullname_field_ name(), $user_id );440 $fullname = xprofile_get_field_data( bp_xprofile_fullname_field_id(), $user_id ); 441 441 $space = strpos( $fullname, ' ' ); 442 442 … … 474 474 return; 475 475 476 xprofile_set_field_data( bp_xprofile_fullname_field_ name(), $user->ID, $user->display_name );476 xprofile_set_field_data( bp_xprofile_fullname_field_id(), $user->ID, $user->display_name ); 477 477 } 478 478 add_action( 'user_profile_update_errors', 'xprofile_sync_bp_profile', 10, 3 ); … … 626 626 627 627 /** 628 * Return the field ID for the Full Name xprofile field. 629 * 630 * @since BuddyPress (2.0.0) 631 * 632 * @return int Field ID. 633 */ 634 function bp_xprofile_fullname_field_id() { 635 $id = wp_cache_get( 'fullname_field_id', 'bp_xprofile' ); 636 637 if ( false === $id ) { 638 global $wpdb; 639 640 $bp = buddypress(); 641 $id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) ); 642 643 wp_cache_set( 'fullname_field_id', $id, 'bp_xprofile' ); 644 } 645 646 return absint( $id ); 647 } 648 649 /** 628 650 * Return the field name for the Full Name xprofile field 629 651 * -
trunk/tests/testcases/xprofile/functions.php
r7469 r7812 81 81 $this->assertEquals( $meta_value, bp_xprofile_get_meta( $f->id, 'field', 'linebreak_field' ) ); 82 82 } 83 84 /** 85 * @group bp_xprofile_fullname_field_id 86 */ 87 public function test_bp_xprofile_fullname_field_id_invalidation() { 88 // Prime the cache 89 $id = bp_xprofile_fullname_field_id(); 90 91 bp_update_option( 'bp-xprofile-fullname-field-name', 'foo' ); 92 93 $this->assertFalse( wp_cache_get( 'fullname_field_id', 'bp_xprofile' ) ); 94 } 83 95 }
Note: See TracChangeset
for help on using the changeset viewer.