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.
Hi, I tried to update Rules to 2.5 in Commerce Kickstart (it's currently using the 2.3 release). After doing some research, I also added the following patches :
http://drupal.org/files/d7_rules_are_lost_0.patch and http://drupal.org/files/d7_rules_owner_recover.patch
The update worked fine, but now when I try to checkout, I get this :
Warning: call_user_func() expects parameter 1 to be a valid callback, function 'rules_events_entity_unchanged' not found or invalid function name in RulesState->get() (line 148 of rules/includes/rules.state.inc).
I tried to remove a condition on commerce-order-unchanged:status
in a rule, and the warning disappeared. The other solution was to add the module_load_include()
line coming from rules_init()
but this doesn't sound like a proper fix.
Any idea?
Comment | File | Size | Author |
---|---|---|---|
#30 | rules-events-include-2120421-30.patch | 776 bytes | klausi |
#25 | rules-events-include-2120421-25.patch | 797 bytes | klausi |
#2 | 2120421-2-fix-events-inclusion-plana.patch | 359 bytes | bojanz |
#2 | 2120421-2-fix-events-inclusion-planb.patch | 953 bytes | bojanz |
Comments
Comment #1
alexweber CreditAttribution: alexweber commentedGetting this too with Rules 2.6, manually adding
to line 147 on in rules.state.inc fixes it for me but it's obviously nothing more than a stop-gap.
Comment #2
bojanz CreditAttribution: bojanz commentedThis is an interesting bug.
What happens is that a rules event gets fired before hook_init in _drupal_bootstrap_full():
So menu_set_custom_theme() calls menu_get_custom_theme() which calls menu_get_item(), which triggers a loading of the order object in our case, which triggers a rule. And then boom, because hook_init() hasn't run and the events include hasn't happened yet.
There are two possible solutions for this:
1) Add a require_once to the top of the module, or hook_boot(). We can't use module_load_include() because drupal_get_path() is not available that early in bootstrap (at hook_boot). This maintains the previous global solution of making the include available everywhere.
2) Move the module_load_include to the functions that actually deal with events, in this case rules_invoke_event() and rules_invoke_event_by_args().
My rules knowledge is not large enough to know if this is enough or proper.
Attaching both patches for your convenience.
Comment #3
joep.hendrix CreditAttribution: joep.hendrix commentedProblem shows also in 2.6.
Comment #4
joep.hendrix CreditAttribution: joep.hendrix commentedHi,
2120421-2-fix-events-inclusion-plana.patch by #2 works for me.
Thanks bojanz!
Comment #5
hcderaad CreditAttribution: hcderaad commentedPlan a works for me.
https://drupal.org/comment/8176391#comment-8176391
Comment #6
meytad CreditAttribution: meytad commentedpatch works for me too
Comment #7
TheodorosPloumis2120421-2-fix-events-inclusion-plana.patch works also for me.
Comment #8
loze CreditAttribution: loze commentedme too. thanks.
Comment #9
mglaman2120421-2-fix-events-inclusion-plana.patch works also for me.
Comment #10
a.milkovsky2120421-2-fix-events-inclusion-plana.patch works for me
But I would use
module_load_include('inc', 'rules', 'modules/events');
instead ofrequire_once 'modules/events.inc';
Comment #11
j0rd CreditAttribution: j0rd commentedPlan A patch works for me. Not sure if this is the best solution to the problem, but since it seems to resolve it for most, might as well bump up the status to reviewed.
For the record, this was the warning in my install
I can't find rules_condition_node_is_of_type_assertions anywhere in code.
Comment #12
Christopher Riley CreditAttribution: Christopher Riley commentedPlan A worked for my issue.
Comment #13
yenidem CreditAttribution: yenidem commentedThank you very much bojanz,
The error disappered. will you commit this patch to new realese of Rules?
Comment #14
Carlos Miranda Levy CreditAttribution: Carlos Miranda Levy commentedUpgrading from Rules 7.x-2.3 to Rules 7.x-2.6
Manually downloaded Rules 7.x-2.6, removed Rules 7.x-2.3 and manually applied first plan a, then rolled backed and applied plan b to rules.module.
Put site in Maintenance Mode.
Getting the same error, repeatedly when I do drush updb.
Only thing different from others is that I'm trying to upgrade Rules from a distribution ( profiles/idea/modules/contrib/rules). But I tried moving it to sites/all/modules/rules and got the same behavior.
Neither did Plan A, Plan B or https://drupal.org/comment/8141131#comment-8141131 work for me (or combination of Plan A and https://drupal.org/comment/8141131#comment-8141131 ).
Can I ignore these errors and consider myself properly upgraded?
Or should I remain with Rules 7.x-2.3 until a time comes to pass where these errors wash away from the memory of mankind?
Comment #15
Carlos Miranda Levy CreditAttribution: Carlos Miranda Levy commentedComment #16
Carlos Miranda Levy CreditAttribution: Carlos Miranda Levy commentedComment #17
bojanz CreditAttribution: bojanz commentedThe patches were rolled against latest code.
Comment #18
gonz CreditAttribution: gonz commented@bojanz - I just updated the module to the latest dev - but still get the error:
Was it rolled into latest stable release (2.6)
Is there anything else I should try?
No more need to apply patch? correct?
Comment #19
checker CreditAttribution: checker commented@pairodime the patch is not yet committed. So this is not fixed in current dev version. See What is a patch?
Comment #20
MPankau CreditAttribution: MPankau commentedPatch A resolved my issue.
Comment #21
AnybodyConfirming the patch!
Plan A works great:
https://drupal.org/files/issues/2120421-2-fix-events-inclusion-plana.patch
The problem is very strong in Drupal Commerce, so it would be cool to have this in the stable release ASAP :)
Comment #22
kostajh CreditAttribution: kostajh commentedPlan A works for me as well.
Comment #23
mengi CreditAttribution: mengi commentedPatch (plan A) has been working for me.
Comment #24
fire_81 CreditAttribution: fire_81 commentedSorry both A and B doesn't work.
I'm on 7.26 version.
Still see this:
Warning: call_user_func() expects parameter 1 to be a valid callback, function 'rules_events_entity_unchanged' not found or invalid function name in RulesState->get() (line 148 of ... rules.state.inc).
Can anyone please help?
Comment #25
klausiI also think we should go with bojanz's plan A. I removed another module_load_include() which is now not needed anymore and we should use the absolute path for the require_once statement.
I'm not sure we can test this with simpletest, so marking this RTBC without test cases.
Comment #26
SocialNicheGuru CreditAttribution: SocialNicheGuru commented@25 how will this work with symlinks if you want an absolute path?
This just reminded me of a previous issue of symlinks and recursion https://drupal.org/node/2054595.
Comment #27
hmartens CreditAttribution: hmartens commentedI get this error when I click on Checkout on a new Drupal Commerce install:
Warning: call_user_func() expects parameter 1 to be a valid callback, function 'rules_events_entity_unchanged' not found or invalid function name in RulesState->get() (line 148 of /public_html/sites/all/modules/contrib/rules/includes/rules.state.inc).
I'm using Rules 7.x-2.6 that came with Commerce Kickstart I think.
Comment #28
pippopeppe CreditAttribution: pippopeppe commentedi have the same error of hmartens in #27, and the proposed patch results arleady applied.
Comment #29
checker CreditAttribution: checker commentedPatch #25 fixed the warnings in my case.
Comment #30
klausi@SocialNicheGuru: We are simply including a neighbour file in this case and PHP is aware of the current directory even if one of the files is symlinked. Just tested that locally. So we don't even need dirname(__FILE__), the original require_once from bojanz' patch is fine.
Comment #32
klausi30: rules-events-include-2120421-30.patch queued for re-testing.
Comment #33
Anybody? No progress yet ?
Comment #34
AnybodyRe-trigger review. Sorry for my failed comment. My mistake.
Comment #35
Anybody30: rules-events-include-2120421-30.patch queued for re-testing.
Comment #36
fagoLet's use the inclusion strategy as we've done in rules.core.inc:
require_once dirname(__FILE__) . '/faces.inc';
-> That should be more robust.
Comment #37
klausiI think that the approach without dirname() is more robust, since it is not prone to symlinking problems. Either way - we have RTBC patches for both approaches, so commit the one you like more :-)
Comment #38
maazzarif CreditAttribution: maazzarif commented#30 patch worked for me. I am using "rules-7.x-2.x-dev". I have this rules module installed in two places one in "sitename/modules/rules" and other in "sitename\profiles\commerce_kickstart\modules\contrib\rules". I have applied this patch to both of them. Thank you for this great patch.
Comment #39
smartsystems160 CreditAttribution: smartsystems160 commentedplan a didn't work for me. #1 (manually adding
to line 147) worked for me and the error is gone. using rules 7.26
Comment #40
fagoThere should be no troubles with symlinks, when dirname() resolves one the new path must be valid as well. #2054595: Infinite loop in _rules_discover_module() function ran into troubles with symlinks as it compared the resulting path - but we don't.
Thanks, committed #25.
Comment #43
ianniscamillieri CreditAttribution: ianniscamillieri commentedI've successfully applied the "2120421-2-fix-events-inclusion-plana" patch to Rules 7.26 but need to upgrade to Rules 7.27 now.
Did anyone test that patch to 7.27 Rules version?
Comment #44
garbo CreditAttribution: garbo commented@cyan2405 That patch is no longer necessary in Rules 7.27. The problem is fixed in 7.27 Since Fago committed the patch from #25. I can confirm that the error is gone now.