I can't seem to delete nodes which are using a Field_collection field. Receiving the following error message:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1: DELETE FROM {field_collection_item} WHERE (item_id IN ()) ; Array ( ) in EntityAPIController->delete() (line 399 of C:\xampp\htdocs\infolijn\sites\all\modules\entity\includes\entity.controller.inc).

Doesn't seem to matter wether the Field_collection field is empty or not.

Comments

p.brouwers’s picture

StatusFileSize
new2.78 KB

I had the same issue and made a patch for it based on the 7.x-1.x-dev-17-01 version.
The problem was that the language isn't set for the entities.

I'll attach the patch here, but I need to update it to the latest version AND fix 1 line that set's the language fixed to 'nl' instead of using the current langcode.

R.Muilwijk’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, field_collection.patch, failed testing.

R.Muilwijk’s picture

Priority: Major » Critical

Marking this critical because it will not allow you to delete nodes anymore.

fago’s picture

this should be fixed with the latest entity API dev version, please test.

rp7’s picture

Tested (Entity API 7.x-1.x-dev 2011-Feb-28) > as far as I can tell, unfortunately, still the same.

cfennell’s picture

Status: Needs work » Needs review
StatusFileSize
new2.02 KB

It looks like _field_invoke() (called by field_attach_delete() in field.attach.inc) invokes field_collection_field_delete() with empty $item arrays when field_collection_items are empty. A couple of the other modules that implement hook_field_delete() that I looked at (file_field, media_field) iterate over the $items array directly in their hook_field_delete() implementations, which means they'll just ignore empty arrays.

In the attached patch, I added small sanity check to field_collection_field_delete() and added a test to field_collection.test to ensure nodes with empty collection fields are deleted.

@fago any reason why this approach should not work?

Thanks.

fago’s picture

Status: Needs review » Fixed

hm, still I think the latest enttiy API should just skip that. Anyway, it won't harm to check it here too + improved test coverage is always good. I fixed the coding syle + committed it.

cfennell’s picture

Sweet, thanks @fago.

p.brouwers’s picture

Cool. Your fix seems to be a better approach than mine cfennel.

Status: Fixed » Closed (fixed)

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

xsyn’s picture

Status: Closed (fixed) » Needs review

Last patch failed testing.

Bump.

servantleader’s picture

Status: Needs review » Fixed

I think this has already been corrected and committed(#8). If something is wrong, we should create a new issue.

Status: Fixed » Closed (fixed)

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