Changeset 7885
- Timestamp:
- 02/14/2014 07:21:52 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-functions.php
r7883 r7885 653 653 * @since BuddyPress (1.2) 654 654 * 655 * @param int $activity_id ID of the activity item whose metadata is being updated. 655 * @param int $activity_id ID of the activity item whose metadata is being 656 * updated. 656 657 * @param string $meta_key Key of the metadata being updated. 657 658 * @param mixed $meta_value Value to be set. 659 * @param mixed $prev_value Optional. If specified, only update existing 660 * metadata entries with the specified value. Otherwise, update all 661 * entries. 658 662 * @return bool True on success, false on failure. 659 663 */ 660 function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) {664 function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_value = '' ) { 661 665 662 666 // Legacy - Make sure activity_id is valid … … 669 673 670 674 add_filter( 'query', 'bp_filter_metaid_column_name' ); 671 $retval = update_metadata( 'activity', $activity_id, $meta_key, $meta_value );675 $retval = update_metadata( 'activity', $activity_id, $meta_key, $meta_value, $prev_value ); 672 676 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 673 677 -
trunk/bp-blogs/bp-blogs-functions.php
r7883 r7885 922 922 * @param string $meta_key Key of the metadata being updated. 923 923 * @param mixed $meta_value Value to be set. 924 * @param mixed $prev_value Optional. If specified, only update existing 925 * metadata entries with the specified value. Otherwise, update all 926 * entries. 924 927 * @return bool True on success, false on failure. 925 928 */ 926 function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {929 function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value, $prev_value = '' ) { 927 930 928 931 // Legacy - Sanitize meta_key … … 930 933 931 934 add_filter( 'query', 'bp_filter_metaid_column_name' ); 932 $retval = update_metadata( 'blog', $blog_id, $meta_key, $meta_value );935 $retval = update_metadata( 'blog', $blog_id, $meta_key, $meta_value, $prev_value ); 933 936 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 934 937 -
trunk/bp-groups/bp-groups-functions.php
r7883 r7885 1041 1041 * @param string $meta_key Metadata key. 1042 1042 * @param mixed $meta_value Value to store. 1043 * @param mixed $prev_value Optional. If specified, only update existing 1044 * metadata entries with the specified value. Otherwise, update all 1045 * entries. 1043 1046 * @return bool True on success, false on failure. 1044 1047 */ 1045 function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) {1048 function groups_update_groupmeta( $group_id, $meta_key, $meta_value, $prev_value = '' ) { 1046 1049 1047 1050 add_filter( 'query', 'bp_filter_metaid_column_name' ); 1048 $retval = update_metadata( 'group', $group_id, $meta_key, $meta_value );1051 $retval = update_metadata( 'group', $group_id, $meta_key, $meta_value, $prev_value ); 1049 1052 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 1050 1053 -
trunk/bp-xprofile/bp-xprofile-functions.php
r7883 r7885 634 634 * @param string $meta_key Key of the metadata being updated. 635 635 * @param mixed $meta_value Value of the metadata being updated. 636 * @param mixed $prev_value Optional. If specified, only update existing 637 * metadata entries with the specified value. Otherwise, update all 638 * entries. 636 639 * @return bool True on success, false on failure. 637 640 */ 638 function bp_xprofile_update_meta( $object_id, $object_type, $meta_key, $meta_value ) {641 function bp_xprofile_update_meta( $object_id, $object_type, $meta_key, $meta_value, $prev_value = '' ) { 639 642 640 643 // Legacy - sanitize meta_key … … 643 646 add_filter( 'query', 'bp_filter_metaid_column_name' ); 644 647 add_filter( 'query', 'bp_xprofile_filter_meta_query' ); 645 $retval = update_metadata( 'xprofile_' . $object_type, $object_id, $meta_key, $meta_value );648 $retval = update_metadata( 'xprofile_' . $object_type, $object_id, $meta_key, $meta_value, $prev_value ); 646 649 remove_filter( 'query', 'bp_xprofile_filter_meta_query' ); 647 650 remove_filter( 'query', 'bp_filter_metaid_column_name' ); -
trunk/tests/testcases/activity/functions.php
r7884 r7885 190 190 $this->assertFalse( bp_activity_update_meta( $a, 'foo', 'bar' ) ); 191 191 $this->assertSame( 'bar', bp_activity_get_meta( $a, 'foo' ) ); 192 } 193 194 /** 195 * @group activitymeta 196 * @group bp_activity_update_meta 197 */ 198 public function test_bp_activity_update_meta_prev_value() { 199 $a = $this->factory->activity->create(); 200 bp_activity_add_meta( $a, 'foo', 'bar' ); 201 $this->assertFalse( bp_activity_update_meta( $a, 'foo', 'bar2', 'baz' ) ); 202 $this->assertTrue( bp_activity_update_meta( $a, 'foo', 'bar2', 'bar' ) ); 192 203 } 193 204 -
trunk/tests/testcases/blogs/functions.php
r7883 r7885 186 186 /** 187 187 * @group blogmeta 188 * @group bp_blogs_update_ groupmeta188 * @group bp_blogs_update_blogmeta 189 189 */ 190 190 public function test_bp_blogs_update_blogmeta_new() { … … 195 195 /** 196 196 * @group blogmeta 197 * @group bp_blogs_update_ groupmeta197 * @group bp_blogs_update_blogmeta 198 198 */ 199 199 public function test_bp_blogs_update_blogmeta_existing() { … … 206 206 /** 207 207 * @group blogmeta 208 * @group bp_blogs_update_ groupmeta208 * @group bp_blogs_update_blogmeta 209 209 */ 210 210 public function test_bp_blogs_update_blogmeta_existing_no_change() { … … 212 212 $this->assertSame( 'bar', bp_blogs_get_blogmeta( 1, 'foo' ) ); 213 213 $this->assertFalse( bp_blogs_update_blogmeta( 1, 'foo', 'bar' ) ); 214 } 215 216 /** 217 * @group blogmeta 218 * @group bp_blogs_update_blogmeta 219 */ 220 public function test_bp_blogs_update_meta_prev_value() { 221 bp_blogs_add_blogmeta( 1, 'foo', 'bar' ); 222 $this->assertFalse( bp_blogs_update_blogmeta( 1, 'foo', 'bar2', 'baz' ) ); 223 $this->assertTrue( bp_blogs_update_blogmeta( 1, 'foo', 'bar2', 'bar' ) ); 214 224 } 215 225 -
trunk/tests/testcases/groups/functions.php
r7883 r7885 337 337 /** 338 338 * @group groupmeta 339 * @group groups_update_groupmeta 340 */ 341 public function test_groups_update_groupmeta_prev_value() { 342 $g = $this->factory->group->create(); 343 groups_add_groupmeta( $g, 'foo', 'bar' ); 344 $this->assertFalse( groups_update_groupmeta( $g, 'foo', 'bar2', 'baz' ) ); 345 $this->assertTrue( groups_update_groupmeta( $g, 'foo', 'bar2', 'bar' ) ); 346 } 347 348 /** 349 * @group groupmeta 339 350 * 340 351 * @todo Why do we do this? -
trunk/tests/testcases/xprofile/functions.php
r7883 r7885 443 443 /** 444 444 * @group xprofilemeta 445 * @group bp_xprofile_update_meta 446 */ 447 public function test_bp_xprofile_update_meta_prev_value() { 448 $g = $this->factory->xprofile_group->create(); 449 bp_xprofile_add_meta( $g, 'group', 'foo', 'bar' ); 450 $this->assertFalse( bp_xprofile_update_meta( $g, 'group', 'foo', 'bar2', 'baz' ) ); 451 $this->assertTrue( bp_xprofile_update_meta( $g, 'group', 'foo', 'bar2', 'bar' ) ); 452 } 453 454 /** 455 * @group xprofilemeta 445 456 * @group bp_xprofile_add_meta 446 457 */
Note: See TracChangeset
for help on using the changeset viewer.