I received the following error code:

user warning: Duplicate entry '36' for key 'PRIMARY' query: INSERT INTO uc_files (fid,filename) VALUES (36,'homework.pdf') in C:\http\apache\htdocs\test\sites\all\modules\ubercart_marketplace\mp_file\mp_file.module on line 295.

Pretty sure that's not a good error. I received this a few times.

1) When I added another filefiled cck for a preview file and uploaded the same file as the "download" field.
2) When you upload a file, then create another node withe same file then hit upload and save before the file is fully uploaded. This node did not have an extra filefield.

A few other times but can't remember the reason why..

Another big one is if you add multiple uploads on "download" filefield, you get that error and if someone purchases the file, nothing shows up in the profile download section. Once this happens, pretty much you can't get any files you purchase after that happens.

For each error I started again from a new database until I got to that error.

CommentFileSizeAuthor
#5 873348-duplicate-key-in-uc-files.patch628 byteshanoii

Comments

aznboy’s picture

I tried this with a clean install of drupal with ubercart, ubercart marketplace, and cck filefield and was able to reproduce this. All other were not installed.

syndicateStorm’s picture

Thanks for the bug report. I'll try to run this down in the near future.

Regarding your last comment. At the moment Marketplace isn't capable of doing multiple simultaneous uploads. You can load an additional file each time you save the node just not all at the same time (there is a feature request for this).

I'll look into cases (1) & (2).

hanoii’s picture

subscribe

hanoii’s picture

Title: Error code » user warning: Duplicate entry 'xx' for key 'PRIMARY' query: INSERT INTO uc_files (fid,filename) VALUES ('xx','yy')

changing title to something more descriptive

hanoii’s picture

Status: Active » Needs review
StatusFileSize
new628 bytes

I think I have tracked this down as I was experiencing this same issue.

Attached is a patch for review.

Basically, I noticed that the files table fid was used to insert the file into uc_files, but this is not the proper way to go, as those IDs can get out of sync and be altogether differently. The thing that was actually triggering this is that there's a file in the download directory that get read and inserted into the uc_files on its own, and then, generating a new fid for uc_files, and when the module tries to insert the same fid on that table it fails. I think this change shouldn't affect any functionality but I must admit I haven't gone that deep but it's working for this. I will be working on fairly interesting site using ubercart marketplace so will report back if I find anything else related to this, but as I said, it seems to be working.

mottboy’s picture

Will try the patch out.

mottboy’s picture

Seems to be working fine. Haven't seen any errors as of late and had about 3 people test it. The actual original error we were able to duplicate and every new node would produce the error. Once the patch was applied it was resolved. Tested 2 purchases by 2 different user/role type and download, sales, etc was all complete.

Any other testing will update if we decide to use this module.

Thank you for the patch.

hanoii’s picture

Status: Needs review » Reviewed & tested by the community

let's push it a bit more then

mottboy’s picture

Yup, will test it out again this week and provide feedback.

truelyGood’s picture

I tested it. Works fine. I was able to generate the errors without the patch and then removed all nodes. Then I applied the patch and tried it out and completed an order and was able to download.

hanoii’s picture

Assigned: Unassigned » hanoii
Status: Reviewed & tested by the community » Fixed

committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.