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

Created on 14 September 2023, 10 months ago
Updated 26 March 2024, 3 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 3 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.69.0 2024