We found an issue using profile_privacy with i18n.

The profile_privacy module sets privileged-only fields to NULL in hook_user() instead of unsetting them. Because of this, profile_privacy is adding fields to $user->content that would not be there if the profile_privacy module was not enabled.

When the $account object with these NULL values is passed to i18nstrings.module it throws the error:

warning: Cannot use a scalar value as an array in /home/sonybmg/d6-live/public_html/sites/all/modules/contrib/i18n/i18nstrings/i18nstrings.module on line 727.

because there's a NULL value where it's expecting an array. Unsetting prevents this error because that field is no longer passed.

Attached is a patch.

Thanks to alevine for the help debugging.

Existing code:

          // Over ride the default profile behavior. If a field is only available
          // to "privileged users" unset the variable entirely. This affects
          // all themed versions 
          elseif ($field->visibility == PROFILE_PRIVATE) {
            $account->{$field->name} = NULL;
            $account->content[$field->category][$field->name] = NULL;
          }

new code:

          // Over ride the default profile behavior. If a field is only available
          // to "privileged users" unset the variable entirely. This affects
          // all themed versions 
          elseif ($field->visibility == PROFILE_PRIVATE) {
            if (isset($account->{$field->name})) {
              unset($account->{$field->name});
            }
            if (isset($account->{$field->name})) {
              unset($account->content[$field->category][$field->name]);
            }
          }

Comments

zroger’s picture

subscribe

cor3huis’s picture

Status: Needs review » Patch (to be ported)
StatusFileSize
new980 bytes

Real patch against D6.x v1.2 added.

cpliakas’s picture

Version: 6.x-1.2 » 6.x-2.x-dev
Status: Patch (to be ported) » Needs work

The idea seems solid, we just need to make sure other modules don't expect that property to be there. Marking as needs work because I am not sure there needs to be two "if" conditionals. Also bumping to the 6.x-2.x branch.

Thanks for the contribution,
Chris

cpliakas’s picture

Status: Needs work » Needs review
StatusFileSize
new985 bytes

Re-rolled patch against the 6.x-2.x branch.

cpliakas’s picture

Status: Needs review » Fixed

This doesn't seem to break anything. Committed at 4dbca26, credited tom_o_t as the author since the idea behind this change is his.

tom_o_t’s picture

Thanks!

cpliakas’s picture

Thank you for doing all the work :-)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.