Hi,
the docs for hook_comment() are missing all required return values for the different $op's.
Also, the example code is wrong, it should move the
cache_clear_all_like(drupal_url(array('id' => $nid)));
into the if clause because else $nid is undefined, and it makes no sense at all. Also, this function doesn't return at all (I don't know if the hook system can handle this)
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 314138-hook_comment_docs.diff | 1 KB | jeffschuler |
Comments
Comment #1
lilou commentedExample code is : http://api.drupal.org/api/function/hook_comment/7
cache_clear_all_like()doesn't exist.Example implementation : http://api.drupal.org/api/function/user_comment/7
Other example implementation : http://api.drupal.org/api/function/search_comment/7
Comment #2
jeffschulerI can't find
cache_clear_all_like()(except in some old D4.6 stuff around the web.) Assuming it shouldn't be used in the example.This issue affects D7 slightly differently than 5 & 6, since hook_comment() is split into individual functions for its various ops. Would/Should I be creating three separate patches for Drupal 5, 6, and 7 in situations where all are affected?
cache_clear_all_like()is still mentioned in D7's example functions for hook_comment_insert() and hook_comment_update().How about using search_comment_insert() & search_comment_update() as examples: ?
Or just continuing with the same pattern as a few of the other hook_comment_* functions, like hook_comment_publish: ?
Comment #3
jeffschulerPatch for D7 HEAD using search examples mentioned in my last comment.
Comment #4
moshe weitzman commentedComment #5
dries commentedCommitted to CVS HEAD. Thanks!
Comment #7
charlie-s commentedWhy was this never committed to Drupal 6 if this was opened in 2008?
Comment #8
ro-no-lo commentedFunny Dries wrote that it was commited, but the docs are still the same.