Loading module with an install hook that invokes content_copy fails
kcoop - March 24, 2009 - 19:29
| Project: | Patterns |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
I've got a module that creates a cck type using drupal_execute on the form content_copy_import_form. I'm trying to load it with a pattern. I've added the prequisite modules content, content_copy, and text, which are also all references in my .info file.
The install hook calls this to create the cck type:
function _create_content_type($cck_definition_file) {
include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
$values = array();
$values['type_name'] = '<create>';
$values['macro'] = file_get_contents($cck_definition_file);
$form_state = array();
$form_state['values'] = $values;
drupal_execute("content_copy_import_form", $form_state);
}When I run the pattern, I get the following error:
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'content_copy_import_form' was given in <mysite>/form.inc on line 366This module installs fine when I'm not using patterns. Further, if I separate my pattern into one containing just the cck module declarations, run it, then run mine, it works fine.
It appears there's something not being fully registered at module load time.

#1
The error you are getting most likely means that content_copy module is not yet enabled at the time when your function is called. That would explain why separating your pattern into two solves the problem. Could you maybe try experimenting little bit more with the order of the statements in your pattern file to see if that makes any difference.
I also don't mind taking a look at your module and pattern if you are willing to share it.
I'm assuming this all relates to standalone patterns module, not install profile, right?
#2
Yes, not install profile. Sorry about the misclassification of those issues.
The function I showed above is called in the module's hook_install. Very straightforward. No actions in the pattern, just modules loading, including the module prerequisites content, content_copy, and text. I even tried rearranging them in the pattern file with my module at the end, thinking there might be a problem with dependency sorting.
I'll see about putting a simple example together for you. I'm kind of slammed right now too. For now, my workaround solves my problem, but I just wanted to note this as an issue so it doesn't get lost. I'm not sure how many people create cck types in their modules, maybe there's a more common idiom I'm not aware of yet.
Thanks for a great module! I'm finding it very useful.
#3
This may not be the most common issue but I would like to sort it out. Your example would be of great help in doing that. Looking forward to it.
Thanks
#4