Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

#6247 closed defect (bug) (fixed)

Typo Error in BP_Friends_Friendship class update sql query

Reported by: sbrajesh's profile sbrajesh Owned by: boonebgorges's profile boonebgorges
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.2
Component: Friends Keywords:
Cc: sbrajesh

Description

Hi,
In the BP_Friends_Friendship class save() method there is a typo in the update sql.

On line 159 in bp-friends/bp-friends-classes.php, The sql query has an extra bracket(')')

	$result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET initiator_user_id = %d, friend_user_id = %d, is_confirmed = %d, is_limited = %d, date_created = %s ) WHERE id = %d", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created, $this->id ) );

Note the ')' that causes a failure of the update query. It seems the BuddyPress core never updates the row directly using the instance but I am using this class to utilize 'is_limited' relationship in a special case and the update is failing.

A simple fix is removing the extra ')' like this

$result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET initiator_user_id = %d, friend_user_id = %d, is_confirmed = %d, is_limited = %d, date_created = %s  WHERE id = %d", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created, $this->id ) );

Change History (2)

#1 @boonebgorges
10 years ago

  • Milestone changed from Awaiting Review to 2.3

Thanks, sbrajesh!

#2 @boonebgorges
10 years ago

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

In 9525:

Fix syntax typo in BP_Friends_Friendship::save().

An extraneous bracket was making it impossible to save an existing friendship
object.

Props sbrajesh.
Fixes #6247.

Note: See TracTickets for help on using tickets.