After the process of de-activating, un-installing and removing the Answers module, the content-types it created(Question and Answer) are still available.
Which in my eyes can't be the right thing, or am I missing something?

Comments

chipcleary’s picture

Hi @royvandijk,

I think you raise a good point.

As background, Answers is built using the Features module. This is a known issue in Features and, as it turns out, the appropriate behavior has been fairly extensively debated #1055460: Disabling a feature does not disown content type.

The concern is potentially deleting data when someone might want to reinstall Answers later.

Based on the debate above, the approach I'd suggest is that when someone uninstalls the module, the module asks: Would you like to:

  • Keep the Question and Answers content types and any Questions and Answers content your site contains? (If so, you will be able to manually modify or delete them using the standard content interface)
  • Delete the Question and Answers content types and any Questions and Answers content your site contains?

Then it does the needful based on the response. How does this approach work for all?

maxilein’s picture

My experience was this:
After installing answers i added a new field "details" to the question content type. I uninstalled Answers (because I had to identify bugs), I also deleted questions and answers types manually.

Then I reinstalled answers.
I ran into a pdo error problem, because the reinstalled module did not add the field again. the error was raised each time I tried to add a new question.

The procedure you explain above seems plausible, but it is too easy to get off track and stuck with some unexpected results.

chipcleary’s picture

Hi, here is some code that will allow you to manually "clean up" after answers. It deletes content types and a menu that Answers creates.

It is not yet packaged up nicely into an uninstall module. Nor will it prevent the issue @maxilein describes in #2 above if you reinstall Answers.

function answers_delete_content_types() {
  $types = array(
    'answer',
	'question',
  );

  foreach($types as $type) {
    node_type_delete($type);
    variable_del('node_preview_' . $type);
  }
  node_types_rebuild();
  menu_rebuild();
}

function answers_delete_menus() {
  $menus = array(
     array('menu_name' => 'menu-using-answers'),
  );
  foreach($menus as $menu) {
    menu_delete($menu);
  }
}
amins’s picture

@Chip,

How do we use this function? create a content with php codes or write a module or maybe any other way?

Thanks

amins’s picture

I found this solution: to manually delete a content type that was created by a feature: Comment #16 http://drupal.org/node/1055460#comment-4343708

chipcleary’s picture

@james.icast, glad you found a solution. Probably now not helpful, but if you want to use the code in #3, the easiest way is probably to:

  1. install the devel module (which lets you execute PHP)
  2. enter the code in a PHP dialog
  3. then enter a call to each function in the same dialog
  4. and submit what you've entered
datthanhphu’s picture

JVmNc5msK2Only local images are allowed.

bluegeek9’s picture

Issue summary: View changes
Status: Active » Closed (outdated)