Problem/Motivation

I added a rule to handle the rules event After updating an entity translation. The rule uses the condition Entity is of type, unfortunately a call to it ends with an exception:
Fatal error: Call to undefined method stdClass::type() in modules/rules/modules/entity.eval.inc on line 158
Debugging it revealed that the function to check the entity type (rules_condition_entity_is_of_type()) expects an entity wrapped by entity_metadata_wrapper().
The reason for this is that entity translation defines entity as variable type. Rules can't wrap the entity itself because it doesn't know the entity-type.
Btw. I've clarified this with fago in IRC.

Proposed resolution

To maintain the existing API I suggest to use module_invoke_all() to call the module hooks with the unwrapped entity and a separated call to rules_invoke_event() and pass an wrapped entity there.

Remaining tasks

Needs review.

User interface changes

None.

API changes

None.

Comments

plach’s picture

Title: Issue with rules invokation in EntityTranslationDefaultHandler::saveTranslations() » Non wrapped entity passed to Rules
Status: Needs review » Reviewed & tested by the community

The patch looks good and works as advertised. Will commit it soon :)

If the Rules integration code were more than a few lines I'd ask you to become the Rules component maintainer, what about the Base system instead? ;)

See http://drupalcode.org/project/entity_translation.git/blob/refs/heads/7.x...

plach’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed, thanks!

Status: Fixed » Closed (fixed)

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

  • Commit c10339c on 7.x-1.x, factory, et-fc, revisions authored by das-peter, committed by plach:
    Issue #1942712 by das-peter: Fixed Non wrapped entity passed to Rules.
    

  • Commit c10339c on 7.x-1.x, factory, et-fc, revisions, workbench authored by das-peter, committed by plach:
    Issue #1942712 by das-peter: Fixed Non wrapped entity passed to Rules.