I think this happened because I was on the "create new list" page I didn't enter a "custom send rate" so it gave me an error telling me to put one in. Then I put in a custom rate (20) and then it produced the following error. However, the list did get created in the process.

PDOException: SQLSTATE[23000]:
Integrity constraint violation:
1062 Duplicate entry 'newsletter_list-2-0-0-und' for key 'PRIMARY':

INSERT INTO {field_data_field_newsletter_template}
(entity_type,
entity_id,
revision_id,
bundle,
delta,
language,
field_newsletter_template_target_id,
field_newsletter_template_target_type)

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);

Array (
[:db_insert_placeholder_0] => newsletter_list
[:db_insert_placeholder_1] => 2
[:db_insert_placeholder_2] => 2
[:db_insert_placeholder_3] => newsletter_list
[:db_insert_placeholder_4] => 0
[:db_insert_placeholder_5] => und
[:db_insert_placeholder_6] => 4
[:db_insert_placeholder_7] => newsletter_template )

in field_sql_storage_field_storage_write()
(line 448 of /.../modules/field/modules/field_sql_storage/field_sql_storage.module).

Comments

Reg’s picture

I should mention that I attempted this after upgrading from beta6 to beta8 (skipped 7 as mentioned).

ParisLiakos’s picture

Status: Active » Closed (cannot reproduce)

i had this error some random times as well.couldnt reproduce it..but template saved fine as well so didnt give more attention
it was completely random.but havent see it for a while.

Btw field_newsletter_template_target_type shouldnt exist.you should upgrade entityreference module to its latest version ;)
Just a wild guess; maybe it has something to do with it

Reg’s picture

I upgraded it, I'll let you know if it crops up again.

Reg’s picture

I might have some idea of what's going on here. Have a look at this:


File: newsletter.list.controller.inc

  public function save($list) {
    field_attach_presave('newsletter_list', $list);
    if (!isset($list->nlid)) {
      $list->created = REQUEST_TIME;
      drupal_write_record('newsletter_list', $list);

You do a check for nlid but not list_title however in the DB list title is set through an index as required to be unique. You might need to put some form validation in place to make sure that anything you set as unique is actually not being duplicated by the user before the form is submitted to the the DB, at least in the case of "add".

I put some debug backtrace code just in front of where the error was occurring in common.inc and then looked back through the calls to to this point. Here's the backtrace:

9  Line: 21,  File: index.php,  Function: menu_execute_active_handler
8  Line: 503,  File: includes/menu.inc,  Function: call_user_func_array
7  Function: newsletter_list_add
6  Line: 692,  File: sites/all/modules/newsletter/includes/newsletter.admin.inc,  Function: drupal_get_form
5  Line: 123,  File: includes/form.inc,  Function: drupal_build_form
4  Line: 364,  File: includes/form.inc,  Function: drupal_process_form
3  Line: 844,  File: includes/form.inc,  Function: form_execute_handlers
2  Line: 1430,  File: includes/form.inc,  Function: newsletter_list_edit_submit
1  Line: 801,  File: sites/all/modules/newsletter/includes/newsletter.admin.inc,  Function: save
0  Line: 45,  File: sites/all/modules/newsletter/includes/newsletter.list.controller.inc,  Function: drupal_write_record

in drupal_write_record (line 6916 of includes/common.inc).
ParisLiakos’s picture

Status: Closed (cannot reproduce) » Active

Thanks a lot, for looking into this more:)

ParisLiakos’s picture

Status: Active » Fixed

Commited a fix.

Status: Fixed » Closed (fixed)

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