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.
Comment | File | Size | Author |
---|---|---|---|
entity_translation-fix-rules-events.patch | 1.77 KB | das-peter | |
Comments
Comment #1
plachThe 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...
Comment #2
plachCommitted and pushed, thanks!