when the 'settings' nodeapi operation is invoked, a string containing the type of node is sent for the $node argument, instead of an object like the rest of the operations. This breaks comment.module, and is inconsistent with the rest of the operations and documentation.

This small patch fixes the problem.

CommentFileSizeAuthor
node_24.patch1.42 KBcrunchywelch

Comments

dries’s picture

 * Invoke a hook_nodeapi() operation in all modules.
 *
 * @param &$node
 *   Either a node object, node array, or a string containing the node type.

Looks like the node_invoke_nodeapi function is broken. It used to be possible to pass a $type.

asimmonds’s picture

This also affects upload.module and about 6 contributed modules.

What's the best way to fix this?
Change the node_invoke_nodeapi() phpdoc to only accept a node object or change node_invoke_nodeapi() to accept a string or array and convert to object before passing to the _nodeapi hooks.

4.5 worked because a $node object was created and populated with $type before calling node_invoke_nodeapi()

Using upload.module as a example, a side-effect of this bug is that the node type settings are saved as upload_ instead of upload_nodetype into the variables table.

dries’s picture

OK, so let's go with this (or chx's slightly better fix) and update the PHPdoc accordingly.

chx’s picture

Priority: Normal » Critical

I have also noted this, even submitted a patch (which I have now marked as duplicate, although I think that was better) and because this breaks two core modules (comment and upload) I mark this critical.

chx’s picture

Priority: Critical » Normal

Oh I have not seen Dries' comment. If he thinks mine is better, then this is duplicate and mine is patch :)

asimmonds’s picture

I agree, chx's patch in #18216 is better as the $node object is created properly with stdClass()