Allow skipping form alter for the specific form

Created on 14 December 2020, over 3 years ago
Updated 20 January 2023, over 1 year ago

Problem/Motivation

Motivation: Performance improvement

To allowing having same form multiple times on a page via blocks or listing of entities we might add entity ids in the form id.

For examples
1. webform submission form https://git.drupalcode.org/project/webform/-/blob/6.x/src/WebformSubmiss...
2. Product add to cart form https://git.drupalcode.org/project/acquia_commercemanager/-/blob/8.x-1.x...

This means module_implements cache entry in cache bootstrap will be updated for each and every entity.

Steps to reproduce

  • Use webform module and create few webforms
  • Check the entry in cache_bootstrap for the cache id module_implements after visiting the new webforms

Proposed resolution

To avoid updating cache entry for each entity we allow the forms to stop invoking the alter hook for the dynamic form id, ideally these forms will already have the base_form_id set and alter hooks will be triggered for them. We will need to add this in the main form itself.

Add the following code (along with the patch) in the Form Plugin at very early stage to get benifit of this performance improvement.

$form['#skip_form_id_hook_alter'] = TRUE;

Remaining tasks

  • Review the approach in patch
  • Update relevant documents and do announcements for the new change

User interface changes

None

API changes

New key added in $form to allow skipping alter hook

Data model changes

None

Release notes snippet

TBD

✨ Feature request
Status

Needs work

Version

9.5

Component
Form  →

Last updated less than a minute ago

Created by

🇮🇳India nikunjkotecha India, Gujarat, Rajkot

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

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

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs performance review

    It is used to alert the performance topic maintainer(s) that an issue significantly affects (or has the potential to affect) the performance of Drupal, and their signoff is needed. See the governance policy draft and Drupal Core gate - performance for more information.

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.69.0 2024