Access logic differs Renderer::doRender Element::isVisibleElement

Created on 30 June 2017, about 8 years ago
Updated 15 August 2025, about 16 hours ago

Problem/Motivation

Renderer::doRender has a bunch of access logic, including #access and #access_callback. Element::isVisibleElement checks both whether an element is visible (based on #type) and whether is it accessible. However, it only checks #access.

Proposed resolution

Renderer:doRender is obviously the canonical solution. Element::isVisibleElement should be brought in line.

Better still, I would propose adding Element::isAccessibleElement that is used by both Renderer:doRender and Element::isVisibleElement, with the added bonus that it would also be usable elsewhere (there are 30 places that read values from #access).

Remaining tasks

  • Write the patch including test coverage.
  • Look at everything that reads from #access and, if appropriate, update.
  • Write a change notice.

User interface changes

None.

API changes

Addition of new method on Element for checking accessibility that should become the standard way of checking. Contrib could continue to use the old method without any new breaks, but the new approach should be encouraged as it also checks #access_callback.

📌 Task
Status

Postponed: needs info

Version

11.0 🔥

Component

render system

Created by

🇬🇧United Kingdom andrewbelcher

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.

  • 🇦🇺Australia acbramley

    Triaged as part of bug smash. It doesn't seem like this is a bug and I'm not actually sure if it'd be possible (or beneficial) to combine the 2.

    Element::isVisibleElement is a static function so doing anything with access_callback would be tricky, and it may be intentional that this code doesn't try to process that callback. That would mean isAccessibleElement would just be checking something like ($element['#access'] instanceof AccessResultInterface && $element['#access']->isAllowed()) || ($element['#access'] === TRUE) but then ::doRender needs to do those checks anyway so it can add the cacheable dependency, etc.

    With that in mind, I'm not sure if this is something we need to do?

Production build 0.71.5 2024