Closed (fixed)
Project:
Ubercart
Version:
6.x-2.2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 May 2010 at 23:00 UTC
Updated:
30 Jul 2010 at 16:00 UTC
Jump to comment: Most recent file
On my FreeBSD 8.0-RELEASE-p1 system running the latest Drupal 6.x/Ubercart (as of this post) with PHP 5.3.2 w/php-fpm and MySQL 5.1.46 I had to change the uc_product_feature_save() function inside ubercart/uc_product/uc_product.module and do away with db_affected_rows() to stop having duplicate features created every time an existing feature was edited and saved.
My changed function here: http://drupalbin.com/14845
I'll post a patch soon.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | ubercart_uc_product_feature_save-6.x-2.2-0.2.patch | 1.41 KB | j0rd |
| #1 | ubercart_uc_product_feature_save-6.x-2.2.patch | 844 bytes | leprechau |
Comments
Comment #1
leprechau commentedHere is a patch for the current stable 6.x-2.2 version.
Comment #2
j0rd commentedThis is happening for me, and I'm Ubuntu 10.04 LTS. aka PHP 5.3, MySQL 5.x. I do not believe this is a PHP 5.3 issue though.
Here's how you can re-create the issue and later I'll explain why it's happening.
1. Create a new product.
2. Add a file feature to it and overwrite File Download Limit to 10.
3. Edit that feature and change the File Download Limit to 15.
Expected behavior:
Product Feature is updated.
Resulted behavior:
Duplicate and empty product feature is created.
Explanation into why:
uc_product_feature_save() is using db_affected_rows() to see if uc_product_feature entry has been updated and while it does get updated, the row does not change. In the database row pfid, nid, fid and description all remain the same. Thus I believe db_affected_rows() is returning 0...since nothing is really "affected". This is a minor issue with the database layer. Perhaps mysql specific.
To test this theory do something like change the description of the original product feature and you'll notice that a new entry is not created, instead the desired behavior happens. Why is this? Because the row is updated and "description" column changes, thus db_affected_rows() returns 1.
I've improved leprechau's patch to avoid an additional query that can be avoided in certain use cases.
--
Ubercart Themes
Comment #3
j0rd commentedCan also confirm this has not been resolved in -dev.
Comment #4
Island Usurper commentedGood catch. Fortunately, this will be simpler in D7 because db_merge() takes care of this logic for us.
Committed.