Change genId to be more resilient for duplicate ids, much like the code in mySql driver.
Submitted by Gallery2 Team
diff file
diff file