Closed (works as designed)
Project:
Drupal core
Version:
5.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Nov 2009 at 16:01 UTC
Updated:
31 Dec 2009 at 02:31 UTC
Looking at
http://api.drupal.org/api/function/hook_node_type/5
I'm a bit surprised finding:
<?php
function hook_node_type($op, $info) {
switch ($op){
case 'delete':
variable_del('comment_'. $info->type);
break;
case 'update':
if (!empty($info->old_type) && $info->old_type != $info->type) {
$setting = variable_get('comment_'. $info->old_type, COMMENT_NODE_READ_WRITE);
variable_del('comment_'. $info->old_type);
variable_set('comment_'. $info->type, $setting);
}
break;
}
}
?>
while I was expecting to find code from modules/node/content_type.inc:344
<?php
/**
* Implementation of hook_node_type().
*/
function node_node_type($op, $info) {
if ($op != 'delete' && !empty($info->old_type) && $info->old_type != $info->type) {
$update_count = node_type_update_nodes($info->old_type, $info->type);
if ($update_count) {
$substr_pre = 'Changed the content type of ';
$substr_post = strtr(' from %old-type to %type.', array('%old-type' => theme('placeholder', $info->old_type), '%type' => theme('placeholder', $info->type)));
drupal_set_message(format_plural($update_count, $substr_pre .'@count post'. $substr_post, $substr_pre .'@count posts'. $substr_post));
}
}
}
Is this normal?
Comments
Comment #1
jhodgdonI don't understand why this is a problem? The function body in hook documentation shows a representative example of hwat a module could do to implement the hook. Sometimes the example is taken directly from one of the core modules, and sometimes it isn't.
I think that the example in hook_node_type() is reasonable: it demonstrates what a module could do on the delete operation and what it could do on the update operation. The example from node_node_type() doesn't do anything for the delete operation, and so it's not that great of an example in my opinion.
Comment #2
jhodgdonComment #3
afagiolithanks for clarifing this.
In my understanding, I've been expecting core code instead of example.
Good to know.
Comment #4
jhodgdonOK, then I guess this is not a bug...
Please reopen if you still think this is a problem.
Thanks...