tim-zw / phurl

Automatically exported from code.google.com/p/phurl
0 stars 0 forks source link

Database structure for generating new code/number seems inefficient with a lot of users #148

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Installed last version.
2. Some users got the following message randomly : "File functions.php, Line : 
66, Message : duplicate entry 'cP' for key 'code'"
3. It seems they a lot of users at the same time, and the software actually 
does this :

- read the table settings for the last generated number
- does+1 and translate this number into a code like 'cP'
- add a ligne into the table urls with this code

But what does happens if two users does exactly the same thing at the same time 
? It seems they got the same number, then the same code, so the input function 
on line 66 of functions.php does stop with the error message, because it cannot 
ave twice the same code.

Please help me find a solution !

Best regards.

Original issue reported on code.google.com by prez.mo5...@gmail.com on 21 May 2013 at 4:02

GoogleCodeExporter commented 9 years ago
- read the table settings for the last generated number
- does+1 and translate this number into a code like 'cP'
- add a line into the table urls with this code
- update the table settings with the new number
- it could be an asynchronous situation between two demands at the same time 
(two readings of the setting table, so same number, same code), and not being 
able to write two time the same code of course into the urls table.

Original comment by prez.mo5...@gmail.com on 21 May 2013 at 4:03

GoogleCodeExporter commented 9 years ago
Is there an easy way for the URL generated to include 5 random characters 
instead of just one?  For example, http://mysite.com/aI6jv

Original comment by kricot...@gmail.com on 17 Dec 2013 at 8:50