Commit a5181519 authored by webchick's avatar webchick

#890210 by Manuel Garcia, Sutharsan, bjaspan: Fixed Cannot enable Comment...

#890210 by Manuel Garcia, Sutharsan, bjaspan: Fixed Cannot enable Comment module after a Drupal 6 to Drupal 7 upgrade.
parent f3755738
......@@ -6,6 +6,35 @@
* Install, update and uninstall functions for the comment module.
*/
/**
* Implements hook_install().
*/
function comment_install() {
// Create comment body field.
if (!field_info_field('comment_body')) {
$field = array(
'field_name' => 'comment_body',
'type' => 'text_long',
'entity_types' => array('comment'),
);
field_create_field($field);
}
// There is a separate comment bundle for each node type to allow for
// per-node-type customization of comment fields. Each one of these bundles
// needs a comment body field instance. A comment bundle is needed even for
// node types whose comments are disabled by default, because individual nodes
// may override that default.
// @todo This should be changed to call field_attach_create_bundle() instead,
// and a comment_field_attach_create_bundle() function should be added to
// handle the creation of the comment body field instance.
foreach (node_type_get_types() as $type => $info) {
if (!isset($info->is_new) && !isset($info->disabled) && !field_info_instance('comment', 'comment_body', 'comment_node_' . $info->type)) {
_comment_body_field_instance_create($info);
}
}
}
/**
* Implements hook_uninstall().
*/
......@@ -46,33 +75,6 @@ function comment_enable() {
db_insert('node_comment_statistics')
->from($query)
->execute();
// Create comment body field.
// @todo this should be done in comment_install, but causes exceptions
// in testing because the list of fields types is not available in
// hook_install(): _field_info_collate_types() returns an empty array.
if (!field_info_field('comment_body')) {
$field = array(
'field_name' => 'comment_body',
'type' => 'text_long',
'entity_types' => array('comment'),
);
field_create_field($field);
}
// There is a separate comment bundle for each node type to allow for
// per-node-type customization of comment fields. Each one of these bundles
// needs a comment body field instance. A comment bundle is needed even for
// node types whose comments are disabled by default, because individual nodes
// may override that default.
// @todo This should be changed to call field_attach_create_bundle() instead,
// and a comment_field_attach_create_bundle() function should be added to
// handle the creation of the comment body field instance.
foreach (node_type_get_types() as $type => $info) {
if (!isset($info->is_new) && !isset($info->disabled) && !field_info_instance('comment', 'comment_body', 'comment_node_' . $info->type)) {
_comment_body_field_instance_create($info);
}
}
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment