function features_var_export() has this code:

   else if (is_numeric($var)) {
    $floatval = floatval($var);
    if (is_string($var) && ((string) $floatval !== $var)) {
      // Do not convert a string to a number if the string
      // representation of that number is not identical to the
      // original value.
      $output = var_export($var, TRUE);
    }
    else {
      $output = $floatval;
    }

Which converts numeric strings to float for sake of this fixing issue #1721926

But this fix introduces new bug which is IMHO more critical than this weight override ping/pong.
If integer list field has allowed values like these:

0|Zero
1|One

Then options.module:options_field_widget_validate() fails on:

if ($element['#required'] && $element['#value'] == '_none')

Because when $element['#value'] is set to 0 not "0" it gets evaluated to FALSE.
Features don't respect original default value "0" returned from field_info_instance() and convert it to 0.
This get's inserted to the database field_config_instance 'data' column.

So when we add new integer list field with mentioned allowed values then default value written to the database is "0" .
But when we revert the feature then integer 0 is written to the database instead of sting "0" and when we select 'Zero' radio button in the form (which corresponds with value 0) then (given that this field is required) validation fails and despite selecting the radio button corresponding with 0|Zero field value Drupal complains that this field is required as if any radio button hasn't been selected at all.

I think it would be better to remove this code ASAP and find better way how to fix override ping/pong later.

CommentFileSizeAuthor
dont_convert_numeric_strings.patch870 bytesPawelR
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

PawelR’s picture

Issue summary: View changes
PawelR’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, dont_convert_numeric_strings.patch, failed testing.

PawelR’s picture

Status: Needs work » Active
hefox’s picture

Did you look for an existing issue about this? I'm fairly certain I've seen one

PawelR’s picture

Issue summary: View changes
PawelR’s picture

PawelR’s picture

Thanks for mentioning that, I've found this issue:

https://www.drupal.org/node/2248129

It's about different error but caused by the same piece of code, I added it as related issue.

PawelR’s picture

Status: Active » Closed (duplicate)