diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-08-25 08:32:58 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-08-25 08:32:58 +0000 |
commit | a5181519cafda3185b05a19f94c1f0a47d818269 (patch) | |
tree | 68dfc07a1718fea1cca49c66115d053e8eceaceb /modules/comment/comment.install | |
parent | f375573849cd38a8c3860ce23bd92cdbc984fdda (diff) | |
download | brdo-a5181519cafda3185b05a19f94c1f0a47d818269.tar.gz brdo-a5181519cafda3185b05a19f94c1f0a47d818269.tar.bz2 |
#890210 by Manuel Garcia, Sutharsan, bjaspan: Fixed Cannot enable Comment module after a Drupal 6 to Drupal 7 upgrade.
Diffstat (limited to 'modules/comment/comment.install')
-rw-r--r-- | modules/comment/comment.install | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/modules/comment/comment.install b/modules/comment/comment.install index 730211bc6..344aa333e 100644 --- a/modules/comment/comment.install +++ b/modules/comment/comment.install @@ -7,6 +7,35 @@ */ /** + * 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(). */ function comment_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); - } - } } /** |