#7189 closed defect (bug) (worksforme)
PHP Warning present when disabling Extended Profiles
Reported by: | rrecurse | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Members | Keywords: | reporter-feedback |
Cc: |
Description
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
@rrecurse That looks like a theme-specific error. Are you using the Woffice theme? If you change to Twenty Sixteen/Fifteen theme, do the errors disappear?