Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
The below export can produce the problem. I tried upgrading to -dev of both rules and entity
{ "rules_saving_new_stuff_again" : {
"LABEL" : "Saving new node",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "node_insert" ],
"DO" : [
{ "variable_add" : {
"USING" : { "type" : "list\u003centity\u003e", "value" : [ "" ] },
"PROVIDE" : { "variable_added" : { "endpoint_list" : "Entity list" } }
}
},
{ "entity_fetch" : {
"USING" : { "type" : "node", "id" : "1" },
"PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
}
},
{ "list_add" : { "list" : [ "endpoint-list" ], "item" : [ "entity-fetched" ] } }
]
}
}
From apache's log:
Fatal error: Class name must be a valid object or a string in /var/www/drupal-7.2/includes/common.inc on line 7475, referer: http://50.57.86.194/drupal-7.2/?q=node%2Fadd%2Farticle&
$entity_type argument has the value 'entity', instead of a "real" entity type. Tried catching a back trace as well but that required more memory than my 256.
Comment | File | Size | Author |
---|---|---|---|
#5 | entity_wrapper_entity_2.patch | 4.49 KB | dixon_ |
#3 | entity_wrapper_entity.patch | 3.66 KB | fago |
Comments
Comment #1
sun-fire CreditAttribution: sun-fire commentedThe same error. Subscribe.
Comment #2
fagouhm, seems to be a general problem of the entity wrappers. They just don't support generic list of entities yet :(
E.g. I was able to reproduce it with
I think the list-wrappers set() and value() method need to special-case generic lists of entities. Regular lists-of-entities are internally represented as an array of entity ids, which then the list-wrapper entity_loads() on demand in value() and turns objects into ids in set().
For generic entity lists though, a list of ids doesn't suffice as we also need the types too.
A bit confusing, but the entity-wrapper use another entity-wrapper-instance to hold the "value" of a generic entity reference. Thus it expects you to pass a wrapped entity as value, what I think rules should be correctly doing.
The problem is, that the list-wrapper now handles the generic-entity-reference like a special one, i.e. it tries to run an entity_load() in value().
Instead, just returning/setting the values as is (=entity wrappers) in value() and set() should be fine and solve the problem.
We also need to cover that in the tests then.
Comment #3
fagoI had a look at it and fixed some issue with generic entity handling.
Attached patch makes the above code example work for me (just replace debug() with dpm()), but misses tests.
Comment #4
Letharion CreditAttribution: Letharion commentedAwesome! I tried it out with Rules, and the rule now executes correctly. Since this is tagged needs tests I'm leaving it open.
Comment #5
dixon_As mentioned, very simple to test. Here is a patch based on #3, plus the tests. Everything passes for me.
Comment #6
fagothanks, committed.