Hi,
For one user, I cannot award the "writer" achievement:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'writer-13990' for key 'PRIMARY': INSERT INTO {achievement_unlocks} (achievement_id, uid, rank, timestamp ..
Looking at the DB, he already has "writer"
select * from achievement_unlocks where uid=13990;
+----------------+-------+-------+------------+------+
| achievement_id | rank | uid | timestamp | seen |
+----------------+-------+-------+------------+------+
| writer | 19 | 13990 | 1336977269 | 1 |on the url user/13990/achievements, the achievement is listed as grayed out (i.e not unlocked).
If the achivement is awarded manually from the gui (admin/config/people/achievements), the logs show that achievements_unlocked() is being called and the user has the appropriate right.
notice achievements achievements_unlocked() uid=13990, a_id=writer
When one achievements_unlocked() and the watchdog, achievements_unlocked_already($achievement_id, $uid) is called first to see if the achievment is already there.
I think achievements_unlocked_already() does not "see" the achievement in the DB table above.
But I'm mystified as to why - any suggestions?
Comments
Comment #1
boran commentedFound the problem, the entries in the achievement_unlocks table for "writer" had a space after them, so "writer ".
After removing the space, the achievement is recognised.
Sigh.
FYI a thing I learned to dump achievement array to a file without disturbing the user experience:
file_put_contents("/tmp/drupal.debug", print_r($achievements, TRUE), FILE_APPEND);