When it gets enabled, Forum does a number of things that do not get undone during uninstall:

  • creates the vocabulary "forum_nav_vocabulary"
  • creates the field "taxonomy_forums"
  • set the variable "forum_nav_vocabulary"

I could understand an argument against deleting the vocabulary: taxonomy is used in a lot of different ways by contrib modules, and deleting it out from under contrib modules could cause problems.

But, the variable should be deleted, and if the field is not in use by any other bundle, it should go as well.

In forum_uninstall(), this patch:

  • deletes the variable "forum_nav_vocabulary"
  • checks to see if the field "taxonomy_forums" is in use by any bundle besides node type forum. If it is not in use by another bundle, it is deleted.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

I would actually delete the vocab too since it is clearly owned by forum module (see its machine name). But I can see both sides so lets just go with what you've proposed.

andypost’s picture

Dries’s picture

+++ modules/forum/forum.install	25 Jun 2010 19:30:58 -0000
@@ -103,6 +103,22 @@ function forum_uninstall() {
+  if (!empty($field_info['bundles']) && count($field_info['bundles']) == 1) {
+    $bundles = $field_info['bundles'];
+    if (($i = array_search('forum', $bundles['node'])) !== FALSE) {
+      unset($bundles['node'][$i]);
+      $bundles = array_filter($bundles);
+    }
+    if (empty($bundles)) {
+      field_delete_field('taxonomy_forums');
+    }

I'm not sure I fully understand this patch. We know that there is exactly one bundle, so why would $bundles be empty()?

andypost’s picture

I think probably bundle could be deleted

AaronBauman’s picture

Dries:
I think the logic in the attached revised patch is cleaner. Please let me know if it's still unclear.

andypost:
the bundle gets deleted since it's owned by a module that's getting disabled. I think node module handles this.

andypost’s picture

Related #599016: Only allow nodes to be posted to forums

Why the condition is count($field_info['bundles']) == 1

AaronBauman’s picture

Status: Reviewed & tested by the community » Needs work

andypost:
In English, the logic should read:
"Given the field "taxonomy_forums", if the count of bundles is 1, and the count of entities for the 'node' bundle is 1, and the single node entity is 'forum', then delete the field 'taxonomy_forums'"

After re-examining, I see that the if-statement in the previous patch is insufficient.
(It doesn't account for other node types using the field, only other bundles.)

Before I roll another patch, should we further discuss whether this is desirable behavior?

andypost’s picture

Aaron, I scare we should remove that field from all bundles while #599016 is not fixed

Anyway, this field could be optionaly attached by some contrib module so if forum is uninstalling then it should remove all its traces.
I'm not sure that deleting a field will remove it from all bundles

larowlan’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +Needs backport to D7
andypost’s picture

I've marked #599016 as fixed because it iterated now right (only node bundles are used)

The only questions:
1) should we delete forum field?
2) should we check for entities/bundles that could use this field?
3) if we delete variable forum_nav_vocabulary then we shoudl delete vocabulary or make it's seaching in forum_enable() more robust because now we had exception trying to make vocabulary with a same name again.

I think all forum variables should be removed in _uninstall hook with vocabulary and fields

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: +Bug Smash Initiative
FileSize
10.58 KB
41.25 KB

I tested this on Drupal 9.3.x, standard install, using devel to generate content. I also added a second term reference field to the forum content. After generating content, I edited a couple of pages to make sure terms for used in both the reference fields. Then I went to admin/modules/uninstall forum.

There is a nice message saying that I have to some work by hand first,

I did than then returned and uninstalled forum. Then get a nice list of what will be deleted:

Note that it is also deleting the term reference field I added, TestTerms. That wasn't being used anywhere else so it was ok to delete.

That seems to working fine. Is there any need to improve that in some way? If not, this can be moved to Drupal 7.

larowlan’s picture

Version: 8.9.x-dev » 7.x-dev

Agree, this is D7 domain now