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

Created on 8 June 2020, over 4 years ago
Updated 6 August 2024, 4 months 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

Closed: cannot reproduce

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.

  • 🇨🇦Canada mparker17 UTC-4

    Seems like I might have accidentally stumbled across this and filed 🐛 A "Book name" plugin shows in config when book module not installed; WSOD if you check it Active ... @smustgrave do you have any insight?

    (I'm cleaning up old issues as part of a big review of open issues for 🌱 [Plan] Stable 8.x-2.0 release Active : thank you for your patience with me)

  • 🇺🇸United States smustgrave

    No worries. Off a quick glance definitely seems like could be related. Think when I posted that patch it was the first time I had used book before. But may want to come up with a generic solution in case other contrib modules tie in?

    Also book is being removed from core in D11.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 9 months ago
    25 pass
  • 🇨🇦Canada mparker17 UTC-4

    Copying parts of the issue summary from 🐛 A "Book name" plugin shows in config when book module not installed; WSOD if you check it Active , so I can mark it as a duplicate of this one.

    @smustgrave, may I trouble you to add some tests to the merge request?

  • 🇨🇦Canada mparker17 UTC-4

    I just did some manual testing, and i see that if the book module is uninstalled, a disabled "Book name" item shows in the plugin list; but if the taxonomy module is uninstalled, there is no corresponding Vocabulary item (I called these items "placeholders" in the screenshot below but that's not the best name). I've attached a screenshot of a site with BOTH the book, and the taxonomy modules uninstalled (2024-03-03--sitemap--issue-3150052--commit-9351649.png).

    I think I'd prefer it if there was no "Book name" item (i.e.: I'd prefer it if the book plugin did what the vocabulary plugin does)... but to some extent what's already in the patch/merge-request is good enough for a 8.x-2.0 release (we can always make it consistent in 8.x-2.1, etc.).

    I would like tests before merging this in, however.

    (if you don't have the capacity, I can try to write tests myself, but I have a lot on my plate right now)

  • Status changed to Needs work 8 months ago
  • 🇺🇸United States smustgrave

    So may patch was more of a temporary hack then anything. Think some kind of different solution needs to be in place to make sure we either don't load plugins with missing dependencies or if we do how to check that dependencies are missing.

    May involve a new key being needed for the sitemap plugins

  • Assigned to PrabuEla
  • 🇮🇳India PrabuEla chennai

    @smustgrave

    I am not sure is it right. I have enabled the book module but the plugin is not visible in sitemap config page

  • Issue was unassigned.
  • Pipeline finished with Success
    6 months ago
    Total: 266s
    #185951
  • Status changed to Closed: cannot reproduce 4 months ago
  • 🇨🇦Canada mparker17 UTC-4

    Hi everyone, a follow-up! Thank you for your patience with me!

    As part of 📌 Drupal 11 compatibility fixes for sitemap Fixed , I had to move the book-related functionality into a new <code>modules/sitemap_book/ submodule because the book module became a contrib module and was deleted from core

    Happily, that fixes the book portion of this ticket (i.e.: the steps to reproduce no longer produce a WSOD).

    However, the ticket also mentions a similar problem with taxonomy/vocabularies... but my preliminary testing didn't turn up any undesirable behavior...

    1. before installing the taxonomy module:
      1. try to view the sitemap: no WSOD, no mention of taxonomy/vocabularies/tags
      2. try to configure the sitemap: no WSOD, no mention of taxonomy/vocabularies/tags
      3. save config, try to view sitemap again: no WSOD, no mention of taxonomy/vocabularies/tags
    2. install taxonomy module, configure a "Tags" vocabulary, add a "Tags" term reference to the basic page node type, create several nodes and give them tags
    3. after setting up taxonomy:
      1. try to view the sitemap: no WSOD, no mention of taxonomy/vocabularies/tags
      2. configure the sitemap: no WSOD, see the vocab plugin
      3. enable and configure the plugin for the "Tags" vocab
      4. save config, try to view sitemap again: no WSOD, vocab shows up as-expected
      5. configure the sitemap: no WSOD, everything as-saved
    4. uninstall the taxonomy module: sitemap not listed in uninstall page, no WSOD
    5. after uninstalling the taxonomy module:
      1. try to view the sitemap: no WSOD, no mention of taxonomy/vocabularies/tags
      2. try to configure the sitemap: no WSOD, no mention of taxonomy/vocabularies/tags
      3. save config, try to view sitemap again: no WSOD, no mention of taxonomy/vocabularies/tags

    So I'm going to mark this as "Closed (cannot reproduce)", and mark 3454907 as a parent issue, but please re-open this if I've missed something.

Production build 0.71.5 2024