Maybe related issues are #1098104: Data comparison of updated and unchanged entity fails if data to compare or data value is empty and #625288: Unchanged CCK (FileField) field values always being seen by rules as changed..
I need a rule that manages values stored in a field collection of two fields (a node reference and a text value) when the user updates the content: there's a calculus involving data's changes, so I have to compare old and new values.
Using event "Before saving" and taking variables "$node" and "$node_unchanged" should be enough, but they give only the changed (new) value. Trying also another rule with event "After updating existing content" leads to the same result.
Moreover I need to manage them in a custom PHP code because I invoke a custom function with something like (in custom PHP code):
if (function_exists('customfunction')) customfunction($node, $node_unchanged);
that contains the following code (it's in a custom module):
...
$wrapper = entity_metadata_wrapper('node', $node);
$field_collection = $wrapper->field_collection; $iterator = $field_collection->getIterator();
while ($iterator ->valid()) {
$nodereference_nid = ($iteratore->current()->value()->field_nodereference['und'][0]['nid']);
$textvalue_value = ($iter->current()->value()->field_textvalue['und'][0]['value']);
$iterator->next();
};
...
and a similar action for node_unchanged: $textvalue_values (for $node and $node_unchanged) should be different (changed in form before saving), but old value is lost somewhere.
Comments
Comment #1
ptmkenny commentedSince the potentially related issues were closed, and there have been no updates to this issue, I'm guessing that the issue was fixed along the path to a stable release. Feel free to re-open if you are still having the same issue with the latest release.
Comment #1.0
ptmkenny commentedsyntax correction