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.
Need to test that actions which would fire in a loop abort. Fun stuff like unpublishing a post when it's published and publishing a post when it's unpublished (note, this may not be a good example, but something like that).
Comment | File | Size | Author |
---|---|---|---|
#18 | actions_infinite_recursion_tests-296322-d6-18.patch | 995 bytes | Albert Volkman |
#12 | 296322-12_actions_infinite_recursion_tests.patch | 11.81 KB | Senpai |
#10 | 296322-10_actions_infinite_recursion_tests.patch | 12.03 KB | cwgordon7 |
#7 | 296322-7_actions_infinite_recursion_tests.patch | 11.34 KB | Senpai |
#1 | actions_tests_01.patch | 11.57 KB | cwgordon7 |
Comments
Comment #1
cwgordon7 CreditAttribution: cwgordon7 commentedSo I wrote this test and found out that the trigger module's API was completely broken and made no sense and didn't work. Interesting bugs include user_access($module) which means the pages are not accessible for any user besides user #1, complete breakage if the module name is not the same as the hook name (some weird special casing was going on for hook_cron() I guess), and a db_select() being attempted with no fields selected. So I changed trigger_menu() along with a few other trigger functions to fix this. This probably needs to be at least partially backported to 6.x afterwards - I know it's an API change, but obviously no one is using the API or someone would have discovered it was completely broken by now.
Comment #2
catchHow does this cause user_access($module)?
Comment #3
cwgordon7 CreditAttribution: cwgordon7 commentedBecause user_access() is used as the access callback if none is specified, so using $module in that array had previously caused user_access($module) to be called rather than user_access('administer actions') or trigger_access_check($module).
Comment #4
mattyoung CreditAttribution: mattyoung commentedsubscribe
Comment #5
Senpai CreditAttribution: Senpai commentedI'm getting a
Warning: call_user_func_array() [/www/manual_php/function.call-user-func-array.html]: First argument is expected to be a valid callback, 'trigger_access_check' was given in _menu_check_access() (line 507 of /www/drupalhead/includes/menu.inc)
Line 507 is:
I'm going in search of the culprit.
Comment #6
Senpai CreditAttribution: Senpai commentedStrange, I thought I had cleared the cache. Submitted admin/build/modules for the second time, and the warning is gone.
Also found a stray semicolon in actions_loop_test.info that was getting in the way of the hidden = TRUE, and fixed it.
Comment #7
Senpai CreditAttribution: Senpai commentedI just typed a grandiose patch review, and when I hit submit, my hotel wifi died and I lost it *all*!
Bottom line is, #1 works, and works well. Only gripe is that I can't tell if Actions themselves will successfully abort in an infinite recursion of their own that happens outside of this new Simpletest module.
New patch attached that fixes two small things, but no functional code was changed from #1.
Goodnight world.
Comment #8
Senpai CreditAttribution: Senpai commentedFollowup to my review in #7: After talking with cwgordon this morning, and being less tired, I went back and looked at the actions_do() call to see whether the simpletests were accurately reflecting a real-world situation. I'm happy to report that the actions_do() function in actions.inc defaults to a static $stack count, but if max count is not defined elsewhere, it defaults to '35'.
Thus, all future actions defined by either core or contrib (such as Rules.module) are protected from infinite recursion, and this test mimics both a default limit of 35 and then a random limit of between 10 and 50 tries.
$this->setMaxStack(mt_rand(10, 50));
Commit this baby! :)
Comment #9
webchickPlease add PHPDoc to all functions and class definitions. (except setUp and getInfo)
Let's document what this variable does, since I don't see Senpai's comment in the source code anywhere.
spaces before/after the =
Should this be a do ... while loop? That first condition is very confusing.
This seems like an unnecessary bit of abstraction that just makes the test harder to follow. Let's just call db_delete() directly in the test.
Two periods.
Let's add a quick comment here. This test is our best shot at documenting how the actions/trigger system works.
Woah, what? Why is this code in hook_help()? Shouldn't this be in hook_init() or similar?
Actually. Why don't we add a "real" watchdog action in system_action_info() as part of this test? Seems like it would be useful outside of this test.
This review is powered by Dreditor.
Comment #10
cwgordon7 CreditAttribution: cwgordon7 commentedDone.
Done.
Done.
Refactored the code to make the logic unnecessary and was able to use the word "plethora" in the process.
Done.
Fixed.
I disagree, it's not my responsibility here to cover for the inadequacies of the actions/triggers API. I did it anyway though to eliminate excuses for marking back to code needs work.
Fixed.
No, I really think that's out of scope for this patch, which has taken quite a lot of scope on already by not only adding tests but also completely fixing trigger.module. Please see this article. ;)
I addressed this above.
I addressed this above.
Comment #11
catchtrigger_menu() rework is also at #544318: Rework trigger_menu() - on first glance it looks like a similar approach to here, but one of these will be duplicate if the other gets committed.
Comment #12
Senpai CreditAttribution: Senpai commentedPatch Review of #10
All of the tests now have proper comments. Good.
Congrats on removing the
protected $limit = 35;
. It's cleaner this way.Shouldn't actions_loop_test_hook_info() be actions_loop_test_info()? Oh, wait, worst function name evah. I get it now. ;)
actions_loop_test_help() was successfully changed to actions_loop_test_init().
Another congrats on using the word 'plethora' in a PHPdoc comment. I highly approve of this refactoring. Plethora++
Webchick sez: "Why don't we add a "real" watchdog action in system_action_info() as part of this test?"
Cwgordon repliz: "Think of the tiny furries!"
Senpai agrees with Cwgordon.
Summary
No functional code was changed or modified in the attached patch. This patch still applies to head, and no animals were harmed in it's creation or editing. In fact, a small, furry kitteh was saved from certain disaster and one porpoise from the eastern ocean was so ecstatic it was spotted doing the backstroke.
BTW Charlie, congrats on promoting worldwide $aids awareness with the invention of this patch. :)
RTBC.
Comment #13
webchickGreat! Committed to HEAD. :)
I *think* we need upgrade documentation here to explain to other modules how to expose their stuff as triggers.
Comment #14
cwgordon7 CreditAttribution: cwgordon7 commentedMore importantly, this needs to be back ported to Drupal 6? It's a valid bug with the module, we can clearly tell how the API was meant to work, and it currently does not work in Drupal 6. Might be too big of a change for the stable release, though.
Comment #15
dpearcefl CreditAttribution: dpearcefl commentedIs there any interest in this issue? Has this been fixed in the latest D6?
Comment #16
catchStill a valid issue. If something was fixed in a newer release and marked for backport, it is almost always a valid bug.
Comment #17
dpearcefl CreditAttribution: dpearcefl commentedOK, that is fine. Just checking for interest.
Comment #18
Albert Volkman CreditAttribution: Albert Volkman commentedHere is a patch incorporating the changes for trigger.admin.inc. Is it safe to assume that the changes to trigger.module are an API change and should not be incorporated?
Comment #19
Albert Volkman CreditAttribution: Albert Volkman commented