The creation of a new node fails (with 500 Service unavailable) if there is a field that accepts more than one item, e.g.

<field_some_field>
    <item>First Value</item>
    <item>Second Value</item>
</field_some_field>

The XML structure is the same as retrieved from an example entry of the same ContentType (without the fields that are not writeable).

The following message is the exception that is thrown.

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'item' for column 'delta' at row 1: INSERT INTO {field_data_field_is_super_event_of} (entity_type, entity_id, revision_id, bundle, delta, language, field_is_super_event_of_url, field_is_super_event_of_title, field_is_super_event_of_attributes) 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); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 935 [:db_insert_placeholder_2] => 1306 [:db_insert_placeholder_3] => conferenceevent [:db_insert_placeholder_4] => item [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => h [:db_insert_placeholder_7] => h [:db_insert_placeholder_8] => h ) in field_sql_storage_field_storage_write() (line 448 of /home/www/html/website/modules/field/modules/field_sql_storage/field_sql_storage.module).
The website encountered an unexpected error. Please try again later.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

klausi’s picture

Title: List of items not working on create node - Incorrect integer value: 'item' for column 'delta' at row 1 » List of field items not working on create node - Incorrect integer value: 'item' for column 'delta' at row 1
Version: 7.x-2.0-alpha1 » 7.x-2.x-dev
Issue tags: +GSoC 2012

Assigning to Sebastian for GSoC.

sepgil’s picture

Status: Active » Needs review
FileSize
867 bytes

I also get an exception, but not the same as you.
Here is however the patch for my issue.

Btw: The correct syntax is:

<field_some_field>
    <item resource="entity_type" id="3">http://www.example.com/entity_type/3</item>
    <item resource="entity_type" id="4">http://www.example.com/entity_type/4</item>
</field_some_field>
klausi’s picture

Status: Needs review » Needs work

This should come with a test case.

sepgil’s picture

Status: Needs work » Needs review
FileSize
2.48 KB

I added the test to the testResourceArray() function.

klausi’s picture

Looks like the whole XML creation is broken. I extended the XML create test with the author and now the tests fail or throw fatal errors, with and without your fix.

I suspect a bug in xmlToArray() where $values['id'] is set to the empty string, and then there is an isset() call in getResourceReferenceValue(). 'id' should never be set in the first place if the XML attribute does not exist.

Patch contains the test case only.

sepgil’s picture

FileSize
2.62 KB

The problem with my patch above was that it didn't check for entities that are not in a list, this patch does it and xml creation works therefore properly.

klausi’s picture

Status: Needs review » Fixed

Committed, thanks!

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

Anonymous’s picture

Issue summary: View changes

*.*.*.* - restws_user [07/Aug/2012:14:42:51 +0200] "POST / HTTP/1.1" 500 7990 "-" "Ruby"