Hi, I've come across an error when I have anonymous users unable to flag content and they are viewing a users profile.
I tracked it down to...
function flag_content_user($op, &$edit, &$account, $category = NULL) {
global $user;
switch($op) {
case 'view':
if ($user->uid == $account->uid) {
// User is viewing their own user page, don't show them anything
return array();
}
$links = flag_content_link(FLAG_CONTENT_TYPE_USER, $account);
foreach($links as $key => $value) {
$items[] = array(
'class' => $key,
'value' => l($value['title'], $value['href'], $value['attributes']),
);
}
return array(t('Flag user') => $items);
case 'delete':
db_query("DELETE FROM {flag_content} WHERE eid = %d AND type = '%s'", $account->uid, FLAG_CONTENT_TYPE_USER);
break;
}
}
It looks like if flag_content_link() returns an empty array the foreach loop in flag_content_user() never loops which results in $items array not being created. This then messes up user.module when we... return array(t('Flag user') => $items);
I was able to bandaid the problem by adding...
$items = array();
Here is what the function looks like for me now.
function flag_content_user($op, &$edit, &$account, $category = NULL) {
global $user;
switch($op) {
case 'view':
if ($user->uid == $account->uid) {
// User is viewing their own user page, don't show them anything
return array();
}
$items = array();
$links = flag_content_link(FLAG_CONTENT_TYPE_USER, $account);
foreach($links as $key => $value) {
$items[] = array(
'class' => $key,
'value' => l($value['title'], $value['href'], $value['attributes']),
);
}
return array(t('Flag user') => $items);
case 'delete':
db_query("DELETE FROM {flag_content} WHERE eid = %d AND type = '%s'", $account->uid, FLAG_CONTENT_TYPE_USER);
break;
}
}
Fixed
2.5
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.