Problem/Motivation

When the Forum module enabled, and the forum vocabulary deleted, and I visit the Uninstall page under Extend, Drupal crashes.

Steps to reproduce

Steps to reproduce:

  1. Enable forum module
  2. Remove forums vocabulary (admin/structure/taxonomy/manage/forums/delete)
  3. Visit module uninstall page (admin/modules/uninstall)

Logged error:
Recoverable fatal error: Argument 1 passed to Drupal\forum\ForumUninstallValidator::hasTermsForVocabulary() must implement interface Drupal\taxonomy\VocabularyInterface, null given, called in /Webserver/drupal-8.1.5/core/modules/forum/src/ForumUninstallValidator.php on line 72 and defined in /Webserver/drupal-8.1.5/core/modules/forum/src/ForumUninstallValidator.php on line 114

Proposed resolution

The error points to line 72 in ForumUninstallValidator.php, so that would be the starting point for resolving the issue.

Remaining tasks

Write a test
Patch
Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

svenryen created an issue. See original summary.

cilefen’s picture

Priority: Normal » Major
joebot’s picture

To reproduce, install the core forum module and then load admin/modules/uninstall.

joebot’s picture

Status: Active » Needs review
alonaoneill’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
shreyal999’s picture

Verified with 8.7, this looks working correctly. Issue not replicated.

yogeshmpawar’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll

Setting back to Needs Review & Triggering bots.

borisson_’s picture

Issue tags: -Forum +Needs tests

This probably needs tests?

johnwebdev’s picture

The issue targets and old version (no longer supported) and I cannot reproduce on 8.7.5. If this issue still exists; please update with steps to reproduce for a supported version of Drupal.

I'm thinking Closed (outdated)?

rensingh99’s picture

I have tested this issue with 8.9x and I have not got the problem. When I visit the uninstall page.

Chi’s picture

Issue summary: View changes

Added steps to reproduce.

Chi’s picture

rensingh99’s picture

FileSize
23.53 KB

Hi,

There is no option to delete the forum vocabulary in admin UI. Since it's dependent on the forum module.

You can delete this vocabulary when you will directly enter the URL "admin/structure/taxonomy/manage/forums/delete" in the address bar.

Then you will get the above error after deleting vocabulary on the uninstall page.

There are no default options to delete that vocabulary due to dependency in the forum module.

The patch is working great. I didn't get the error on the uninstall page if forum vocabulary is deleted.

But I am not sure that we should delete the vocabulary in this way.

Thanks,
Ren

Chi’s picture

Status: Needs review » Needs work

If user removes the vocabulary the forum functionality will be broken in many ways. I think a patch should prevent removal of forum vocabulary.
Note that vocabulary can also be removed through configuration system (drush cim, drush cdel, etc).

rensingh99’s picture

I think a patch should prevent removal of forum vocabulary.

So, in this case, we should change the title and description of this issue.

ccaajj’s picture

Hi all, I just had this problem in 8.8.4 and this seems like the proper place to recap what happened. If not, apologies! and please tell me where I should go :)

The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\forum\ForumUninstallValidator::hasTermsForVocabulary() must implement interface Drupal\taxonomy\VocabularyInterface, null given, called in /home/ccaajj/public_html/conversate/web/core/modules/forum/src/ForumUninstallValidator.php on line 61 in Drupal\forum\ForumUninstallValidator->hasTermsForVocabulary() (line 103 of core/modules/forum/src/ForumUninstallValidator.php).

I went to uninstall the Forum module on the Uninstall module page.The checked checkbox in the left column was disabled. In the right column where the module description and other options can be seen by flipping the disclosure triangle, there were two bullet items saying essentially that all forum module content nodes had to be deleted and all forum vocabulary terms had to be deleted before the module could be disabled. So from the Manage Content and Manage Vocabs admin pages respectively, I deleted as asked.

Going back to the Uninstall page to finish the job, I got the error above. The Forum content type is still present and editable, and all the Forum permissions, links and fields all are still present, though /admin/forum gives a 404.

My experience aside, though I hope it will help in troubleshooting, any ideas on how this can be fixed? Drush pmu failed with the same error and composer remove didn't work because Forum is in core. Any advice appreciated!!

Thanks in advance,

-Chris

ccaajj’s picture

Hi again, I did find an answer for how to get the Uninstall page working again, which let me uninstall Forum after all

https://drupal.stackexchange.com/questions/259483/cant-uninstall-drupal-...

Basically, just create a replacement vocab named Forums and that lets the Uninstall page load as per usual.

-C

Version: 8.1.7 » 8.1.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

pmagunia’s picture

The workaround solution in #17 worked for me. It let me uninstall forums. Thanks

Version: 8.1.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. Branches prior to 8.8.x are not supported, and 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.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

I tested this on Drupal 9.5.x and was able to reproduce the problem. Note that the delete option was not available when editing the forum vocabulary. One has to use the admin/structure/taxonomy/manage/forums/delete.

Perhaps this scenario can be added to \Drupal\Tests\forum\Functional\ForumUninstallTest?

quietone’s picture

Issue summary: View changes

I meant to update the IS.

mohit_aghera’s picture

Adding test cases.

Status: Needs review » Needs work

The last submitted patch, 26: 2774399-26-test-only.patch, failed testing. View results

Munavijayalakshmi’s picture

Version: 9.4.x-dev » 9.5.x-dev
Assigned: Unassigned » Munavijayalakshmi
Status: Needs work » Needs review
Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned
Status: Needs review » Reviewed & tested by the community
FileSize
250.45 KB
80.34 KB

In 9.5.x branch #26 patch applied successfully and clear the error after applying patch.

borisson_’s picture

Status: Reviewed & tested by the community » Needs work

one tiny nitpick/question

+++ b/core/modules/forum/tests/src/Functional/ForumUninstallTest.php
@@ -159,4 +160,24 @@ public function testForumUninstallWithoutFieldStorage() {
+    \Drupal::service('module_installer')->install(['dblog']);

why are we installing dblog? I don't see where we use it further?

mohit_aghera’s picture

Status: Needs work » Needs review
FileSize
2.55 KB
685 bytes

Yup, looks like I forgot to remove that. 👍
Updating the patch.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

thanks, back to rtbc

  • catch committed 0b82131 on 10.0.x
    Issue #2774399 by mohit_aghera, joebot, Munavijayalakshmi, rensingh99,...
  • catch committed b3af257 on 10.1.x
    Issue #2774399 by mohit_aghera, joebot, Munavijayalakshmi, rensingh99,...
  • catch committed a6b5766 on 9.5.x
    Issue #2774399 by mohit_aghera, joebot, Munavijayalakshmi, rensingh99,...
catch’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Needs follow-up

I think it's a good idea to add a custom validator to prevent deletion of the forum vocabulary, but since there are sites already in this state, fixing this makes sense too.

Committed/pushed to 10.1.x and cherry-picked back to 9.5.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

quietone’s picture

Issue tags: -Needs follow-up