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]);
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | profile_privacy-708280-4.patch | 985 bytes | cpliakas |
| #2 | profile_privacy-issue708280.patch | 980 bytes | cor3huis |
Comments
Comment #1
zroger commentedsubscribe
Comment #2
cor3huis commentedReal patch against D6.x v1.2 added.
Comment #3
cpliakas commentedThe 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
Comment #4
cpliakas commentedRe-rolled patch against the 6.x-2.x branch.
Comment #5
cpliakas commentedThis doesn't seem to break anything. Committed at 4dbca26, credited tom_o_t as the author since the idea behind this change is his.
Comment #6
tom_o_t commentedThanks!
Comment #7
cpliakas commentedThank you for doing all the work :-)