Closed (fixed)
Project:
Flag
Version:
7.x-2.0-beta5
Component:
Flag core
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Aug 2011 at 08:03 UTC
Updated:
18 Jul 2014 at 10:00 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
wolfmarter commentedI have not been able to figure out how to merge the database values on loginn
i will keep trying and report my efforts
maybe someone can help??
thx wolfmarter
Comment #2
quicksketchThanks for the report, sounds like a likely issue and no further information should be needed. I'll test this out and see if I can reproduce it.
Comment #3
wolfmarter commentedthat would be wonderfull since i am in the need of this function for a current project. If i can help you in any way i will be glad to do so.
regards
wolfmarter
Comment #4
quicksketchI was looking in to this issue today and it looks like we already attempted to solve this problem by handling it the same as we did in Drupal 6. The applicable code already says it's trying to avoid these errors, but obviously the same approach we used before doesn't work in Drupal 7. Here's the code that is causing the error (from flag.module, flag_user_login()):
Because the new database system throws an exception (not just a PHP warning), we'll need to figure out a different way to handle this.
Comment #5
quicksketchThis patch corrects this issue on Drupal 7 by using a similar approach but doing each UPDATE query individually. Because a single warning will cause the entire update to fail in Drupal 7 (differences in how PDO works from normal queries it seems), we have to use this less efficient but effective approach.
I also discovered an issue related to this of database counts causing SQL errors. This was due to our dependence on db_update() returning a count of changed rows, but in some situations we would call the _update_count() method with a count that matched the current count, leading to a SQL error when Flag tried to do an INSERT when a row already existed. While this was a common practice in D6, in D7 we have the convenient db_merge() function to handle this exact situation, so I've used that in this patch to fix the additional problem.
I've committed this patch to the 7.x-2.x branch. The D6 branch is not affected by these problems.
Comment #7
Ivan Simonov commentedquicksketch, are you sure this patch was committed to the 7.x-2.x branch?
Comment #8
St_B commentedHello, is there any version of this patch for flag 7.x-3 branch ?
Comment #9
joachim commentedThe 7.x-3.x branch was forked from the 7.x-2.x branch long after this issue was closed! You can see the code from this patch, albeit with some changes for the 3.x table names, in flag_user_login().
Comment #10
St_B commented@joachim ok, we thought the error we have looks pretty like what is described in this issue.
step 1 : anonymous user create a flagging object ; this flagging can also be flagged by another user
step 2 : admin user flags the previous flagging => error : Integrity constraint violation: 1062 Duplicate entry '3140' for key 'PRIMARY': INSERT INTO {flagging}
It seems that it wants to change the user id and the sid by inserting a line instead of updating it. BUT in flag.module there is no db_insert('flagging').
We notice that when the first user is not anonymous, there is no problem, so it is linked to the replacement of uid when it is like 0.
Do you have any idea that could help ?
[Flag version : 7.x-3.5 and Session API version : 7.x-1.0-rc1]