[ic] Bug found: get_cart with merge=1

Mike Heins mike at perusion.com
Sat Mar 5 14:03:38 EST 2005

Quoting Brian Kaney (brian at vermonster.com):
> On Sun, 2005-02-27 at 20:19, brian at vermonster.com wrote:
> > Hello,
> > 
> > I am on IC 5.2 and think I've discovered a bug with the userdb get_cart function
> > with the merge="1" flag.
> > 
> > Consider a saved cart consisting of a master item with one or more sub-items.  A
> > user imports this saved cart twice.  Deleting one of the master items causes
> > all the sub-items are deleted.
> > 
> > I looked in the [dump] and noticed that the mv_mi id's for the two groups are
> > the same.  It seems that get_cart with merge="1" does not consider the mv_mi
> > values of items already in the shopping cart.  It should and I believe this is
> > a bug.
> > 
> I solved this by creating a usertag that looks into a user's saved carts
> and finds the maximum mv_mi.  I then increment this and loop around the
> items in the cart, forcing the mv_mi the new max value.  Then I save the
> cart using the save_cart tag:
> [perl userdb]
>    my $max = $Tag->mvmi_max();
>    foreach my $item (@$Items) { $item->{'mv_mi'} = $max + 1; }
> [/perl]
> [save_cart nickname="[cgi cart_nickname]" hide="1"]

I had this on my list of things to think about. It occurred to me that a
good way to set the mv_mi value might be the UNIX time of the submission
plus a series of digits -- that should be completely unique within a user
and would prevent possible conflict on merged carts. So I did that.

I also wrote a routine to add to the get_cart merge function which makes
sure you won't merge a group with the same number -- that probably is
no longer needed, but I believe I have written routines before which
create their own mv_mi and that might save the problem then.

Both changes are in CVS.
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

Opportunity is missed by most people because it is dressed in
overalls and looks like work. -- Thomas Edison

More information about the interchange-users mailing list