I have a custom module with following helper function:
/**
* Implements hook_rules_action_info().
*/
function userpoints_rules_mcs_rules_action_info() {
...
$actions['userpoints_rules_mcs_action_txn_list'] = array(
'label' => t('Load transactions'),
'named parameter' => TRUE,
'parameter' => array(
...
'tid' => array(
'label' => t('!Points category', userpoints_translation()),
'type' => 'integer',
'options list' => 'userpoints_rules_get_categories',
'optional' => TRUE,
)
...
),
...
);
...
return $actions;
}
something is not write because I get the followin error from time to time:
PHP Fatal error: Call to undefined function userpoints_rules_get_categories() in /[drupal_path]/modules/rules/ui/ui.data.inc on line 99, referer: http://localhost/admin/config/workflow/rules/components/manage/rules_order_points_moderation/add/2/action
function userpoints_rules_get_categories() is defined in module userpoints_rules.rules.inc so even by name should been loaded previously. I don't exactly understand how rules.inc files are included.
Please help.
Comments
Comment #1
SilviuChingaru commentedHmmm... And the same script is working fine right after clear cache for one time, then that error apears... I think the problem comes from way Rules is setting its cache or something...
EDIT 1: If I make a custom function callback instead of 'userpoints_rules_get_categories' something like:
is working fine only if I put it in .module not in rules.inc file. I don't understand...
Edit 2:
NO IT IS NOT WORKING IN EDIT 1
The error is in fact from an alteration in hook_rules_action_info_alter, I have a line like this:
The error function is 'userpoints_rules_mcs_moderate' wich is defined in userpoints_rules_mcs.rules.inc file that is not included when the hook_rules_action_info_alter() is called from userpoints_rules.rules.inc, the one that provides $actions['userpoints_action_grant_points']. How the hook_rules_action_info_alter() works?
Can we change 'option list' callback function of other module with this hook?
Why our hook_rules_action_info_alter() rules.inc file is not included by rules when an action is altered via this hook?
Is this a bug or there is another way to implement it?
Thank you very much for your time!
Comment #2
PatchRanger commentedDid you use an example from Rules tutorial as a base for your implementation?
I've spent about an hour trying to solve exactly the same issue.
Finally I've discovered that 'module' parameter is misconfigured: there should be machine name (or no at all), not user-friendly.
See my comment to tutorial: https://drupal.org/node/298533#comment-7746391.
Comment #3
subhojit777