Jump to content

File upload error - SQLSTATE[23000]: Integrity constraint violation


Karl_T
 Share

Recommended Posts

Every time I upload multiple images to any image fields at the same time, no matter I drag multiple or choose multiple images, most files randomly not uploaded. Most of the time only the first image is uploaded.

The error message is 

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2276-0' for key 'PRIMARY' INSERT INTO `field_images` (pages_id, sort, `data`, `description`, `modified`, `created`) VALUES(2276, 0, 'twitter-1.svg', '[\"\"]', '2017-05-28 13:04:54', '1970-01-01 08:00:10')

So, it seem like this is because of the duplicated sort index. If I drag images into the field or choose the images one by one, there is no issue. That means when multiple files are uploaded, the sort index generated are the same most of the time.

This most likely is PW side issue, but I tested this in a fresh installed PW without issues. This just happens in that particular server. I have updated PW to latest from 3.060 to 3.063dev. The issue still persists. Thanks.

Link to comment
Share on other sites

16 minutes ago, Karl_T said:

This most likely is PW side issue, but I tested this in a fresh installed PW without issues. This just happens in that particular server. I have updated PW to latest from 3.060 to 3.063dev. The issue still persists. Thanks.

If you are not having this problem on a fresh install but only on one particular PW installation, how are you sure that this is a PW side issue?

Link to comment
Share on other sites

Thanks for your reply. The issue seems to be the duplication of sort index. I think the sort index is generated and then handled by PW, isn't it? Would you mind telling me any other possibilities so that I can check on them?

Link to comment
Share on other sites

Normally there cannot be a duplication of the sort index for the same pages_id. Before an Imagefield is stored all page related entries (pages_id == $page->id) are deleted first from the database before the new sorted images are stored (@see /wire/core/FieldtypeMulti.php) .Try to clear manually all related entries from the database and try again.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Hi All,

I've been having this issue lately and I'm not sure where to start looking.
We aren't running Redis, so it's not resolved by the link @Karl_T linked above.

Sometimes multiple images upload fine, sometimes i get this:

599c4ba9da249_ScreenShot2017-08-22at11_19_52AM.thumb.png.fee6b202e72184c8b5d8baab07645c3f.png

Any guidance would be much appreciated. 

Processwire 2.8.62
PHP 5.6.25
MySQL 5.0.11

 

Link to comment
Share on other sites

I had one of the admins at our host explore possibilities on their side. Basically they came back with nothing and suggested I continue to explore this as a ProcessWire issue. Anyone have any additional thoughts on this? 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...