Scott,
All theory, I believe. But I could some day decide I want to sell a product named
SUPERCALIFRAGILISTICEXPIALIDOCIOUS. I know, that's too long already, but you get the picture.
I'd say this is a real problem. We need to first stop user action from even reaching database. We
then need to at least warn users that the resultant auto-generated defaultVariantProductId(s) are
non-unique, and further tell them it's because they either have overly long base (virtual) product
Id or too many feature idCodes.
I'll put that in my TODO ASAP list.
Which is something I've been meaning to say to us folks in OFBiz community. Error messages in
OFBiz are probably too difficult for a hacker to decipher, let alone users. Slight exaggeration
there, but you get picture. :)
I'm trying to start a properly written (tech docs standard) "average driver's handbook (or
compendium if you got time)" with some "average drivers". Any interested, please let me know.
Cryptic error messages will be "corrected" along the way.
Jonathon
Scott Gray wrote:
Hi Jonathan
If the features are extending the product Id past 20 characters, a
different strategy would probably be required for auto id generation as
truncating the product id would most likely cause duplicate id errors.
I don't know how to best to approach this, but is this all theory or is
someone actually having problems with variant product Id lengths?
Regards
Scott
Jonathon -- Improov wrote:
Scott,
Oh hey, I think there's a "buffer overrun" bug of sorts here. The
codes I submitted doesn't confine the defaultVariantProductId to a max
length of 20? Not that the original codes does such a constraint. (Do
we do a delegator.getEntityFieldType("Product",
"id-ne").stringLength() to get max length?). Anyway, it's still pumped
back into database where it's truncated to max-length.
Still, it'll be good for the QuickAddVariants.ftl javascript to
display only defaultVariantProductId(s) of valid lengths.
Spin-off thought here. Currently, the defaultVariantProductId is of a
simplistic form <productId><separator><featureIdCodes>. Would anyone
want to further split up the <featureIdCodes>? I don't need to. If
anyone needs that, let me know.
Jonathon
Scott Gray wrote:
Hi
I actually said that we should do it if anyone had objections, but no
one did so that's why it went in as is. But yeah if over-running the
limit is a possibility then it should probably be changed. Perhaps
there should be some code in there anyway for coping with that
situation, if someones running that many features saving 1 character
might not be much of a bonus.
Regards
Scott
Jacopo Cappellato wrote:
I agree with Si.
Jacopo
Si Chen wrote:
Hey there -
This patch is a good idea, but I think Scott Gray suggested that
this "-" could be configured in a properties file, and I think
that's a good idea. Otherwise, if you have four or five features
you will easily overrun the 20-character productId key limit.
Keeping it in properties file is a good way to allow it to be
modified. Otherwise it's not very nice to have to go into the code
to do it.
Jonathon, you up for doing this and sending in another patch?
Si
------------------------------------------------------------------------
Subject:
svn commit: r495891 -
/ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java
From:
[EMAIL PROTECTED]
Date:
Sat, 13 Jan 2007 12:48:56 -0000
To:
[email protected]
To:
[email protected]
Author: jleroux
Date: Sat Jan 13 04:48:55 2007
New Revision: 495891
URL: http://svn.apache.org/viewvc?view=rev&rev=495891
Log:
A patch from Jonathon Wong "Prepend feature idCodes with '-'"
(https://issues.apache.org/jira/browse/OFBIZ-620)
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java?view=diff&rev=495891&r1=495890&r2=495891
==============================================================================
---
ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java
(original)
+++
ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java
Sat Jan 13 04:48:55 2007
@@ -227,7 +227,7 @@
List newFeatures = new LinkedList();
List newFeatureIds = new LinkedList();
if
(currentFeature.getString("idCode") != null)
-
newCombination.put("defaultVariantProductId", productId +
currentFeature.getString("idCode"));
+
newCombination.put("defaultVariantProductId", productId + "-" +
currentFeature.getString("idCode"));
else
newCombination.put("defaultVariantProductId", productId);
newFeatures.add(currentFeature);