Using Drush to update from 2.7 to 2.9:

Performed update: flexslider_picture_update_7001                     [ok]
WD php: PDOException: SQLSTATE[23000]: Integrity constraint          [error]
violation: 1062 Duplicate entry 'image__default__file_field_picture'
for key 'PRIMARY': INSERT INTO {file_display} (name, weight, status,
settings) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2, :db_insert_placeholder_3); Array
(
    [:db_insert_placeholder_0] => image__default__file_field_picture
    [:db_insert_placeholder_1] => 0
    [:db_insert_placeholder_2] => 1
    [:db_insert_placeholder_3] =>
a:4:{s:20:"fallback_image_style";s:0:"";s:10:"image_link";s:0:"";s:8:"colorbox";s:21:"***_mapping";s:15:"picture_mapping";s:21:"***_mapping";}
)
 in drupal_write_record() (line 7239 of
***/htdocs/includes/common.inc).

Note the **** are redactions.

So the actual 2.9 db change works, but then some other code tries to add the "image__default__file_field_picture" record and fails.

Because file_display table already has (and "name" field is the primary key):
name: image__default__file_field_picture
weight: -47
status: 0
settings: a:4:{s:15:"picture_mapping";s:21:"***_mapping";s:20:"fallback_image_style";s:5:"large";s:10:"image_link";s:0:"";s:8:"colorbox";s:21:"***_mapping";}

Thoughts?

Comments

rodrigoaguilera’s picture

I'm experiencing the same.
I'll go back to 2.7 until I have more idea about what is happening

rodrigoaguilera’s picture

Priority: Normal » Major
slippast’s picture

I'm experiencing what appears to be the same error (probably reported differently as I'm on Postgres). It happens when I flush cache or run update.php. It appears to happen when the registry_rebuild() function is run. For what it's worth here's my error from the Drupal log:

PDOException: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "file_display_pk_field_revision_node_example_quantity"

DETAIL: Key (name)=(image__default__file_field_picture) already exists.:

INSERT INTO file_display (name, weight, status, settings)
VALUES (
:db_insert_placeholder_0,
:db_insert_placeholder_1,
:db_insert_placeholder_2,
:db_insert_placeholder_3
);
Array ( ) in drupal_write_record() (line 7239 of /***/htdocs/includes/common.inc).

Edit: I rolled back to version 2.7 and everything is working again. The problem appears to have been introduced in version 2.8.

criznach’s picture

Do you also see picture listed twice on your file display view modes? If so, I think the issue is mentioned elsewhere in the queue. You may have had file entity 1.x installed at one time, and the displays are conflicting. I was able to work around it by deleting the conflicting rows in the file_display table, then executing this drush command:

drush vset picture_updated_to_file_entity_2 1

This forces picture to use the file_entity 2.x code. If that causes issues for you, set it back to zero:

drush vset picture_updated_to_file_entity_2 0

rodrigoaguilera’s picture

I'm having this problem on a clean install that has file entity module v2.
And I do see the 2 picture file formatters for media.
I guess my variable is not set. I'll check later.

Feels to me like an ugly way to give support to two versions of another module.
AFAIK what other modules did was releasing a new major version (picture 3.0) but those where media_xxxx and this module doesn't rely entirely on file entity module.

what about releasing the support for file entity inside picture as a separate submodule(Actually two submodules to give support to the two versions of file entity)?

rodrigoaguilera’s picture

Version: 7.x-2.9 » 7.x-2.x-dev
StatusFileSize
new840 bytes

As I suspected variable picture_updated_to_file_entity_2 ended up not being set.

The variable should be set at every event where the file_entity version is checked.

rodrigoaguilera’s picture

Status: Active » Needs review
loudmu’s picture

#6 failed still having the same errror message " PDOException: SQLSTATE[23000]: Integrity constraint ..."
violation: 1062 Duplicate entry

rodrigoaguilera’s picture

Can you give steps to reproduce with the patch applied?

attiks’s picture

Patch from #6 committed, can you test again with the new release?

attiks’s picture

Status: Needs review » Fixed

Assuming it is fixed

silkogelman’s picture

Picture 7.x-2.10 (including patch #6) did not fix this issue for me.
I wasn't even able to run a cache clear or cron because of this error.
However when I manually forced the variable to TRUE that fixed it (custom module with one line of code)
variable_set('picture_updated_to_file_entity_2', TRUE);

I'm hoping this is ok, as it seems it was trying to run a database query it already executed previously.

Not sure if this is still an issue for others (please reopen this issue if it is), so I don't want to put too much time into it at this point, but here's the gist of my config:

I had 2 sites with this error, but I am not able to reproduce this error on a clean install.
Both sites have this config:

file_entity 7.x-2.x-dev (latest)
Picture 2.? (not sure with what version I started, 2.9 or earlier)
Media module 7.x-2.x-dev (latest)
WYSIWYG module 7.x-2.x-dev (latest)
Varnish module

The error I had when running update.php or flushing cache:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'image__default__file_field_picture' for key 'PRIMARY': INSERT INTO {file_display} (name, weight, status, settings) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => image__default__file_field_picture [:db_insert_placeholder_1] => 0 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => a:4:{s:20:"fallback_image_style";s:17:"inline_content_tv";s:10:"image_link";s:0:"";s:8:"colorbox";s:23:"inline_article_image_pm";s:15:"picture_mapping";s:23:"inline_article_image_pm";} ) in drupal_write_record() (line 7308 of /var/www/xx/docroot/includes/common.inc).

attiks’s picture

Status: Fixed » Active
rodrigoaguilera’s picture

Then there's another place where the picture module assumes file entity is version 2 without checking and setting the variable first.

Or we think of a way to get rid of the variable altogether which seems like the cleanest option.

lesleyfernandes’s picture

Status: Active » Closed (outdated)

If anyone is still facing this issue, please let us know. For now, I am closing it because it is related to an old version of the module.