Hi,
The issue might occur for other fields, too. It however didn't occur when testing for the body field in the same setup.
I had this issue on a rather complex node type and rule, but was able to reproduce it in a very basic way:
- installed latest Fivestar and Rules dev
- created a new node type
- added a Fivestar field (public, vote on edit, maximum is 5 stars)
- node/add/rules-test to create a node of this type
- created a new action rule triggered when viewing a node
- added condition "entity has field" to check against the Fivestar field
- added devel debug output
When viewing the node, the message below is logged:
0 ms Reacting on event Der Inhalt ist abgerufen worden.
20.79 ms Evaluating conditions of rule Fivestar calculation test. [edit]
22.509 ms The condition entity_has_field evaluated to FALSE [edit]
22.529 ms AND evaluated to FALSE.
22.571 ms Finished reacting on event Der Inhalt ist abgerufen worden.
When modifying the condition to testing for the body field instead, the rule "fires" as expected:
0 ms Reacting on event Der Inhalt ist abgerufen worden.
20.621 ms Evaluating conditions of rule Fivestar calculation test. [edit]
22.281 ms The condition entity_has_field evaluated to TRUE [edit]
22.301 ms AND evaluated to TRUE.
" Rule Fivestar calculation test fires. [edit]
0 ms Rule Fivestar calculation test fires.
0.187 ms Evaluating the action devel_debug. [edit]
73.063 ms Rule Fivestar calculation test has fired.
95.449 ms Finished reacting on event Der Inhalt ist abgerufen worden.
Here is the node data structure (with unfold fields to see their content):
... (Object) stdClass
vid (String, 2 characters ) 37
uid (String, 1 characters ) 1
title (String, 4 characters ) Test
log (String, 0 characters )
status (String, 1 characters ) 1
comment (String, 1 characters ) 2
promote (String, 1 characters ) 1
sticky (String, 1 characters ) 0
nid (String, 2 characters ) 29
type (String, 10 characters ) rules_test
language (String, 2 characters ) de
created (String, 10 characters ) 1336718370
changed (String, 10 characters ) 1336718370
tnid (String, 1 characters ) 0
translate (String, 1 characters ) 0
revision_timestamp (String, 10 characters ) 1336718370
revision_uid (String, 1 characters ) 1
body (Array, 1 element)
und (Array, 1 element)
0 (Array, 5 elements)
value (String, 11 characters ) <p>test</p>
summary (String, 0 characters )
format (String, 10 characters ) plain_text
safe_value (String, 12 characters ) <p>test</p>
safe_summary (String, 0 characters )
field_fivestar_rules_test (Array, 1 element)
und (Array, 1 element)
0 (Array, 3 elements)
count (Integer) 1
user (String, 2 characters ) 80
average (String, 2 characters ) 80
rdf_mapping (Array, 9 elements)
cid (String, 1 characters ) 0
last_comment_timestamp (String, 10 characters ) 1336718370
last_comment_name (NULL)
last_comment_uid (String, 1 characters ) 1
comment_count (String, 1 characters ) 0
name (String, 4 characters ) root
picture (String, 1 characters ) 0
data (String, 74 characters ) a:3:{s:7:"overlay";i:1;s:7:"contact";i:0;s:20:"...
entity_view_prepared (Boolean) TRUE
content (Array, 10 elements)
Comments
Comment #1
Anonymous (not verified) commentedInvestigating entity.eval.inc:
When testing for the Fivestar field:
$wrapper is an empty entity wrapper (no node instance inside). So isset($wrapper->$field_name) fails.
I did a cross check with an integer field:
$wrapper then contains an instance of the node and isset($wrapper->$field_name) succeeds.
Conclusion:
loading of the $wrapper somehow depends on what field I'm trying to test for.
Comment #2
Anonymous (not verified) commentedWith latest version of Fivestar I can't reproduce the behavior. Looks like it's a bug of the other modules. So I'm closing this for now.