Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When setting up rules, asserting that a flagging entity is of a specific bundle fails.
When adding the condition - flagging is of bundle - it fails with the following
Call to undefined method stdClass::type()
I was able to work around this by calling entity_metadata_wrapper on the flagging object before passing it to rules. However, the bundle check fails for reasons unknown.
This is necessary since rules does not allow accessing of the bundle fields until you first add the above rule.
Comments
Comment #1
joachim CreditAttribution: joachim commentedComment #2
shabana.navas CreditAttribution: shabana.navas commentedWill take a look at it.
Comment #3
shabana.navas CreditAttribution: shabana.navas commentedDo you mean you are getting this error when you are adding the condition 'Entity is of Bundle'? Not able to duplicate this. Would appreciate an export of your rule so that I can re-create this error.
Comment #4
drone.ah CreditAttribution: drone.ah commentedThe rule is currently on a "flagged a field collection" so you might need that module installed for the rule to be active.
The flag is set to use javascript and the javascript call fails (I have devel enabled with krumo backtrace which I suspect is what breaks the javascript).
The rule is as follows:
{ "rules__ve_points_on_flagging" : {
"LABEL" : "-ve Points on Flagging",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "flag" ],
"ON" : { "flag_flagged_inaccurate" : [] },
"IF" : [
{ "entity_is_of_bundle" : {
"entity" : [ "flagging" ],
"type" : "flagging",
"bundle" : { "value" : { "inaccurate" : "inaccurate" } }
}
}
],
"DO" : [ { "drupal_message" : { "message" : "It Worked!" } } ]
}
}
From the error log:
PHP Fatal error: Call to undefined method stdClass::type() in {...}/rules/modules/entity.eval.inc on line 165,
Comment #5
shabana.navas CreditAttribution: shabana.navas commentedI have never used the field collection module, so, let's see how this goes...
Comment #6
shabana.navas CreditAttribution: shabana.navas commentedFinally got some time to test this. It is actually working just fine for me. I created a Playlist node with a field_collection field. I have set up a flag on the field_collection. I have the following rule trigger (identical to yours) when the I flag the field_collection field.
{ "rules_test_field_collection" : {
"LABEL" : "Test field_collection",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "flag" ],
"ON" : { "flag_flagged_like_my_tracks" : [ ] },
"IF" : [
{ "entity_is_of_bundle" : {
"entity" : [ "flagging" ],
"type" : "flagging",
"bundle" : { "value" : { "like_my_tracks" : "like_my_tracks" } }
}
}
],
"DO" : [ { "drupal_message" : { "message" : "It worked." } } ]
}
}
I get the 'It worked.' message after I flag the field. I have the devel module with krumo backtrace enabled. So this is working perfectly for me. I am not sure what could be going wrong on your end.
Comment #7
apmsooner CreditAttribution: apmsooner commented