[buddypress-trac] [BuddyPress Trac] #5731: text/number profile fields not rendered if value == 0

buddypress-trac noreply at wordpress.org
Sun Jul 13 22:29:48 UTC 2014


#5731: text/number profile fields not rendered if value == 0
--------------------------+-----------------------
 Reporter:  DJPaul        |       Owner:  djpaul
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  2.1
Component:  XProfile      |     Version:  1.0
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+-----------------------
Changes (by WCUADD):

 * keywords:   => has-patch


Comment:

 I wanted to make a patch to #5738 (standardise required xprofile fields
 errors) but this ticket had to be solved first to go further with #5738.

 There were 5 places in the code that prevent a required xprofile field to
 be set to '0' value. See 5731.02.patch.

 First workflow (register with backcompat):
 - `L106:bp-members-screens.php` in `bp_core_screen_signup()`: an
 `empty($_POST['field_' . $field_id])` check prevents to validate the
 signup screen
 - `L170:bp-members-screens.php` in `bp_core_screen_signup()`: another
 `empty( $_POST['field_' . $field_id] )` check prevents to store the '0'
 value in $usermeta (which will be stored in `wp_signups` table)
 - `L327:bp-members-classes.php`in `add_backcompat()`: another `empty(
 $usermeta["field_{$field_id}"] )` check prevents to set '0' value in
 `wp_bp_xprofile_data` table

 Second workflow (register without backcompat that is to say with
 `define('BP_SIGNUPS_SKIP_USER_CREATION', 1)` in `wp_config.php`):
 - `L1691:bp-members-functions.php` in `bp_core_activate_signup()`: an
 `empty( $current_field )` check prevents to set '0' value in
 `wp_bp_xprofile_data` table

 Third workflow (update profile):
 - `L89:bp-xprofile-screens.php` in `xprofile_screen_edit_profile()`: an
 `empty( $_POST['field_' . $field_id] )` check prevents to validate the
 edit screen

 I ran quite a number of tests and with these modifications within these
 usecases, I've been able to save '0' value in required xprofile fields.

 Perhaps there are other usecases / workflows that still contain this
 problematic `empty()` check resulting in misinterpreting '0' value for
 integer or string required xprofile field?

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5731#comment:10>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list