I cant really figure this out.
I have a module which interacts with the webform module which just works perfectly fine.
But now I wanted to create a cron which updates certain submissions, but the cron function claims that suddenly the webform function webform_get_submission
is undefined although all other mymodule functions use webform functions without any issues. How come?
// a whole lot functions which use webform functions
// [...]
function mymmodule_cron() {
$conf = mymmodule_defaults();
// check cron run
if(true /* for testing */){
// set writable User
global $user;
$original_user = $user;
$old_state = drupal_save_session(FALSE);
$user = user_load(1);
// fancy sql statement
$sql = array();
// [...]
$sql = join(" ",$sql);
$result = db_query($sql);
$queue = DrupalQueue::get('mymmodule_cron_archiveanon');
foreach ($result as $row) {
$row->anon = true;
$queue->createItem($row);
}
// restore default user
$user = $original_user;
drupal_save_session($old_state);
}
}
function mymmodule_cron_archiveanon_wrapper($item){
$node = node_load($item->nid);
if( function_exists('webform_get_submission')) {
die("Yep.");
// $submission = webform_get_submission($item->nid, $item->sid);
}
else {
die("Nope.");
// dies here
}
// custom function
// mymmodule_contract_archive($node, $submission, $item->anon);
}