1

I'm getting errors such as

Fatal error: Call to undefined function webform_expand_select_ids()

and so I'm trying to include all the includes in /sites/all/modules/webform/components.

I'm not even sure if that's going to help, but to help figure that out I was hoping that I could at least check and see whether module_load_include() is successfully including files?

  if ($form['#form_id'] == 'quiz_answer_key_node_form'){      
    $url = "./sites/all/modules/webform/components/*.inc";
    $filenames = glob("$url");
    $type = 'inc';
    $module = 'webform';
    foreach ($filenames as $filename)
    {
       dsm(module_load_include($type, $module, $filename));
    } 
}
1

module_load_include() returns FALSE if it can't find the file, and the full path to the file included if it can find the file, and it was successfully included. In addition to that, it uses require_once which will throw a fatal E_COMPILE_ERROR error if the file is not found.

An easy way to debug would be to use code like this in your loop:

$file_path = module_load_include($type, $module, $filename);

if ($file_path === FALSE) {
  dpm('Failed to include: ' . $filename);
}
else {
  dpm('Successfully included: ' . $file_path);
}

That will give you a pretty solid answer as to whether or not the files are being included. If you get no debug messages, you know that the glob() isn't returning the list of files that it should be.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.