[buddypress-trac] [BuddyPress Trac] #7189: PHP Warning present when disabling Extended Profiles

buddypress-trac noreply at wordpress.org
Tue Jul 19 19:52:24 UTC 2016


#7189: PHP Warning present when disabling Extended Profiles
--------------------------+-----------------------------
 Reporter:  rrecurse      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Members       |    Version:
 Severity:  normal        |   Keywords:  needs-patch
--------------------------+-----------------------------
 A PHP warning is produced when visiting the /members/ page of a buddypress
 enabled site but only IF extended profiles are disabled.

 The warning is:

 Invalid argument supplied for foreach() in ../buddypress/members/members-
 loop.php on line 172

 Invalid argument supplied for foreach() in ../buddypress/members/members-
 loop.php on line 221

 The lines producing this are:

 foreach ($fields as $field) { ...

 Which should be ok based on logic-check found right above it, but this
 logic uses isset(). And while the var $feilds may be set, it's an empty
 array, so isset() produces false positive. An easy fix is using !empty()
 not empty since this checks arrays.

 So change:

 if (isset($fields) && count($fields) > 0) {

 to:

 if (!empty($fields) && count($fields) > 0) {

 And the warning is gone.

 The issue arises from this block of code on or about line 160:

 $table_name = woffice_get_xprofile_table('fields');
 $sqlStr = "SELECT name, type FROM " . $table_name;
 $fields = $wpdb->get_results($sqlStr);

 of file buddypress/members/members-loop.php

 Which is querying for the woffice_get_xprofile_table

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7189>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list