Postponed (maintainer needs more info)
Project:
Rules
Version:
7.x-2.x-dev
Component:
Rules Core
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Oct 2011 at 21:04 UTC
Updated:
30 Oct 2014 at 12:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
fagoplease try updating the entity api module to the latest dev version
Comment #2
Goofy2k commentedI updated the entity api to 7.x-1.0-beta10. The issue remains. Should this update affect user reference fields as well as entity reference fields?
Comment #3
Goofy2k commentedI found this article on adding /removing users from a reference list programmatically.
My knowledge of php is too poor to translate this in some code for a php-code rule.
Comment #4
fagoplease try updating the entity api module to the latest *dev* version
Comment #5
Goofy2k commentedMistake from my side Fago. I now moved to Entity API 7.x-1.x-dev. No improvement.
Of course I also looked at my Rules, but I think they are allright. Adding a user goes OK with almost the same code. I also save the node after updating the field. Have control messages firing OK.
Comment #6
fagoah, maybe the entity is not saved by rules. Try reading the debug log, whether it says so. If not, try updating to the latest dev version or use the "save an entity" action.
Comment #7
Goofy2k commentedI explicitely save the entity (pool_node) but see no changes.
There are 2 actions list_remove as I use a user_reference and an entity list for testing
Does "evaluating" in the debug output actually mean that the action is executed?
Obviously YES, because I see the result of drupal_message appearing.
DEBUG OUTPUT
" Rule Remove pooler reference from pool node fires. [edit]
0 ms Rule Remove pooler reference from pool node fires.
0.808 ms Evaluating the action list_remove. [edit]
2.137 ms Evaluating the action list_remove. [edit]
2.538 ms Evaluating the action php_eval. [edit]
2.785 ms Evaluating the action entity_save. [edit]
5.423 ms Evaluating the action drupal_message. [edit]
5.594 ms Rule Remove pooler reference from pool node has fired.
19.613 ms Evaluating conditions of rule Generate game set for pooler. [edit]
19.631 ms AND evaluated to TRUE.
Comment #8
Goofy2k commentedI finally succeeded to add/remove users on a multi-valued user-reference field.
So all seems to work well !
The origin of the initial issue was in the fact that I tried to change the field after a webform submission on the data-containing node.
I solved the problem by entering explicit entity-fetch and save actions in the rule that was triggered by the webform submission.
Thanks for your support Fago
Comment #9
Ogredude commentedFor some reason, adding an entity reference to a single-value field does not require an explicit entity save, but adding a value to a multi-value reference field does. This doesn't seem right.
Comment #10
emattias commentedFor me(with node references) it was that stuff is added to the node object so the comparison between the $node object in the db and the current list item returns false. But the entity api adds $node->original which is the original $node object.
Here's a patch that checks if ->original isset on the current item(should work on any entity) and uses that in the comparison instead.
Comment #11
mitchell commentedIs this patch still needed?
Comment #12
geek-merlinyes it is.
i can confirm that
* with todays dev and
* a product reference field
a remove($list, $item) does NOT do the remove.
debugging confirms the analysis in #10:
* looks like $item has always an new revision-id even if it is freshly loaded and not changed (suppose entity api prepares this for us)
* so the deep comparison implicit in array_keys($list, $item) can not work
* applying the patch makes it worksforme
@fago: maybe this issue rises a deeper question about how to test equality for entities.
maybe we should just expose the "original" property instead of doing magic.
maybe weh should let user choose "object equality" against "entity id equality".
think you have some ideas about this.
daring to raise prio as data manipulation of this kind is a core use case for rules and this one is badly broken.
Comment #13
geek-merlinoops, as stated above...
Comment #14
mitchell commentedUpdated component.
Comment #15
klausiCannot reproduce. I tested this with entityreference and commerce_product_reference and in both cases removing an item from a multi-valued field worked without any problems.
Can you provide a minimal setup to reproduce the error?
And the provided patch seems wrong to me, what has the original entity to do with this?
Comment #16
geek-merlinad #15:
> And the provided patch seems wrong to me, what has the original entity to do with this?
read my #12
Comment #17
web360 commentedEncountered same issue with node reference with multi-values. #10 Patch works.
Comment #18
thibI encountered same issue with Entity Reference
Comment #19
thibI used this tutorial to creat a backlinks system : http://nodeone.se/en/creating-multiple-back-links
The problem with this tutorial is that it does not provide solution to remove backlinks created on the other node when one of them is remove to another.
So I create a VBO Views to load node referencing the modified node and set a rule, that the action occurs before the creation of backlink, to remove the modified node from their entity reference fields.
It's this last action that does not work.
I don't know if this is very understandable !!!
Comment #20
asak commentedYep. look like this patch is still needed.
Tested with a reference field that didn't update without the patch - works will with the patch.