Problem/Motivation

The show_component_required_marker setting doesn't always work reliably because of the following code in name_element_render_component:

  $show_component_required_marker = $core
    && !empty($base_element['#show_component_required_marker'])
    && !in_array('default_value_input', $base_element['#field_parents']);

The in_array check isn't doing a strict type comparison, leading to unpredictable results if the field_parents array contains values other than strings.

Steps to reproduce

If the field_parents array looks like the following, then the in_array check will incorrectly evaluate to true:

['some_field', 0, 'entity']

The integer 0 (rather than string 0) will cause the in_array check to always return true due to php's type conversion semantics, nomatter the value for needle.

Proposed resolution

Use a strict check instead. Patch attached.

CommentFileSizeAuthor
strict_array.patch607 bytesjeremyskinner

Issue fork name-3178407

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

JeremySkinner created an issue. See original summary.

jeremyskinner’s picture

Issue summary: View changes
jeremyskinner’s picture

Status: Active » Needs review

nkoporec made their first commit to this issue’s fork.

nkoporec’s picture

committed, thanks!

nkoporec’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.