Duplicate declaration of $context in WidgetBase

Created on 2 August 2023, over 1 year ago
Updated 16 August 2023, over 1 year ago

Problem/Motivation

On WidgetBase.php (core/lib/Drupal/Core/Field), it seems there is a duplicated bloc of code:

Lines 114-121

    // Allow modules to alter the field multi-value widget form element.
    // This hook can also be used for single-value fields.
    $context = [
      'form' => $form,
      'widget' => $this,
      'items' => $items,
      'default' => $this->isDefaultValueWidget($form_state),
    ];

And duplicated again a bit after in lines 149-155

    // Allow modules to alter the field widget form element.
    $context = [
      'form' => $form,
      'widget' => $this,
      'items' => $items,
      'default' => $this->isDefaultValueWidget($form_state),
    ];

It seems after the \Drupal::moduleHandler()->alterDeprecated was removed in 10.x, the first declaration of $context was left and it is still appear in 10.1.x and 11.x.

I noticed the duplication while checking the last patch in https://www.drupal.org/project/drupal/issues/2980806 🐛 Fields with unlimited cardinality show 1 extra input field Needs work , as the code there is removed (though it is not part of the solution to the issue).

We could remove the first block and leave just the second one.

Best

Steps to reproduce

Can be checked on https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...

Proposed resolution

Remove the first duplicated code

Remaining tasks

To remove the code

User interface changes

-

API changes

-

Data model changes

-

Release notes snippet

-

🐛 Bug report
Status

Fixed

Version

11.0 🔥

Component
Field 

Last updated 1 day ago

Created by

🇧🇪Belgium gorkagr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024