PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node_view__product_display' for key 'name': INSERT INTO {page_manager_handlers} (name, task, subtask, handler, weight, conf) 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); Array ( [:db_insert_placeholder_0] => node_view__product_display [:db_insert_placeholder_1] => node_view [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => panel_context [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => a:12:{s:5:"title";s:22:"Custom Product Display";s:9:"no_blocks";i:0;s:8:"pipeline";s:8:"standard";s:22:"body_classes_to_remove";s:0:"";s:19:"body_classes_to_add";s:0:"";s:6:"css_id";s:0:"";s:3:"css";s:0:"";s:8:"contexts";a:0:{}s:13:"relationships";a:0:{}s:4:"name";s:15:"product_display";s:6:"access";a:2:{s:7:"plugins";a:1:{i:0;a:4:{s:4:"name";s:9:"node_type";s:8:"settings";a:1:{s:4:"type";a:1:{s:15:"product_display";s:15:"product_display";}}s:7:"context";s:25:"argument_entity_id:node_1";s:3:"not";b:0;}}s:5:"logic";s:3:"and";}s:3:"did";s:1:"2";} ) in drupal_write_record() (line 7239 of /var/www/mysite/htdocs/includes/common.inc).

Comments

dan_metille’s picture

Getting the same here.

damienmckenna’s picture

Version: 7.x-3.5 » 7.x-3.x-dev

This was reported in the Panels Everywhere issue queue too: #2422189: Error when cloning a variant

damienmckenna’s picture

Another related issue, this time for Panelizer: #2445769: Unable to clone a display

damienmckenna’s picture

joel_osc’s picture

I think I may have an idea on this one. The following patch #813754-44: Ability to set variant machine name in Panels UI made some changes to how machine names are handled for tasks. It allows for a name to be passed in from the form instead of automatically generated. On cloning unfortunately the task name is identical to the variant being cloned which triggers the error. I briefly tested the following change to the clone/import code - adding lines 451 to 454 in page_manager.module:

    441 function page_manager_handler_add_to_page(&$page, &$handler, $title = NULL) {
    442   $last = end($page->handler_info);
    443   $handler->weight = $last ? $last['weight'] + 1 : 0;
    444   $handler->task = $page->task_id;
    445   $handler->subtask = $page->subtask_id;
    446   $handler->export_type = EXPORT_IN_DATABASE;
    447   $handler->type = t('Normal');
    448 
    449   if ($title) {
    450     $handler->conf['title'] = $title;
    451     $handler->conf['name'] = preg_replace('/[^a-z0-9_]+/', '-', strtolower($title));
    452   }
    453   else {
    454     $handler->conf['name'] = '';
    455   }
    456 
    457   $name = page_manager_handler_get_name($page->task_name, $page->handlers, $handler);
    458 
    459   $handler->name = $name;
    460 
    461   $page->handlers[$name] = $handler;
    462   $page->handler_info[$name] = array(
    463     'weight' => $handler->weight,
    464     'name' => $handler->name,
    465     'changed' => PAGE_MANAGER_CHANGED_CACHED,
    466   );
    467 }

Essentially this passes in a machine name if the title is available and nothing if a title is not available so that a unique name based on UUID will be created. I briefly tested cloning and importing and they seem to work, however I would like some thoughts or suggestions from others that may know this code a bit better before posting a patch.

lanceh1412’s picture

I think you are right there. I don't know much about panels code but stepped through it yesterday and came to the same conclusion about where a fix was needed. I'll paste that code in and test it out.

joel_osc’s picture

Project: Panels » Ctools
Version: 7.x-3.x-dev »
Status: Active » Needs review
StatusFileSize
new575 bytes

I am going to move this to the ctools issue queue (hope that is okay!) since I believe the issue is in the page_manager code and provide a patch for the community to have a look at.

damienmckenna’s picture

Project: Ctools » Chaos Tool Suite (ctools)
Version: » 7.x-1.x-dev

That older project is the wrong one, this is the correct ctools ;)

damienmckenna’s picture

Status: Needs review » Needs work
damienmckenna’s picture

Status: Needs work » Needs review

Trying to trigger the testbot.

damienmckenna’s picture

Could you please test the latest -dev release, see if the problem persists?

damienmckenna’s picture

FYI I tested this with the current -dev releases of Panels and CTools and wasn't able to reproduce the problem.

emcniece’s picture

Still hitting this with fresh dev versions of Panelizer, Panels, and ctools.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'site_template__basic_sidebar_layout' for key 'name': INSERT INTO {page_manager_handlers} (name, task, subtask, handler, weight, conf) 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); Array ( [:db_insert_placeholder_0] => site_template__basic_sidebar_layout [:db_insert_placeholder_1] => site_template [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => panel_context [:db_insert_placeholder_4] => -27 [:db_insert_placeholder_5] => a:12:{s:5:"title";s:20:"Basic Sidebar Layout";s:9:"no_blocks";i:1;s:8:"pipeline";s:8:"standard";s:22:"body_classes_to_remove";s:0:"";s:19:"body_classes_to_add";s:0:"";s:6:"css_id";s:0:"";s:3:"css";s:0:"";s:8:"contexts";a:0:{}s:13:"relationships";a:0:{}s:4:"name";s:20:"basic_sidebar_layout";s:6:"access";a:2:{s:7:"plugins";a:1:{i:0;a:3:{s:4:"name";s:5:"front";s:8:"settings";N;s:3:"not";b:1;}}s:5:"logic";s:3:"and";}s:3:"did";s:2:"18";} ) in drupal_write_record() (line 7261 of /var/www/clients/client0/web28/web/includes/common.inc).

joel_osc’s picture

Just to confirm, I am still seeing it too on the latest dev:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node_view__news' for key 'name': INSERT INTO {page_manager_handlers} (name, task, subtask, handler, weight, conf) 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); Array ( [:db_insert_placeholder_0] => node_view__news [:db_insert_placeholder_1] => node_view [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => panel_context [:db_insert_placeholder_4] => 101 [:db_insert_placeholder_5] =>

The patch still applies on the latest dev and fixes the issue.

Anonymous’s picture

The patch in #7 worked for me: Chaos tools 7.x-1.7, Panels 7.x-3.5. I don't have Panelizer. I'm going to leave the status as it is—I'm pretty new to Drupal and am not sure I have sufficient expertise to test the patch.

Here's the error I was seeing previously:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'node_view__sandbox_node' for key 'name': INSERT INTO {page_manager_handlers} (name, task, subtask, handler, weight, conf) 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); Array ( [:db_insert_placeholder_0] => node_view__sandbox_node [:db_insert_placeholder_1] => node_view [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => panel_context [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => a:12:{s:5:"title";s:12:"Sandbox view";s:9:"no_blocks";i:0;s:8:"pipeline";s:8:"standard";s:22:"body_classes_to_remove";s:0:"";s:19:"body_classes_to_add";s:0:"";s:6:"css_id";s:0:"";s:3:"css";s:0:"";s:8:"contexts";a:1:{i:0;a:4:{s:10:"identifier";s:19:"View: System Status";s:7:"keyword";s:4:"view";s:4:"name";s:35:"view:system_status-ctools_context_1";s:2:"id";i:1;}}s:13:"relationships";a:0:{}s:4:"name";s:12:"sandbox_node";s:6:"access";a:2:{s:7:"plugins";a:1:{i:0;a:3:{s:4:"name";s:5:"theme";s:8:"settings";a:1:{s:5:"theme";s:7:"working";}s:3:"not";b:0;}}s:5:"logic";s:3:"and";}s:3:"did";s:1:"9";} ) in drupal_write_record() (line 7261 of /var/www/html/includes/common.inc).

matholum’s picture

Status: Needs review » Reviewed & tested by the community

Same thing for me as with #15. I'm using Chaos tools 7.x-1.7 and Panels 7.x-3.5 with nothing else. Once I learned how to patch it worked perfectly. Thanks for the fix! ^_^

damienmckenna’s picture

I've confirmed that this patch resolves the problem for closing Panels Everywhere displays.

dillix’s picture

#7 Fix issue for me, please commit it.

fluxline’s picture

works for me, cheers.

joelpittet’s picture

RTBC++

lwwalker’s picture

#7 was working for me, but has since stopped. Has anyone else had the patch stop working? I've tried reinstalling the module and patching it again, but no luck.

  • japerry committed 3b3b003 on 7.x-1.x authored by joel_osc
    Issue #2445203 by joel_osc: Error trying to clone a variant
    
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Yup, tested this all week, looked good to me!

maximpodorov’s picture

Oh, thanks a lot. With this bug, the following ugly workarounds were necessary:
http://cgit.drupalcode.org/entity_panels/commit/?id=cf7e65d

maximpodorov’s picture

Status: Fixed » Active

The patch doesn't fix the problem of cloning. The clone can have the same title as the original, so the name becomes the same as the original also.

maximpodorov’s picture

Moreover, when non-English letters are used for variant title, this title transforms into empty name which break cloning again.

damienmckenna’s picture

Status: Active » Fixed

@maximpodorov: I suggest creating a new issue for this problem.

damienmckenna’s picture

FYI in the Panelizer world a patch was added to improve the cloning process: #2480999: Machine name on panlizer clone form doesn't autocomplete

maximpodorov’s picture

I think this problem can be solved here, it doesn't differ from the original description.

maximpodorov’s picture

Status: Fixed » Active
dillix’s picture

+1

maximpodorov’s picture

Status: Active » Needs review
StatusFileSize
new1.29 KB

The patch solves the problem by checking new name existence in the DB.

juc1’s picture

I am getting "PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry..." when cloning a variant. @ maximpodorov is your patch in in #32 in addition to the patch in #7 or instead?

lwwalker’s picture

#32 confirmed works. Only #32, not in addition to #7.

maximpodorov’s picture

#7 is already committed. Patch #32 is for the current dev branch.

sylus’s picture

Status: Needs review » Fixed

This patch worked for me as well and seems pretty reasonable to mark as RTBC given it just checks if name is being used and trims the possibility of the title beginning or ending with a '-'.

sylus’s picture

Status: Fixed » Reviewed & tested by the community
mgifford’s picture

japerry’s picture

Status: Reviewed & tested by the community » Fixed

Yah this (#32) seems like a decent incremental fix. Done.

  • japerry committed 6c53ad9 on 7.x-1.x authored by maximpodorov
    Issue #2445203 by maximpodorov, joel_osc: Error trying to clone a...

Status: Fixed » Closed (fixed)

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