Debug a somethnig going weird in someone elses nodeapi presave
This could be prettier. Do not judge. Especially could be prettier using an IDE.
<?php
/**
* Invoke a hook_nodeapi() operation in all modules.
*
* @param &$node
* A node object.
* @param $op
* A string containing the name of the nodeapi operation.
* @param $a3, $a4
* Arguments to pass on to the hook, after the $node and $op arguments.
* @return
* The returned value of the invoked hooks.
*/
function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
$return = array();
foreach (module_implements('nodeapi') as $name) {
if ($op == 'presave') {
// @debug
$v = (array)$node;
drupal_set_message($v['uid']);
}
$function = $name .'_nodeapi';
if ($op == 'presave') drupal_set_message('blame: ' . $name);
$result = $function($node, $op, $a3, $a4);
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
}
else if (isset($result)) {
$return[] = $result;
}
if ($op == 'presave') {
// @debug
$v = (array)$node;
drupal_set_message($v['uid']);
}
}
return $return;
}
?>
Do this if things are all right and good at the start of a node_save and are not after nodeapi presave is called.
Where the value you are interested in stops showing up, that's the module that is sabotaging you.
Comments
Post new comment