Relevant modules:

* taxonomy
* metatag

Step to reproduce:
1. Create content type with an autocomplete term reference field
2. Add node and type a new term in the autocomplete field for the node/add form
3. Save

What seems to happen:
The new taxonomy term is saved before the node, triggering its own field_attach_insert routine. This goes down to Entity Translation which then fires its save translation module. Metatag hooks into that with metatag_entity_translation_insert that calls entity_languge which then calls entity_translation_language. Here is where the issue is: instead of getting the handler for taxonomy_term, it gets the handler for node. Then, when it passes the taxonomy_term entity to the handler and runs entity_extract_ids(), it expects a bundle which is not set, throwing EntityMalformedException.

I've rigged this to work by getting rid of entity_translation_current_form_get_handler() on line 1641 of entity_translation.module (set $handler to false so that entity_translation_get_handler() loads the correct handler), but I'm not sure if this is the best thing to do.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

peximo’s picture

Status: Active » Needs review
FileSize
1.82 KB

Hi, I have the same problem; attached patch should fix it.

My steps to repeat:
1. Enable entity_translation
2. Enable field translation for a content type (eg: basic page)
3. Add a vocabulary, use the widget for tagging and set his terms translatable
4. Add a term reference field to the previous configured content type
5. Add new node, insert one or more tag and save

plach’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

The patch looks good, thanks! There are some issues I can fix on commit, if none provides a reroll before.

+++ b/entity_translation.module
@@ -1623,7 +1623,9 @@ function entity_translation_language($entity_type, $entity) {
+  // Other entities maybe created or saved while submitting the current one,

maybe > may be

+++ b/includes/translation.handler.inc
@@ -123,6 +123,16 @@ interface EntityTranslationHandlerInterface {
+  public function isEntity($entity_type, $entity);

I'd rename this to isWrappedEntity() to improve readability.

+++ b/includes/translation.handler.inc
@@ -721,6 +731,14 @@ class EntityTranslationDefaultHandler implements EntityTranslationHandlerInterfa
+    list ($id,,) = entity_extract_ids($entity_type, $entity);

Extra space after "list".

plach’s picture

Issue tags: +Needs tests

Would be good to have some coverage for this too.

peximo’s picture

rerolled

plach’s picture

@impleri:

Could you confirm this fixes your issue?

impleri’s picture

Confirming that #4 works for me and solves the issue.

plach’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed, thanks.

bachbach’s picture

works for me !

Status: Fixed » Closed (fixed)

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

Merlineus’s picture

This patch breaks correct language detection for pathauto on node creation.
http://drupal.org/node/1925848

  • Commit 8eb6297 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions authored by peximo, committed by plach:
    Issue #1851118 by peximo | impleri: Fixed Incorrect ET Handler set in...

  • Commit 8eb6297 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions, workbench authored by peximo, committed by plach:
    Issue #1851118 by peximo | impleri: Fixed Incorrect ET Handler set in...