In the processElement() method (in the Dimensions and Measurement elements), '#field_suffix' isn't always defined, leading to a potential PHP notice when you have a field description:
Notice: Undefined index: #field_suffix in Drupal\physical\Element\Measurement::processElement() (line 139 of modules/contrib/physical/src/Element/Measurement.php).
Steps to reproduce:
- Add a physical 'Dimensions' or 'Measurements' field to a node type.
- Make sure the field has a description.
- When you go the node add/edit form that has the Physical field, the PHP notice appears.
This patch makes sure that '#field_suffix' is set, though not sure if this is the best approach, since you end up with an empty '#field_suffix' in some cases.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | undefined_field_suffix-2940428-2.patch | 898 bytes | brunodbo |
Comments
Comment #2
brunodboComment #3
brunodboComment #4
joelpittet@brunodbo What's the steps to reproduce this notice?
Comment #5
brunodbo@joelpittet Updated the summary with steps.
Comment #7
joelpittetThanks, that helps visualize the problem:) I've committed and pushed to the -dev branch.
Comment #8
joelpittet@brunodbo looks like this RTBC patch is going to remove this all together, could you review it as well and I may revert this fix and commit that: #2877891: Help text forcing unit select up
Comment #9
brunodboHeh, something like the patch in #2877891: Help text forcing unit select up was on my mind to do next :) Indeed, it solves this issue and some others, so let's go with that.
Comment #10
joelpittetComment #11
bojanz commentedIt's bad practice to revert bug fixes just because another issue is going to refactor the code.
Comment #13
bojanz commentedCommitted again. This gets rid of the notice while the other issue becomes ready.
Thanks, brunodbo.
Comment #14
joelpittetI've never heard that before. I would think it's more nuanced than a blanket rule. There were more people RTBCing the other patch and I checked with the author of this patch before reverting.