Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Wim Leers on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Introduced in version:
8.0.0-BETA11
Issue links:
Description:
- API break:
MenuLinkTreeElement::access
must now be NULL or anAccessResultInterface
object, it used to be either NULL or a boolean. - API addition:
MenuParentFormSelectorInterface::getParentSelectOptions()
has gained a new optional parameter. - API addition:
Element::isEmpty()
Practically
DefaultMenuLinkTreeManipulators::checkAccess()
now sets anAccessResult
object (which implements bothAccessResultInterface
andCacheableDependencyInterface
). This ensures that the final menu tree contains all the necessary cacheability metadata during rendering.MenuLinkTree::build()
now tracks the cacheability metadata of both access results and the links it renders, and then applies that cacheability metadata to the the render array it returns. The cacheability of rendered URLs is taken care of inmenu.html.twig
, becauseMenuLinkTree::build()
does not actually render URLs, the Twig template does.MenuLinkTree::build()
just figures out *which* links to render.
This means that any code that was transforming a menu link tree, and included an access-checking menu link tree manipulator, and manually rendered (i.e. not using MenuLinkTree::build()
) the end result, must now perform access checking in that manual rendering.
Similarly, if you had written any custom menu link tree manipulator that performed access checking, it must now no longer set booleans, but AccessResultInterface
objects.
Impacts:
Module developers