Skip to:
Content

BuddyPress.org

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#8503 closed defect (bug) (fixed)

PHP8 multi-byte safety warning

Reported by: ionvv's profile ionvv Owned by: imath's profile imath
Milestone: 9.0.0 Priority: normal
Severity: normal Version: 8.0.0
Component: Extended Profile Keywords: has-patch
Cc:

Description

When using BP 8.0.0 with PHP8 and calling bp_xprofile_get_hidden_fields_for_user( $user->ID ) a warning will be raised: Warning: Only the first byte will be assigned to the string offset in /var/www/html/domain.tld/wp-content/plugins/buddypress/bp-xprofile/bp-xprofile-functions.php #1315

Attachments (2)

8503.1.patch (504 bytes) - added by johnjamesjacoby 3 years ago.
Cast results of bp_get_user_meta() to array
8503.2.patch (795 bytes) - added by johnjamesjacoby 3 years ago.
Cast to array early. Remove late array casting.

Download all attachments as: .zip

Change History (8)

#1 @imath
3 years ago

Thanks a lot for your report. We’ll check this issue asap.

@johnjamesjacoby
3 years ago

Cast results of bp_get_user_meta() to array

@johnjamesjacoby
3 years ago

Cast to array early. Remove late array casting.

#3 @imath
3 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 8.1.0

Thanks a lot @johnjamesjacoby for the patch and sorry @vapvarun i missed it earlier. I'm going to test it asap.

#4 @imath
3 years ago

In 13011:

Avoid a PHP8 warning when xProfile user visibility levels are empty

When the record does not exist yet into the usermeta table, getting the 'bp_xprofile_visibility_levels' usermeta returns an empty string while we're expecting an array. As we use the expected array to reset the visibility level if the administrator enforced a specific visibility to the field, it's causing the PHP8 warning. To fix it, we are now casting the 'bp_xprofile_visibility_levels' usermeta as soon as we get it.

Props johnjamesjacoby

See #8503 (branch 8.0)

#5 @imath
3 years ago

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

In 13012:

Avoid a PHP8 warning when xProfile user visibility levels are empty

When the record does not exist yet into the usermeta table, getting the 'bp_xprofile_visibility_levels' usermeta returns an empty string while we're expecting an array. As we use the expected array to reset the visibility level if the administrator enforced a specific visibility to the field, it's causing the PHP8 warning. To fix it, we are now casting the 'bp_xprofile_visibility_levels' usermeta as soon as we get it.

Props johnjamesjacoby

Fixes #8503 (trunk)

#6 @imath
3 years ago

  • Milestone changed from 8.1.0 to 9.0.0

Ticket retargeted after milestone deleted

Note: See TracTickets for help on using tickets.