Got this when trying to add a contact, this was from a fresh install, all modules enabled, all I did was create a contact type called 'client' and tried to add one. Tried a few times with different data, always the same result.

/redhen/contact/add/client

Integrity constraint violation: 1062 Duplicate entry '4' for key 'PRIMARY': INSERT INTO {redhen_contact_revision}

Module is looking good though, Drupal has been sorely lacking this for a long time.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

levelos’s picture

Status: Active » Closed (cannot reproduce)

Can't reproduce. Please try again with the latest code base.

rHOnDO’s picture

Component: Current » Shared

Same issue and I am using the 7.x-1.x-dev dated 2012-Sep-17.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '29' for key 'PRIMARY': INSERT INTO {redhen_contact_revision} (contact_id, revision_id, author_uid, first_name, last_name, redhen_state, updated) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => 28 [:db_insert_placeholder_1] => 29 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => Bruce [:db_insert_placeholder_4] => Wayne [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1349195326 ) in drupal_write_record() (line 7036 of /var/aegir/.../includes/common.inc)

rHOnDO’s picture

Status: Closed (cannot reproduce) » Active

See my post above (#2)

rHOnDO’s picture

Tried again today with the Oct. 2nd dev version.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '33' for key 'PRIMARY': INSERT INTO {redhen_contact_revision} (contact_id, revision_id, author_uid, first_name, last_name, redhen_state, updated) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => 32 [:db_insert_placeholder_1] => 33 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => Robert [:db_insert_placeholder_4] => Redfern [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1349308079 ) in drupal_write_record() (line 7036 of /var/aegir/.../includes/common.inc).

levelos’s picture

Status: Active » Closed (cannot reproduce)

Still unable to recreate. My guess is that are lingering tables/data from an old version. When you say fresh install, are you sure you deleted the entire database before reinstalling? We've got hundreds of users at this point and no one else is reporting this issue ...

stevep’s picture

Same problem

Fresh install = new database + "minimal" modules enabled, including pathauto, token etc.

Modules:

Redhen 7.x-1.0-beta3+2-dev 2012-Oct-27
Entity API 7.x-1.0-rc3+11-dev 2012-Oct-24
on Ubuntu local server PHP 5.3.10-1ubuntu3.4

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '4' for key 'PRIMARY': INSERT INTO {redhen_contact_revision} (contact_id, revision_id, author_uid, first_name, last_name, redhen_state, updated) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => 4 [:db_insert_placeholder_1] => 4 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => Fred [:db_insert_placeholder_4] => Nirk [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1351372483 ) in drupal_write_record() (line 7036 of /var/www/drupal7/includes/common.inc).

-----------------------> Update

Installed RedHen CRM Demo (7.x-1.x-dev | 2012-Oct-19 ) working fine. Above problem appears related to incorrect setup.

valderama’s picture

Having the same issue here.

valderama’s picture

Status: Closed (cannot reproduce) » Active

I could "solve" the issue by removing the drupal_write_record call in the contact entity controller (line 45). It seems as the revision of the new contact was about to be created twice - therefor the duplicate PRIMARY key. The error is gone then, and I can create contacts without any problem. Also a revision entry for each contact is created in the redhen_contact_revision table.

I do not know much about the internals of entities, but might it be possible that latest dev of Entity API may takes care of creating the revisions already?

valderama’s picture

See also this issue over there at Entity API about revisions. Seems revision support got into dev - somewhat silently: http://drupal.org/node/996696

valderama’s picture

Status: Active » Needs review
FileSize
718 bytes
valderama’s picture

Was a bit to fast with the first patch. This one now takes care of correct revision creation on update.

valderama’s picture

Title: Integrity constraint violation » Use Entity APIs new revision support

Changing title

seanberto’s picture

Priority: Normal » Major

Bumping priority. We'll address this asap. (Hectic two weeks here with the holidays....)

seanberto’s picture

Assigned: Unassigned » bleedev
seanberto’s picture

nedjo’s picture

I'm getting this error in the Debut RedHen app after updating to Entity 1.0. This is a blocker for a new Open Outreach release, see #1874958: Issue RC8 Open Outreach release with security updates.

nedjo’s picture

Quick untested update to patch. Looks to contain a stray change, but I don't have time ATM to fix.

levelos’s picture

Status: Needs review » Fixed

Thanks @nedjo, that works great. Committed.

jhoffmcd’s picture

I've been getting this error when trying to update a contact through a relations endpoint:

Notice: Undefined property: stdClass::$revision_id in drupal_write_record() (line 7030 of ...\www\includes\common.inc).
Notice: Undefined property: RedhenContact::$revision_id in EntityAPIController->saveRevision() (line 525 of ...\www\sites\all\modules\entity\includes\entity.controller.inc).
Notice: Undefined index: revision_id in EntityAPIController->saveRevision() (line 528 of ...\www\sites\all\modules\entity\includes\entity.controller.inc).
Notice: Undefined index: revision_id in EntityAPIController->saveRevision() (line 533 of ...\www\sites\all\modules\entity\includes\entity.controller.inc).
DatabaseTransactionNoActiveException: in DatabaseConnection->rollback() (line 1024 of ...\www\includes\database\database.inc).

I though it might be related to this patch but when I used it I now get:

Fatal error: Class 'RedhenContactEntityController' not found in ..\www\includes\common.inc on line 7679

Now I'm not sure whether or not I just didn't apply the patch right... Am I right in assuming my original errors were caused by the issue discussed in this post?

EDIT: This did work for me, the error that I got was from the file's permissions being changed for some reason.

danielbeeke2’s picture

How to use these revisions?
I have searched the code for clues, but it looks partly intergrated with the dev version.

nedjo’s picture

How to use these revisions?

This patch didn't add any UI elements but just switched out some custom handling for the new Entity API CRUD handling of revisions. What's done with revisions is still the same as before: each time an edit is made, it's saved as a new revision.

We would need new issues and patches for things like:

  • Make saving a new revision optional.
  • Enable browsing of past revisions.
danielbeeke2’s picture

Ah I see, thanks!

Status: Fixed » Closed (fixed)

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

  • Commit 7ac73af on 7.x-1.x, tests, redhen-donation authored by nedjo, committed by levelos:
    #1592686 by nedjo: Use Entity APIs new revision support.
    

  • Commit 7ac73af on 7.x-1.x, tests, redhen-donation, relation-roles authored by nedjo, committed by levelos:
    #1592686 by nedjo: Use Entity APIs new revision support.