Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello!
If I save user settings (/user//edit) then I got error:
recoverable fatal error: Object of class stdClass could not be converted to string in /home/u2799/domains/shah-online.ru/sites/all/modules/user_badges/user_badges.module on line 218.
Comments
Comment #1
sbefort CreditAttribution: sbefort commentedSame issue here.
Comment #2
leebroozlee CreditAttribution: leebroozlee commentedIt looks like a problem with the static $badges variable in the
user_badges_user() function.
we have:
static $badges = array();
then later on:
$badges[$account->uid] = $account->badges;
so $badges are arrays of badges, keyed by user ids.
but later from within same function:
$badges = user_badges_get_badges('select');
which makes the static $badges an array of badge names (strings), keyed by badge id.
I fixed mine by changing $badges to instead use a variable name $all_badges
from within the 'insert' and 'update' select cases in the user_badges_user() function
-paul
Comment #3
calefilm CreditAttribution: calefilm commentedThank you Paul! Your solution solved my error.
With deep thanks,
Cale
Comment #4
alexx90 CreditAttribution: alexx90 commentedcan you plz tell me witch file and witch line I have to change that
cause I tried to find where but there are a lot of $badges
and thank you
Comment #5
calefilm CreditAttribution: calefilm commentedI don't remember this one but looks like I probably changed it around line 218 like the original posters error:
"user_badges/user_badges.module on line 218."
so that would be user badges module, open up file 'user_badges.module' and search for '$badges'
then follow what leebroozlee did. Best I can suggest
Comment #6
shabana.navas CreditAttribution: shabana.navas commentedFixed in Version 7. Please upgrade to Version 7.x-3.x.