Speed up \Drupal\Core\Plugin\Context\ContextHandler::checkRequirements by adding a hasMatchingContexts method

Created on 14 September 2023, about 1 year ago
Updated 26 March 2024, 8 months ago

Problem/Motivation

\Drupal\Core\Plugin\Context\ContextHandler::checkRequirements calls getMatchingRequirements which evaluates each context. But in ::checkRequirements we only need to know if one context matches.

Steps to reproduce

Proposed resolution

Add a ::hasRequirements method, that uses foreach and returns early instead of using array_filter.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
Layout builderΒ  β†’

Last updated about 13 hours ago

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

Sign in to follow issues

Comments & Activities

  • Issue created by @larowlan
  • First commit to issue fork.
Production build 0.71.5 2024