Changeset 8022
- Timestamp:
- 03/03/2014 01:48:45 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-cache.php
r7975 r8022 132 132 } 133 133 add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' ); 134 135 /** 136 * Clear the fullname cache when field 1 is updated. 137 * 138 * xprofile_clear_profile_data_object_cache() will make this redundant in most 139 * cases, except where the field is updated directly with xprofile_set_field_data() 140 * 141 * @since BuddyPress (2.0.0) 142 */ 143 function xprofile_clear_fullname_cache_on_profile_field_edit( $data ) { 144 if ( 1 == $data->field_id ) { 145 wp_cache_delete( 'bp_user_fullname_' . $data->user_id, 'bp' ); 146 } 147 } 148 add_action( 'xprofile_data_after_save', 'xprofile_clear_fullname_cache_on_profile_field_edit' ); 134 149 135 150 /** -
trunk/bp-xprofile/bp-xprofile-classes.php
r7965 r8022 1157 1157 $cached = wp_cache_get( $this->field_id, 'bp_xprofile_data_' . $this->user_id ); 1158 1158 1159 if ( $cached ) {1159 if ( $cached && ! empty( $cached->id ) ) { 1160 1160 $retval = true; 1161 1161 } else { -
trunk/tests/testcases/members/functions.php
r7910 r8022 101 101 $this->assertSame( home_url( 'new-members-slug' ) . '/' . $user->user_nicename . '/', bp_core_get_user_domain( $user_id ) ); 102 102 } 103 104 /** 105 * @group bp_core_get_user_displayname 106 */ 107 public function test_bp_core_get_user_displayname_empty_username() { 108 $this->assertFalse( bp_core_get_user_displayname( '' ) ); 109 } 110 111 /** 112 * @group bp_core_get_user_displayname 113 */ 114 public function test_bp_core_get_user_displayname_translate_username() { 115 $u = $this->create_user(); 116 117 $user = new WP_User( $u ); 118 119 $found = bp_core_get_user_displayname( $u ); 120 $this->assertNotEmpty( $found ); 121 $this->assertSame( $found, bp_core_get_user_displayname( $user->user_login ) ); 122 } 123 124 /** 125 * @group bp_core_get_user_displayname 126 */ 127 public function test_bp_core_get_user_displayname_bad_username() { 128 $this->assertFalse( bp_core_get_user_displayname( 'i_dont_exist' ) ); 129 } 130 131 /** 132 * @group bp_core_get_user_displayname 133 * @group cache 134 */ 135 public function test_bp_core_get_user_displayname_xprofile_populate_cache() { 136 $xprofile_is_active = bp_is_active( 'xprofile' ); 137 buddypress()->active_components['xprofile'] = '1'; 138 139 $u = $this->create_user( array( 140 'display_name' => 'Foo', 141 ) ); 142 bp_core_get_user_displayname( $u ); 143 144 $this->assertSame( 'Foo', wp_cache_get( 'bp_user_fullname_' . $u, 'bp' ) ); 145 146 if ( ! $xprofile_is_active ) { 147 unset( buddypress()->active_components['xprofile'] ); 148 } 149 } 150 151 /** 152 * @group bp_core_get_user_displayname 153 * @group cache 154 */ 155 public function test_bp_core_get_user_displayname_xprofile_bust_cache_after_xprofile_update() { 156 $xprofile_is_active = bp_is_active( 'xprofile' ); 157 buddypress()->active_components['xprofile'] = '1'; 158 159 $u = $this->create_user(); 160 xprofile_set_field_data( 1, $u, 'Foo Foo' ); 161 162 $this->assertFalse( wp_cache_get( 'bp_user_fullname_' . $u, 'bp' ) ); 163 164 if ( ! $xprofile_is_active ) { 165 unset( buddypress()->active_components['xprofile'] ); 166 } 167 } 168 169 /** 170 * @group bp_core_get_user_displayname 171 */ 172 public function test_bp_core_get_user_displayname_xprofile_exists() { 173 $xprofile_is_active = bp_is_active( 'xprofile' ); 174 buddypress()->active_components['xprofile'] = '1'; 175 176 $u = $this->create_user(); 177 xprofile_set_field_data( 1, $u, 'Foo Foo' ); 178 179 $this->assertSame( 'Foo Foo', bp_core_get_user_displayname( $u ) ); 180 181 if ( ! $xprofile_is_active ) { 182 unset( buddypress()->active_components['xprofile'] ); 183 } 184 } 185 186 /** 187 * @group bp_core_get_user_displayname 188 */ 189 public function test_bp_core_get_user_displayname_xprofile_does_not_exist() { 190 $xprofile_is_active = bp_is_active( 'xprofile' ); 191 buddypress()->active_components['xprofile'] = '1'; 192 193 $u = $this->create_user( array( 194 'display_name' => 'Foo Foo', 195 ) ); 196 197 // Delete directly because BP won't let you delete a required 198 // field through the API 199 global $wpdb, $bp; 200 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = 1", $u ) ); 201 wp_cache_delete( 'bp_user_fullname_' . $u, 'bp' ); 202 wp_cache_delete( 1, 'bp_xprofile_data_' . $u, 'bp' ); 203 204 $this->assertSame( '', xprofile_get_field_data( 1, $u ) ); 205 $this->assertSame( 'Foo Foo', bp_core_get_user_displayname( $u ) ); 206 $this->assertSame( 'Foo Foo', xprofile_get_field_data( 1, $u ) ); 207 208 if ( ! $xprofile_is_active ) { 209 unset( buddypress()->active_components['xprofile'] ); 210 } 211 } 103 212 }
Note: See TracChangeset
for help on using the changeset viewer.