When attempting to select and save role badges (admin/config/people/user_badges/roles) a series of errors are generated:
Warning: Missing argument 1 for SelectQuery::condition(), called in ...\user_badges\user_badges.module on line 1166 and defined in SelectQuery->condition() (line 1006 of ...\htdocs\includes\database\select.inc).
Notice: Undefined variable: field in SelectQuery->condition() (line 1007 of ...\htdocs\includes\database\select.inc).
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IS NULL )' at line 2: SELECT u.uid AS uid FROM {users} u LEFT OUTER JOIN {user_badges_user} ubu ON ubu.uid=u.uid AND ubu.type='role' WHERE (u.status = :db_condition_placeholder_0) AND (ubu.bid = :db_condition_placeholder_1) AND (ubu.uid IS NULL ) AND ( IS NULL ) ; Array ( [:db_condition_placeholder_0] => 0 [:db_condition_placeholder_1] => 2 ) in user_badges_save_roles() (line 1169 of ...\user_badges\user_badges.module).
If you remove all badges from the roles and save, all goes well.
If you have no badges selected, you can select one badge and it will save, but will give the simple error, "There was a problem saving roles to the database." After that you get the above errors.
Comment | File | Size | Author |
---|---|---|---|
#3 | user_badges.module-user_badges_save_roles.patch | 5.54 KB | Delty |
#2 | user_badges.module-user_badges_save_roles.patch | 46.85 KB | Killpill |
Comments
Comment #1
Killpill CreditAttribution: Killpill commentedWow... I was debugging this thing and writing something as I went then totally Google searched with this tab and lost my text.
I have the same problem.
The "correct" code, from looking at the 6.x module, should be:
I think, at least.
After that I get this error:
PDOException: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1: INSERT INTO {user_badges_user} (uid, bid, type) VALUES (:db_insert_placeholder_0_0, :db_insert_placeholder_0_1, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => role [:db_insert_placeholder_0_0] => 1 [:db_insert_placeholder_0_1] => 2 ) in user_badges_save_roles() (line 1214 of .../user_badges/user_badges.module).
No idea on that one but now I'm almost late for something. Hopefully this will help someone... but I am new to all this.
Edit:
Just got back. I'm going to start from the old module function and rewrite the queries to work with D7. I hope that will do the trick. Just trying to understand this, as I need it to work.
Edit2:
Seems to work for me! I'll submit a patch after I figure out how to.
Comment #2
Killpill CreditAttribution: Killpill commentedI don't really know how the patch file system works.
This is what I changed:
I just took the function from 6.x, replaced the 7.x function with it, then updated all the queries to 7.x syntax. It seems to work for me but I must stress that I am new to this.
Comment #3
Delty CreditAttribution: Delty commentedThanks for doing that Killpill. I'm going to test it here in a minute.
WRT creating patch files, you need to use the diff utility. It's very simple and is built into most Linux/UNIX operating systems. On Windows, you can install Cygwin to get a unix shell that has the patch and diff utilities. Once you have access to it, the diff command is:
diff -u original.c new.c > original.patch
That's all there is to it. I've attached the patch.
UPDATE: My initial testing looks good - I was able to save and remove badges and the role badges were assigned properly when roles were added or removed. Thanks!
Comment #4
Delty CreditAttribution: Delty commentedI'm getting a couple of badge related errors in the log now if you want to take a look. It might not have anything to do with your changes though, because now I have a badge set for blocked (new) users where before I was unable to set that badge successfuly for testing.
Notice: Undefined property: stdClass::$badges_all in user_badges_user_presave() (line 343 of /var/www/clients/client3/web2/web/sites/default/modules/user_badges/user_badges.module).
and
Warning: key_exists() expects parameter 2 to be array, null given in user_badges_user_presave() (line 343 of /var/www/clients/client3/web2/web/sites/default/modules/user_badges/user_badges.module).
Comment #5
Killpill CreditAttribution: Killpill commentedMy badge image file is also being deleted from the folder but the badge remains. Other folders, such as user title images and user pictures, are not cleared so this is unique to badges.
I'm checking in on user_badges_user_presave now.
Edit:
I don't get that notice message when editing a user profile and blocking someone, but the function is called and I had it print the $account variable - which had badges_all in it. Where do these notices occur for you, page wise?
Edit2:
Found the warning and notice in my log from when a user registered.
Comment #6
Delty CreditAttribution: Delty commentedAs you noticed, it happens when a new user registers, so it might be trying to set the badge before the account is available (i.e. on the Anonymous account) so my guess is a simple check to see if it's a new user on the anonymous account would fix it.
Thanks!
Comment #7
Killpill CreditAttribution: Killpill commentedI created a separate issue for this here. I don't have any intention of fixing it at the moment unless it is causing problems.
Comment #8
imoreno CreditAttribution: imoreno commentedHi,
unable to apply this patch, is it still in use?
Comment #9
imoreno CreditAttribution: imoreno commentedpatch from #1 worked for me, i can now save the role based tags with no errors.
Comment #10
SebCorbin CreditAttribution: SebCorbin commentedPatch committed (I've rewritten comments according to Drupal Coding standards)
Comment #11
SebCorbin CreditAttribution: SebCorbin commented