Hi,
The column shorturl_link.lid should not be a serial (but an int).
The new values of 'serial' types are handled by the database, not by the programmer (so they should not be set to specific values, by code).
The INSERT statement in the stable version of short_url_shorten() ignores that and just overwrites lid anyway. But drupal_write_record() in the -dev version plays nice and adheres to the schema definition. Effect: even though you pass $link->lid = 3845, the shorturl_link.lid column will be 1. (And the next one 2, etc. Your $last_id values are totally ignored.)
And no recorded short URL will ever resolve, because they were recorded wrong.
Solution: simple.
Make shorturl_link.lid an int; that's what it is. (There's no requirement for primary keys to be serials.)
Comment | File | Size | Author |
---|---|---|---|
#4 | shorturl_schema2a.patch | 1.37 KB | roderik |
#3 | shorturl_remove_serial.patch | 828 bytes | seanburlington |
#1 | shorturl_schema2.patch | 1.51 KB | roderik |
shorturl_schema.patch | 975 bytes | roderik |
Comments
Comment #1
roderikActually (I should have checked this earlier...)
While you're busy, can you use the below patch instead of the one in my first message?
The length definition for your number columns does not do anything - except it makes schema.module complain about a "mismatch" between the definition and the actual database.
Comment #2
seanburlington CreditAttribution: seanburlington commentedYep - this bug completely breaks new installs of this module.
If you have upgraded from a previous version so that max(lid) is already greater than SHORTURL_START_FROM it will probably work
But otherwise all your links will be broken.
Comment #3
seanburlington CreditAttribution: seanburlington commentedConfirmed that with this change (making the lid column int not serial) a new install now works
I've re-rolled the patch as the above didn't work for me
However this may be down to my code as I've already incorporated the patch at #520588: Implementing tracking and metrics
Comment #4
roderikMaybe it's because my diffs contained some weird lines? In that case, apologies.
Otherwise the patch in #3 is the same as the one in the original message. Please use this one instead -- for the reasons outlined in #1.
Comment #5
irakli CreditAttribution: irakli commentedFixed in the commit: http://drupal.org/cvs?commit=380576
Many thanks, roderik.
Comment #6
irakli CreditAttribution: irakli commented