Closed (fixed)
Project:
Ubercart
Version:
7.x-3.4
Component:
Documentation
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 May 2013 at 12:11 UTC
Updated:
29 May 2013 at 08:41 UTC
Hi,
I am using cart links to create a custom product experience. Now I was using cart links to track stuff, and had build a cart link as follows:
an example url is /cart/add/e-p119_q1-iAlmeerderhout%20leden%20golfclub?destination=cart/checkout
However, the index is longer than 32 characters, resulting in a PDOException:
String data, right truncated: 1406 Data too long for column 'cart_link_id' . I solved it by increasing the length of the field to 255, but I don't think that is the way to go.
Comments
Comment #1
longwaveWe should either truncate the cart links ID at 32 characters, or increase the length of the field (and still truncate longer ones). Maybe 64 or 128 characters is more useful?
Comment #2
longwaveDuplicate post
Comment #3
tr commentedThe index is just a unique identifier used to track an ad campaign, special offer, affiliate, etc - it's not meant to hold a product name (that information is part of the product node, so it's available from the nid).
The only thing I think needs to be done here is to make sure the documentation spells out the limitation on id length.
Comment #4
longwaveWe should at least truncate them to avoid the reported error message.
Comment #5
longwaveFixed in http://drupalcode.org/project/ubercart.git/commitdiff/61d0a52
Comment #6
tr commentedI just noticed that the documentation already contains the information that the index is limited to 32 characters, describing the index as "An alphanumeric string (32 characters max) to identify the link."
I'm not sure that truncating is the way to go. More generally, we probably need a way to validate cart links, but that would still require the administrator to proactively validate before publishing the cart link - it's not something we can guarantee will be done. Thus, even validation would not prevent an administrator from publishing an invalid link. The question then becomes what should happen when an invalid link is clicked? Should it silently try to recover (which is what truncation does) or should it just silently log an error into the dblog to let the admin know he made a mistake? Displaying a PDO exception is of course the wrong thing to do, but shouldn't there be some notice to the customer that the link was invalid and the action could not be completed?
Comment #7
longwaveAs this only involves cart link tracking, if somehow an invalid (too long) ID is attempted to be used, I think "doing the right thing" is truncating it so the customer gets the desired result - the product is added to their cart. The only possible side effect is misreported tracking, but if the same incorrect link is used twice or more, they will still be tracked as the same ID. Adding a watchdog entry would let the admin know this has actually happened, but I don't see the point in notifying the customer when it has no effect on them.