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.

CommentFileSizeAuthor
#1 features-2034285-1.patch1.04 KBLes Lim
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Les Lim’s picture

Status: Active » Needs review
FileSize
1.04 KB

Patch attached.

Status: Needs review » Needs work

The last submitted patch, features-2034285-1.patch, failed testing.

hefox’s picture

Status: Needs work » Needs review

#1: features-2034285-1.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, features-2034285-1.patch, failed testing.

hefox’s picture

likely need to do
drush en -y features_test; drush cc all; drush fu up -y features_test and include that in the patch

mpotter’s picture

No, 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.

bburg’s picture

Issue summary: View changes

As an example of what this might be breaking is this issue in conditional_field: https://www.drupal.org/node/2193055.

capysara’s picture

Yes, @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?

capysara’s picture

donquixote’s picture

Issue summary: View changes

For 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.