Static cache for constraint objects

Created on 1 February 2017, almost 9 years ago
Updated 10 September 2025, about 2 months ago

Problem/Motivation

Currently Drupal has a static cache for the constraint validators - ConstraintValidatorFactory, but does not have a static cache for the constraints.

For example with the EntityChangedConstraint: if we validate three entities we will create three objects for the EntityChangedConstraint class and only a single object for the EntityChangedConstraintValidator.

Currently when validating just a single node entity we create:
53 Constraint objects without any options.
34 Constraint objects with options.

Proposed resolution

In order to reduce the number of created objects we should add a static cache for constraint objects as well. The correct place for this should be the ConstraintManager.

Remaining tasks

Discuss and write a patch.

User interface changes

None.

API changes

Not known yet.

Data model changes

None.

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡©πŸ‡ͺGermany hchonov πŸ‡ͺπŸ‡ΊπŸ‡©πŸ‡ͺπŸ‡§πŸ‡¬

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

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

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

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.

No activities found.

Production build 0.71.5 2024