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.
| Comment | File | Size | Author |
|---|---|---|---|
| strict_array.patch | 607 bytes | jeremyskinner |
Issue fork name-3178407
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
Comment #2
jeremyskinner commentedComment #3
jeremyskinner commentedComment #6
nkoporeccommitted, thanks!
Comment #7
nkoporec