Hi, I am still not able to use custom text field with predefined default text. Error message (field "aa", default text"aa".
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'commerce_invoice-1-0-0-und' for key 1: INSERT INTO {field_data_field_aa} (entity_type, entity_id, revision_id, bundle, delta, language, field_aa_value, field_aa_format) 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] => commerce_invoice [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => commerce_invoice [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => ss [:db_insert_placeholder_7] => ) in field_sql_storage_field_storage_write() (line 448 of /var/www/web5/example.com/example.com/modules/field/modules/field_sql_storage/field_sql_storage.module).
Is it right? Or am I somewhwre wrong? Thanks

Comments

pavel ruban’s picture

Yes, I have this bug too.

As I observed - it related to several time execution field_attach_insert function:

place: commerce.controller.inc:61

1) $invoice = $this->_save($invoice, $transaction); - within save method
2)$this->invoke('insert', $invoice);within invoke method of the same class

So mysql transaction will try insert field data several times & cause the error

gilles_c’s picture

Any news about this bug ?

peximo’s picture

Component: User interface » Code
Status: Active » Needs review
StatusFileSize
new2.25 KB

Hi, I have the same problem, I believe that the controller save method replicates a part of the default process causing the bug.
I've tested the attached patch in a project and it seems to work.
But I do not know so well the module to be sure this is the right fix.

sportel’s picture

Hi,

I'm also having this problem, when using a custom text field with a predefined default text. Has the provided patch been reviewed yet?

calmforce’s picture

I hit the same problem while using the dev version from 2013-09-30. Apparently, this module has never been tested with custom fields attached to the commerce_invoice entity - any field, not just the text field, will cause the PDOException. I got it with the field type 'price' and the field type 'date'. The problem is with the line 93 of commerce_invoice.controller.inc (inside the function _save()) - it is redundant, there is no need to call field_attach_insert() because the line 61 of the same file calls invoke('insert') immediately after calling _save(). While doing invoke('insert') the first thing called is field_attach_insert(). The same is about the line 97 - this call to field_attach_update() is redundant as well, because the line 66 does call invoke('save').
After I removed the lines 93 and 97 all my invoices are being saved with all the custom fields I have attached to them.

calmforce’s picture

Issue summary: View changes
StatusFileSize
new874 bytes

I have added a simple patch that makes the fix by just removing 2 lines from commerce_invoice.controller.inc file (see comment #5). If you want to use it please pay attention to the paths - I use modules/contrib directory.

c-logemann’s picture

@calmforce: Thank you for helping with the code. It's better to use "git diff" to create patches. In this way it doesn't matter where a module is installed.
See also: Advanced patch contributor guide .

The command for creating and applying patches is documented on the "version control" page of each module (see tab). For this module this is here.

@sportel: If somebody tests a patch (s)he should report the result in the issue the patch is provided. Testing isn't difficult with git. But a helpful test needs to reproduce the error. This is easier for people who are affected by a problem.

calmforce’s picture

I found one more issue with commerce_invoice.controller.inc : the line $this->invoke('save', $invoice) doesn't do anything because there is no hook 'save', but there is hook 'update', so it has to be $this->invoke('update', $invoice). So with the attached patch I am able to have variety of custom fields added to the commerce_invoice entity, and all of them are updated correctly.

dwkitchen’s picture

Status: Needs review » Closed (won't fix)

Closing all Drupal 7 issues as this project will only be supported for Drupal 8