I have a rule which calls my media type.
media type is panelized
if the rule saves the content multiple times I get the error below.
If I remove panelizer from my media_type the error goes away.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node-124-343-page_manager' for key 'PRIMARY': INSERT INTO {panelizer_entity} (entity_type, entity_id, revision_id, name, no_blocks, css_id, css, pipeline, contexts, relationships, did, view_mode, css_class, title_element, link_to_entity, extra) 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, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array
(
[:db_insert_placeholder_0] => node
[:db_insert_placeholder_1] => 124
[:db_insert_placeholder_2] => 343
[:db_insert_placeholder_3] => node:sng_media:default
[:db_insert_placeholder_4] => 0
[:db_insert_placeholder_5] =>
[:db_insert_placeholder_6] =>
[:db_insert_placeholder_7] => standard
[:db_insert_placeholder_8] => a:0:{}
[:db_insert_placeholder_9] => a:0:{}
[:db_insert_placeholder_10] => 0
[:db_insert_placeholder_11] => page_manager
[:db_insert_placeholder_12] =>
[:db_insert_placeholder_13] => H2
[:db_insert_placeholder_14] => 1
[:db_insert_placeholder_15] => a:0:{}
)
in drupal_write_record() (line 7219 of /var/aegir/platforms/7/servers/sng-contrib/sng-d7.27-oa-2.16/includes/common.inc).

CommentFileSizeAuthor
#12 panelizer-n2248781-12.patch702 bytesDamienMcKenna
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SocialNicheGuru’s picture

DamienMcKenna’s picture

I don't think this is related to #2248275: hook_entity_update has no 'did' value, the problem seems to be that hook_entity_update isn't correctly identifying the $update items, so it's attempting to create a new record instead of updating an existing record. Could you please modify the function so that it looks like the following:

  public function hook_entity_update($entity) {
    list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
    if (!$this->is_panelized($bundle)) {
      return;
    }

    // If there's no panelizer information on the entity then there is nothing
    // to do.
    if (empty($entity->panelizer)) {
      return;
    }
    dpm($entity->panelizer);

Then expand the $entity->panelizer array and me know (screenshots work) what it contains.

DamienMcKenna’s picture

Title: Integrity constraint violation: 1062 Duplicate entry node-124-343-page_manager for key PRIMARY INSERT INTO {panelizer_entity} » "Integrity constraint violation" error updating file entities
Status: Active » Postponed (maintainer needs more info)
primozsusa’s picture

I have similar problems. It works on dev but not in production because it seams panelizer config is not exported imported properly by features ... ??

primozsusa’s picture

what is panelizer inserting on the content edit? this is happening randomly on the same node but most of the time it is not working...
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node-36-36-default' for key 'PRIMARY': INSERT INTO {panelizer_entity} (entity_type, entity_id, revision_id, name, no_blocks, css_id, css, pipeline, contexts, relationships, did, view_mode, css_class, title_element, link_to_entity, extra) 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, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 36 [:db_insert_placeholder_2] => 36 [:db_insert_placeholder_3] => node:nc_activity:default:default [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => standard [:db_insert_placeholder_8] => a:0:{} [:db_insert_placeholder_9] => a:0:{} [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => default [:db_insert_placeholder_12] => [:db_insert_placeholder_13] => H2 [:db_insert_placeholder_14] => 1 [:db_insert_placeholder_15] => a:0:{} ) in drupal_write_record() (line 7194 of .../includes/common.inc).

primozsusa’s picture

It seams that this "Integrity constraint violation" problem might be related with "entitycache" in my case everything works ok with "entitycache" module being disabled..

primozsusa’s picture

For me the problem are revisions: in PanelizerEntityDefault.class.php hook_entity_update

because $this->supports_revisions is true and this $panelizer->revision_id != $revision_id is true
update variable is not set and there goes "Integrity constraint violation" in drupal_write_record

      if ($this->supports_revisions) {
        if (empty($panelizer->revision_id) || $panelizer->revision_id != $revision_id) {
          $panelizer->revision_id = $revision_id;
          $update = array();
        }
        else {
          $update = array('entity_type', 'entity_id', 'revision_id', 'view_mode');
        }
      }

Because i don't know what caused the revisions to be broken (ids) its easier for me to just disable and delete revisions to solve this..

broeker’s picture

EDIT: I didn't read the original issue closely (just saw the same error message) -- in our case, this is happening on a regular node save, not a file entity, and we do not currently have revisioning enabled. I'll leave this here for now but wondering if it needs a new issue instead.

We are running the latest DEV version of Panelizer, and are also getting this error repeatedly:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node-1924-1924-page_manager' for key 'PRIMARY': INSERT INTO {panelizer_entity} (entity_type, entity_id, revision_id, name, no_blocks, css_id, css, pipeline, contexts, relationships, did, view_mode, css_class, title_element, link_to_entity, extra) 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, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 1924 [:db_insert_placeholder_2] => 1924 [:db_insert_placeholder_3] => node:unit_of_instruction:default [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => standard [:db_insert_placeholder_8] => a:0:{} [:db_insert_placeholder_9] => a:3:{i:0;a:6:{s:10:"identifier";s:71:"Taxonomy term from Node (on Node: Unit Grade Level [field_grade_level])";s:7:"keyword";s:25:"taxonomy_term_grade_level";s:4:"name";s:54:"entity_from_field:field_grade_level-node-taxonomy_term";s:5:"delta";s:1:"0";s:7:"context";s:9:"panelizer";s:2:"id";i:1;}i:1;a:6:{s:10:"identifier";s:11:"Term parent";s:7:"keyword";s:11:"parent_term";s:4:"name";s:11:"term_parent";s:4:"type";s:6:"parent";s:7:"context";s:69:"relationship_entity_from_field:field_grade_level-node-taxonomy_term_1";s:2:"id";i:1;}i:2;a:6:{s:10:"identifier";s:13:"Term parent 2";s:7:"keyword";s:13:"parent_term_2";s:4:"name";s:11:"term_parent";s:4:"type";s:3:"top";s:7:"context";s:26:"relationship_term_parent_1";s:2:"id";i:2;}} [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => page_manager [:db_insert_placeholder_12] => [:db_insert_placeholder_13] => H2 [:db_insert_placeholder_14] => 1 [:db_insert_placeholder_15] => a:4:{s:24:"panels_breadcrumbs_state";i:1;s:25:"panels_breadcrumbs_titles";s:11:"%node:title";s:24:"panels_breadcrumbs_paths";s:6:"<none>";s:23:"panels_breadcrumbs_home";i:1;} ) in drupal_write_record() (line 7356 of /data/disk/o1/static/drupal-7.26-prod/includes/common.inc).

As per the above message, we are also running Entity Cache module -- so far in limited testing I cannot trigger the error when Entity Cache is disabled, and it returns when re-enabled.

dags’s picture

This exception appears for me when saving a Panelized node with "Create new revision" unchecked. Checking "Create new revision" appears to circumvent the issue. Fortunately for me, my requirements need revisioning turned on.

I'm trying to get Panelizer to play nice with Workbench Moderation by following the instructions in this article. So I'm using the latest dev snapshot of Panelizer and Workbench Moderation 1.3 with both patches (see link) applied to the modules. And I'm implementing hook_node_update() as suggested in the article.

UPDATE: Actually, I only had the workbench_moderation patch applied when I first got the error. Then I applied the panelizer patch and no error. But I had also checked "Create new revision" so I can't be sure exactly what fixed the issue for me.

broeker’s picture

Update:

We enabled automatic revisioning on the client site where we were continually seeing this error, and it seems to have worked. They've had a team of 10-12 people hitting the site all day and no errors at all since we enabled revisions (Entity Cache remains enabled). Thanks to Dags for the tip on that one.

drupov’s picture

I have a similiar issue (don't really know if it belongs here).

I am updating entity reference fields on a panelized content type through VBO and a custom rule (the rule simply reads the value from one field and writes it into another one).

When I update a single record everything works fine.

But for more than one record I get following error:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=351&op=do StatusText: Service unavailable (with message) ResponseText: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node-4063-4063-default' for key 'PRIMARY': INSERT INTO {panelizer_entity} (entity_type, entity_id, revision_id, name, no_blocks, css_id, css, pipeline, contexts, relationships, did, view_mode, css_class, title_element, link_to_entity, extra) 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, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 4063 [:db_insert_placeholder_2] => 4063 [:db_insert_placeholder_3] => node:person:default:default [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => standard [:db_insert_placeholder_8] => a:0:{} [:db_insert_placeholder_9] => a:0:{} [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => default [:db_insert_placeholder_12] => [:db_insert_placeholder_13] => H2 [:db_insert_placeholder_14] => 1 [:db_insert_placeholder_15] => a:0:{} ) in drupal_write_record() (line 7194 of /var/www/site1/includes/common.inc).

DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
702 bytes

I've finally reproduced this. It turns out that the problem was in hook_entity_load.

DamienMcKenna’s picture

FYI the error in hook_entity_load was caused by it not reloading the $revision_id variable during the final foreach() loop, it was using an old copy of the variable which then threw off hook_entity_update.

DamienMcKenna’s picture

DamienMcKenna’s picture

  • Commit ed877b9 on 7.x-3.x by DamienMcKenna:
    Issue #2248781 by DamienMcKenna: hook_entity_load was not resetting $...
DamienMcKenna’s picture

Status: Needs review » Fixed

Committed!

DamienMcKenna’s picture

Status: Fixed » Closed (fixed)

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