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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexweber’s picture

Getting this too with Rules 2.6, manually adding

module_load_include('inc', 'rules', 'modules/events');

to line 147 on in rules.state.inc fixes it for me but it's obviously nothing more than a stop-gap.

bojanz’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
953 bytes
359 bytes

This is an interesting bug.
What happens is that a rules event gets fired before hook_init in _drupal_bootstrap_full():

    // Prior to invoking hook_init(), initialize the theme (potentially a custom
    // one for this page), so that:
    // - Modules with hook_init() implementations that call theme() or
    //   theme_get_registry() don't initialize the incorrect theme.
    // - The theme can have hook_*_alter() implementations affect page building
    //   (e.g., hook_form_alter(), hook_node_view_alter(), hook_page_alter()),
    //   ahead of when rendering starts.
    menu_set_custom_theme();
    drupal_theme_initialize();
    module_invoke_all('init');

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.

joep.hendrix’s picture

Version: 7.x-2.5 » 7.x-2.6

Problem shows also in 2.6.

joep.hendrix’s picture

Hi,
2120421-2-fix-events-inclusion-plana.patch by #2 works for me.

Thanks bojanz!

hcderaad’s picture

meytad’s picture

patch works for me too

TheodorosPloumis’s picture

loze’s picture

me too. thanks.

mglaman’s picture

2120421-2-fix-events-inclusion-plana.patch works also for me.

a.milkovsky’s picture

2120421-2-fix-events-inclusion-plana.patch works for me

But I would use
module_load_include('inc', 'rules', 'modules/events'); instead of require_once 'modules/events.inc';

j0rd’s picture

Status: Needs review » Reviewed & tested by the community

Plan 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

call_user_func_array() expects parameter 1 to be a valid callback, function               [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123

I can't find rules_condition_node_is_of_type_assertions anywhere in code.

Christopher Riley’s picture

Plan A worked for my issue.

yenidem’s picture

Thank you very much bojanz,
The error disappered. will you commit this patch to new realese of Rules?

Carlos Miranda Levy’s picture

Upgrading 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.

$ drush updb
The following updates are pending:

rules module : 
  7210 -   Deletes the unused rules_empty_sets variable. 
  7211 -   Creates the "owner" column. 
  7212 -   Make sure registry gets rebuilt to avoid upgrade troubles. 
  7213 -   Recover the "owner" property for broken configurations. 

Do you wish to run all pending updates? (y/n): y
Performed update: rules_update_7210                                                 [ok]
Performed update: rules_update_7211                                                 [ok]
Performed update: rules_update_7212                                                 [ok]
Performed update: rules_update_7213                                                 [ok]
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
call_user_func_array() expects parameter 1 to be a valid callback, function         [warning]
'rules_condition_node_is_of_type_assertions' not found or invalid function name
faces.inc:123
'all' cache was cleared in /xxxx/xxxx/drupal7#xxxxxx.com                    [success]
Finished performing updates. 

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?

Carlos Miranda Levy’s picture

Status: Reviewed & tested by the community » Needs work
Carlos Miranda Levy’s picture

  1. Problem was not solved by suggested solutions.
  2. Patches are for previous version, not latest.
bojanz’s picture

Status: Needs work » Needs review

The patches were rolled against latest code.

gonz’s picture

@bojanz - I just updated the module to the latest dev - but still get the error:

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 /srv/bindings/...somecodehere.../code/sites/all/modules/contrib/rules-7x-2x-dev/includes/rules.state.inc).

Was it rolled into latest stable release (2.6)

Is there anything else I should try?

No more need to apply patch? correct?

checker’s picture

@pairodime the patch is not yet committed. So this is not fixed in current dev version. See What is a patch?

MPankau’s picture

Patch A resolved my issue.

Anybody’s picture

Confirming 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 :)

kostajh’s picture

Plan A works for me as well.

mengi’s picture

Patch (plan A) has been working for me.

fire_81’s picture

Sorry 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?

klausi’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
797 bytes

I 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.

SocialNicheGuru’s picture

@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.

hmartens’s picture

I 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.

pippopeppe’s picture

i have the same error of hmartens in #27, and the proposed patch results arleady applied.

checker’s picture

Patch #25 fixed the warnings in my case.

klausi’s picture

@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.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 30: rules-events-include-2120421-30.patch, failed testing.

klausi’s picture

Status: Needs work » Needs review
Anybody’s picture

Status: Needs review » Needs work

? No progress yet ?

Anybody’s picture

Status: Needs work » Needs review

Re-trigger review. Sorry for my failed comment. My mistake.

Anybody’s picture

fago’s picture

Let's use the inclusion strategy as we've done in rules.core.inc:
require_once dirname(__FILE__) . '/faces.inc';
-> That should be more robust.

klausi’s picture

Status: Needs review » Reviewed & tested by the community

I 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 :-)

maazzarif’s picture

#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.

smartsystems160’s picture

plan a didn't work for me. #1 (manually adding

module_load_include('inc', 'rules', 'modules/events');

to line 147) worked for me and the error is gone. using rules 7.26

fago’s picture

Status: Reviewed & tested by the community » Fixed

There 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.

  • Commit e1cdbd9 on 7.x-2.x authored by bojanz, committed by fago:
    Issue #2120421 by bojanz, klausi: Fixed warning: call_user_func()...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ianniscamillieri’s picture

I'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?

garbo’s picture

@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.