Closed (fixed)
Project:
Drupal core
Version:
5.x-dev
Component:
other
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 May 2006 at 11:17 UTC
Updated:
21 Feb 2007 at 01:27 UTC
Changes made to node in _nodeapi hook of custom module takes no effect.
Reproduce:
Create nodeapi_test.module with:
function nodeapi_test_nodeapi($node, $op){
switch($op){
case "validate": $node->body .= "___ADD"; break;
}
}
Enable the module in administration. Create a page.
Body is saved without addition string.
Then replace all the drupal installation (except sites directory) with files from
Drupal 4.7 RC3. Create a page again.
Page saves with "___ADD" string, as expected.
Comments
Comment #1
ultraBoy commentedMy suggestions:
Are you sure about making changes when $op == 'validate'? Try another ops, such as 'load' or, more likely 'view'.
Another possibility, if this op was replaced with forms api like this one http://drupal.org/node/22218#hook_nodeapi_form
Comment #2
Budrick commentedActually, what I need is some $node->taxonomy modification before node is saved. I want it to be saved with the changes I did on validate. $node->body is used in the above example just for simplicity.
Documentation says:
And the option worked fine until the 4.7 release, but now its not. It can break many modules that used the option.
Comment #3
Budrick commentedComment #4
killes@www.drop.org commentedThis is non-critical as it doesn't break any core functionality.
I think you should return the changed value.
Comment #5
Budrick commentedWhat do you mean?
Comment #6
chx commentedvalidate does not let you do that. docs update is in the works. see hook_submit.
Comment #7
Budrick commentedDocumentation is still not updated: http://api.drupal.org/api/4.7/function/hook_nodeapi
Comment #8
knugar commented.... and still not updated.
After trying to use hook_nodeapi() to change $node->body during 'validate' (yes I realy want to do this, and not during 'view') in a drupal-4.7.4 module, I couldn't understand what I was doing wrong - checked and double checked the documentation... Thanks to this bug report I finaly know why i failed :-)
I think this should be corrected ASAP so others don't have to waste time on this during module development.
Comment #9
Budrick commentedSo in head: http://api.drupal.org/api/HEAD/function/hook_nodeapi
Comment #10
moshe weitzman commentedComment #11
Budrick commented