Hide books, vocabularies from settings form if modules are not enabled.

Created on 8 June 2020, about 4 years ago
Updated 30 May 2024, 29 days ago

Problem/Motivation

One would think calculateDependencies would have an effect, but it did not seem to when I tested briefly.

The if (\Drupal::moduleHandler()->moduleExists('book')) { in the settings form help prevents an exception, but the default (non-derived) option for a Book is still available in the checklist. I'm assuming it would be the same for vocabularies if taxonomy is not installed.

(a "Book name" plugin shows as a plugin that you can enable on the module's configuration page, even when the book module is not installed. If you enable it, then the sitemap displays a WSOD)

Steps to reproduce

  1. Install a fresh Drupal 10 test site using the standard install profile (my test site was on 10.1.x).
  2. Download and install the 8.x-2.x-dev version of the module: composer require "drupal/sitemap:2.x-dev@dev"
  3. Go to /admin/modules. Note that the Core -> Book module is unchecked (uninstalled). Leave it that way.
  4. Go to /admin/modules. Check the checkbox next to Other -> Sitemap to install it, then click "Install".
  5. Go to /admin/config/search/sitemap. Note under Enabled plugins, there is a "Book name" checkbox. Check it, and click "Save configuration". You see the message "The configuration options have been saved"
  6. Go to /sitemap. You see a WSOD, or the message "The website encountered an unexpected error. Please try again later." In the dblog, you see a php message: Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "book.manager". in Drupal\Component\DependencyInjection\Container->get() (line 157 of /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php).
  7. Go to /admin/modules. Check the checkbox next to Core -> Book to install it, then click "Install".
  8. Go to /sitemap. You see the sitemap again, but not a "Book name" section.
  9. Go to /admin/config/search/sitemap. Note under Enabled plugins, the "Book name" plugin has disappeared.

Proposed resolution

Don't display plugins if the module they depend on is not installed.

Remaining tasks

  1. Add tests
  2. Review and feedback
  3. RTBC and feedback
  4. Commit

User interface changes

Plugins will no longer display if the module that they depend on is not installed.

API changes

To be determined.

Data model changes

To be determined.

🐛 Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

🇺🇸United States akalata

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024