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.
We need a good solution for implementing recursion prevention... Will think about a solution :)
Comment | File | Size | Author |
---|---|---|---|
#33 | interdiff-28_32.txt | 1.39 KB | somersoft |
#33 | interdiff-31_32.txt | 570 bytes | somersoft |
#33 | rules-implement_recursion_prevention-2280417-32.patch | 10.38 KB | somersoft |
#31 | rules-implement_recursion_prevention-2280417-31.patch | 10.44 KB | mrinalini9 |
#16 | 2280417-6-recursion-prevention.patch | 5.3 KB | TR |
Comments
Comment #1
fubhy CreditAttribution: fubhy commentedComment #2
Lucasljj CreditAttribution: Lucasljj as a volunteer commentedWe could create an account to be used as a bot and check if the bot or a normal user is updating/inserting/deleting entities
, this method > [api link] probably work but I'm not sure why this approach is marked as "highly discouraged!"Comment #3
Lucasljj CreditAttribution: Lucasljj as a volunteer commentedUsing AccountSwitcherInterface::switchTo || \Drupal::service('account_switcher'); work beautiful
Comment #4
fagoLet's just follow what we have in d7 - that is proven to work as good enough.
Comment #5
fagoComment #6
klausiStarting with a failing test https://github.com/fago/rules/pull/443
Comment #7
fagoI think a beta should have that.
Comment #8
sukanya.ramakrishnan CreditAttribution: sukanya.ramakrishnan commentedCan we please get an estimated time for fixing this one? This is making the Rules module virtually unusable for us!
Thanks,
Sukanya
Comment #9
HoangD CreditAttribution: HoangD commentedI have temporary solution at
Comment #10
milindk CreditAttribution: milindk as a volunteer commentedIs this functionality is available in any other module? If not I can try to implement it.
Comment #11
TR CreditAttribution: TR commentedWe had recursion prevention in D7 Rules. D7 Rules also has tests which demonstrate the conditions where we might encounter recursion and show what we expect to happen in those cases. It looks like @klausi started to port those tests above in #6. I don't know how far he got, but his work is there in the pull request.
There is no one working on this currently.
I think a good approach would be to update and finish what @klausi started - let's get the recursion tests ported to D8 first, that way we will have a way to evaluate any patch for recursion prevention and that way we will have an automated check to ensure recursion prevention continues to work.
I would prefer that all development be done here in the issue queue with patches, so I would like to see that updated and posted here as a patch. @fago hasn't been active in Rules for more than a year, so pull requests in github won't help.
Comment #12
TR CreditAttribution: TR commented@milindk: Do you intend to work on this?
Comment #13
milindk CreditAttribution: milindk as a volunteer commented@TR Yeah I will be working on this.
Comment #14
TR CreditAttribution: TR commentedThank you! If you have questions or problems just ask.
Comment #15
TR CreditAttribution: TR commented@milindk: Any progress?
Comment #16
TR CreditAttribution: TR commentedHere's an update to and re-roll of @klausi's "failing test" from #6. The code was taken from the PR and changed only to apply to the current version of Rules. I expect the patch will apply and the test will fail.
This, and porting the other recursion tests from the d7-tests directory should be the first step.
Comment #17
TR CreditAttribution: TR commentedPart of that fail is because I misspelled 'context_definitions' when I re-rolled the PR. But part is because we're no longer operating on config entities but on RulesComponents, which don't have a uuid() method. I'm not going to fix that because I'm not working on this issue right now, I just wanted to re-roll the patch in hopes that someone could pick this up and finish it off.
Comment #18
TR CreditAttribution: TR commentedNot a beta blocker, since as far as I can tell this is NOT going to involve an API change.
But it should be a release blocker.
Comment #19
somersoft CreditAttribution: somersoft commentedAdded uuid() function.
The patch is rolled against 3.0-alpha6 tag.
Comment #20
somersoft CreditAttribution: somersoft commentedComment #22
somersoft CreditAttribution: somersoft commentedRe-rolled to pass CS and sort out index uuid issue.
Comment #24
TR CreditAttribution: TR commentedPlease provide an interdiff.txt so we can see what you changed. And as I noted in #17 my previous patch had a spelling error that caused a test mail and needs to be corrected.
Comment #25
somersoft CreditAttribution: somersoft commentedUpdated the code to cope with tests.
Removed spelling error so test pass.
Comment #26
somersoft CreditAttribution: somersoft commentedFor those following this issue an update on why the test failed, as it is possible that you can apply the patch and because none of your rules are updating the entity that is being saved, then you may find that it works. In the failing test, the 'rules_entity_update:node' rule updates the title field and it is failing with the following message.
Here is the changed from released code that produced that message
Hence it is indicating that the revisionId has changed, from 1 to 2, but it is not flagged as a new revision.
So the patch prevents the issue title, but the test indicates that more work has to be done so that when the rule is updating self. Perhaps the use of 'rules_entity_presave:entity_type_id' is an acceptable workaround.
What does work is updating of other entity when an entity is being updated.
Would like to hear from others about sucesses and failures after applying the patch, to see if more test are needed to written. Perhaps someone knows what needs to change in Drupal\rules\Context\ExecutionState->autoSave() or elsewhere, to cope with updating self. Probably the testing need to be extended so that the calling variable is has the updated information as well or document that it does not.
Comment #27
somersoft CreditAttribution: somersoft commentedComment #28
somersoft CreditAttribution: somersoft commentedIt was found that in some cases comparing $context_values failed with a PHP Error indicating it was out of stack space when there was large objects in the context. Now a hashes are compare.
The patch can be applied to 8.x-3.0-alpha7 released 3 December 2021 . The patch cannot apply to the -dev as it has moved on.
Comment #29
TR CreditAttribution: TR commentedI triggered the tests on #28 so we can see what DrupalCI thinks about this patch.
Comment #30
TR CreditAttribution: TR commentedPatch needs re-roll.
Comment #31
mrinalini9 CreditAttribution: mrinalini9 at Material for Drupal India Association commentedRerolled patch #28, please review it.
Thanks!
Comment #33
somersoft CreditAttribution: somersoft commentedRerolled #31 as the executeWithState() was not protected.