The update hook to update the permissions is using an invalid value for the N in the function name.

In some installs the update would cause this mysql error:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3-administer field collections' for key 'PRIMARY' because the update doesn't get registered properly as an update to the initial install

field_collection_7000 should be field_collection_7001 and then increase from that point.

the 7000 is reserved for the initial 7.x install.

CommentFileSizeAuthor
field_collection_install_N_fix.patch552 bytescntlscrut
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kmare’s picture

Hello,
with the latest dev from 2012-Jan-11, I was getting that error too. cntlscrut, using your patch, nothing really changed as I'm still getting the very same error. Any ways I could help to track that error down?
Thank you in advance.

Michael-IDA’s picture

The following updates returned messages
field_collection module
Update #7000

    * Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3-administer field collections' for key 'PRIMARY': UPDATE {role_permission} SET permission=:db_update_placeholder_0 WHERE (permission = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => administer field collections [:db_condition_placeholder_0] => administer field-collections ) in field_collection_update_7000() (line 56 of /var/www/html/sites/all/modules/field_collection/field_collection.install).

Version : 7.x-1.0-beta3

After patch:

The following updates returned messages
field_collection module
Update #7001

    * Failed: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3-administer field collections' for key 'PRIMARY': UPDATE {role_permission} SET permission=:db_update_placeholder_0 WHERE (permission = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => administer field collections [:db_condition_placeholder_0] => administer field-collections ) in field_collection_update_7001() (line 56 of /var/www/html/sites/all/modules/field_collection/field_collection.install).

Really looks like it's an SQL bug, not the function name being wrong.

Pretty much messes up /admin/reports/updates as well. "$ drush pm-update" seems okay though.

Best,
Sam

tim.plunkett’s picture

Priority: Major » Normal

A patch would be nice. I think we might need to write a new 7001 function that does the same as 7000 but only if that one wasn't run.

jantoine’s picture

This error is not due to the update function being named incorrectly, although that is a bug and should be fixed!

This error is occurring because before the update function is run, Drupal has already recognized that the Field Collection module has a new permission 'administer field collections' and has assigned that permission to the administrator role! If the update function is run after this takes place, the update attempts to create a duplicate entry for the administrator role and this new permission. This update fails because the primary key consists of the rid and permission fields.

I think a proper solution could be to delete any permissions associated with the administrator role before running this update query.

_redfog’s picture

I confirmed by unchecking administrator's permissions for field collection module, then apply update, worked for me.
See #4

jmuzz’s picture

Issue summary: View changes
Status: Active » Closed (outdated)