Closed (fixed)
Project:
Documentation
Component:
Misc
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Dec 2006 at 14:08 UTC
Updated:
3 Feb 2007 at 01:31 UTC
Jump to comment: Most recent file
http://api.drupal.org/api/4.7/function/hook_validate says:
It can also be used to make changes to the node before submission, such as node-type-specific formatting.
Both my recollection and an attempt to do that just now are contrary to that claim.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | hook_validate_ref.diff | 1.01 KB | pwolanin |
| #3 | node.php_2.patch | 1.79 KB | pwolanin |
| #2 | node.php_1.patch | 1.35 KB | plumbley |
Comments
Comment #1
Wesley Tanaka commentedAh yes, hook_submit does exist (I didn't see it the first time in the list). I'd suggest:
1. changing the hook_validate documentation so that the $node parameter is no longer preceded with '&'
2. removing the claim that it's possible to make changes to the node
3. adding a reference to hook_submit for people that want to make changes to a node.
Comment #2
plumbley commented+1 for this fix (remains in HEAD documentation). Combined with an out of date node_example.module, I think this has been confusing quite a few people for a while.
Patch for HEAD attached. Please also apply to 4.7, since it is wrong there too.
Best wishes,
Mark.
Comment #3
pwolanin commentedI'm not sure the & symbol matters- it can be preferable to pass large object by reference just for speed's sake.
Also, in PHP5 all objects are passed by reference no matter the declaration.
Also, the changes are not quite correct, since form_set_value() can be used to make changes at the validate stage:
http://api.drupal.org/api/HEAD/function/form_set_value
Attached patch commited to HEAD version (FYI, anone with CVS access can commit to the docs)
Comment #4
pwolanin commentedalso commited the same changes to the 4.7 branch
Comment #5
plumbley commentedMinor follow up (no action)... Personally I do think removing the & symbol (as in the applied patch) really does matter, since to have left it in would strongly imply pass by reference. Since this is what was true historically (Drupal 4.6), I think the documentation should use belt and braces (comments and code) to make this change as clear as possible.
Comment #6
Wesley Tanaka commentedRemoving the & is important because it makes it clear that changes to the parameter *cannot* be propogated outside of the function.
(in an unimportant but slightly relevant note: I remember chx posting somewhere that parameters without the '&' are actually faster -- some notice produced by his development tool, but I can't find that bug trail).
Comment #7
(not verified) commentedComment #8
webchickWe have a problem...
The API docs should be about code as it currently stands. There should be no references to Drupal versions past; information about API quirks that changed between versions belongs in the "Converting your modules" part of the handbook. Imagine how bloated the API docs would be if we documented every time that an API changed between versions!
So could you please re-word these changes so they're not "Since Drupal 4.7..." and instead "You may not..." or whatever?
Comment #9
pwolanin commentedfixed and committed in 4.7 and HEAD per the attached patch.
Comment #10
(not verified) commented