[buddypress-trac] [BuddyPress Trac] #6552: XProfile: don't bail BP_XProfile_Group::save() when wpdb returns 0 rows affected
buddypress-trac
noreply at wordpress.org
Wed Jul 8 19:31:12 UTC 2015
#6552: XProfile: don't bail BP_XProfile_Group::save() when wpdb returns 0 rows
affected
----------------------------------+-----------------------------
Reporter: Offereins | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Component - XProfile | Version: 2.3.0
Severity: normal | Keywords: has-patch
----------------------------------+-----------------------------
As per [https://buddypress.trac.wordpress.org/changeset/9677 r9677] the
`save()` method in class-bp-xprofile-group.php checks for an empty result
of `wpdb::query()`. But unlike how class-bp-xprofile-field.php handles it
(compare with `!== null`*), it just checks for `empty()`. This creates an
issue, which is very aptly described in the
[https://buddypress.trac.wordpress.org/browser/trunk/src/bp-
xprofile/classes/class-bp-xprofile-field.php#L286 inline comments of the
latter file]:
{{{
/**
* Check for null so field options can be changed without changing any
* other part of the field. The described situation will return 0 here.
*/
}}}
I guess, since very little users of BP generate meta for XProfile groups,
this issue hasn't shown up untill now. Suggested is to follow the logic
present in `BP_XProfile_Field::save()`. Patch is attached.
*) Since `wpdb::query()` returns
[https://core.trac.wordpress.org/browser/trunk/src/wp-includes/wp-
db.php#L1614 false on errors, rather than null], I think we should better
check with `!== false`. Also, can `wpdb::query()` return a `WP_Error`? The
phpDoc doesn't mention it.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6552>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list