Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The is_numeric($var)
check outputs the string with floatval(), whether I want it to or not. We can preserve the intentionality of numeric strings by just adding a is_string()
check before is_numeric()
.
Background
The conversion from string to number (float/int) was originally introduced in 3fc3a94cd and 78772d50b, both are tagged with #1721926: Field Instance Export "weight" - brings me in a Override ping/pong - quotes and no quotes.
Comment | File | Size | Author |
---|---|---|---|
#1 | features-2034285-1.patch | 1.04 KB | Les Lim |
Comments
Comment #1
Les LimPatch attached.
Comment #3
hefox CreditAttribution: hefox commented#1: features-2034285-1.patch queued for re-testing.
Comment #5
hefox CreditAttribution: hefox commentedlikely need to do
drush en -y features_test; drush cc all; drush fu up -y features_test and include that in the patch
Comment #6
mpotter CreditAttribution: mpotter commentedNo, I'm not sure about this one. The reason for the addition of the is_int and is_float checks was to fix the issue with Weights in fields getting exported as string values. There are some modules that are incorrectly returning numeric values as string data. So adding this is_string patch would break that stuff again.
This one needs a lot more testing and justification of what it's breaking to be considered.
Comment #7
bburgAs an example of what this might be breaking is this issue in conditional_field: https://www.drupal.org/node/2193055.
Comment #8
capysara CreditAttribution: capysara commentedYes, @bburg is correct. I'm having the same issue described in https://www.drupal.org/node/2193055. Should this be addressed in Features or Conditional Fields?
Comment #9
capysara CreditAttribution: capysara commentedThis is a likely duplicate: https://www.drupal.org/project/features/issues/2356437
Comment #10
donquixote CreditAttribution: donquixote commentedFor the record:
The conversion from string to number (float/int) was originally introduced in 3fc3a94cd and 78772d50b, both are tagged with #1721926: Field Instance Export "weight" - brings me in a Override ping/pong - quotes and no quotes.
Imo this looks wrong, and should not have been committed.
However changing this now would be risky and have side effects..
Before we can do anything here I need to study the original issue, #1721926: Field Instance Export "weight" - brings me in a Override ping/pong - quotes and no quotes.
Existing modules that struggle with this might want to implement hook_features_export_render() as a workaround.