Settings form takes forever to load when there are many books

Created on 6 January 2023, almost 2 years ago
Updated 6 August 2024, 4 months ago

Problem/Motivation

The sitemap modules book plugin lets you display a section on the sitemap for each book on the site. However, when you have a lot of books (my site has 1445 books), the settings page at /admin/config/search/sitemap takes forever to load, even if you don't use any instances of the book plugin (we don't use the book plugin).

Steps to reproduce

  1. Install drupal core, and the sitemap module-project.
  2. Enable the sitemap module, and the book module.
  3. Go to /node/add/book and create a book — under Book outline, you will need to set "Book" to - Create a new book - before saving. To better illustrate the problem, repeat this 1445 times (sadly, devel_generate will create book nodes, but won't put them in books, so it's not very useful here).
  4. Go to /admin/config/search/sitemap. Actual behavior: Long load times because 1445 checkboxes are rendered. Expected behavior: Shorter load times if we are not using the book plugin (?).

Proposed resolution

From #2, it seems pretty likely that Core's book module will move to contrib in the near future (see 📌 [Policy] Move book to contrib in Drupal 11 Fixed ); so our proposed resolution is:

  1. Create a sitemap_book submodule, and move the book plugin, deriver, and test into the submodule
  2. Update the plugin to refer to the new deriver; update the test to enable the new submodule
  3. Move the config schema into the new submodule
  4. Move the implementation of hook_ENTITY_TYPE_delete() which clears the sitemap plugin cache when a book is deleted into the submodule
  5. Write an update hook that looks to see if any book plugins are enabled, and if so, enables the new submodule; so that the project continues to work as before for sites already using book plugin(s)

Remaining tasks

  1. See 📌 Drupal 11 compatibility fixes for sitemap Fixed and Split sitemap_book config schema from sitemap schema Active

User interface changes

None.

If you have at least one book sitemap plugin enabled when you apply the patch, and you run database updates, then the new "Sitemap: Book" (sitemap_book) submodule will be enabled automatically, and the Sitemap settings form will look the way it did before.

If you have books on your site, but you don't have any book sitemap plugins enabled when you apply the patch, then you will (intentionally!) no longer see checkboxes for them on the Sitemap settings form (unless you enable the "Sitemap: Book" (sitemap_book) submodule).

API changes

None.

Data model changes

No changes to the database model; although you should run database update after applying the patch to install the new "Sitemap: Book" (sitemap_book) submodule if necessary.

Feature request
Status

Closed: duplicate

Component

Code

Created by

🇨🇦Canada ndesanto

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

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.71.5 2024