The URL for each item within a book tree should be an instance of \Drupal\Core\Url but is not

Created on 30 June 2020, about 5 years ago
Updated 18 September 2024, 10 months ago

In the available variables section of core/modules/book/templates/book-tree.html.twig within items we have (amongst others):

* - url: The book link URL, instance of \Drupal\Core\Url.

However this is no longer true. In https://www.drupal.org/project/drupal/issues/3010378 β†’ it was changed from a Url object to a string in the format entity:node/12345. We found this after updating Drupal Core and finding some of our custom code was no longer working.

Proposed resolution:
1. Either revert the change, so that url continues to be a Url object
or
2. Update the book-tree.html.twig documentation and publish a change record so anyone relying on the current/previous behaviour is able to update their code accordingly
or
3. Patch to create a Url object without loading a node, this will restoe item.url to being a Url object and maintains the performance boost originally sought out by not loading the node. This is compatible with the link Twig function as well.

We have a patch for option 3, but need framework manage review to confirm this is the right approach.

πŸ› Bug report
Status

Fixed

Version

2.0

Component
BookΒ  β†’

Last updated 12 days ago

  • Maintained by
  • πŸ‡ΊπŸ‡ΈUnited States @pwolanin
Created by

πŸ‡¬πŸ‡§United Kingdom nicrodgers Monmouthshire, UK

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