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.
Comment | File | Size | Author |
---|---|---|---|
dont_convert_numeric_strings.patch | 870 bytes | PawelR | |
Comments
Comment #1
PawelR CreditAttribution: PawelR commentedComment #2
PawelR CreditAttribution: PawelR commentedComment #4
PawelR CreditAttribution: PawelR commentedComment #5
hefox CreditAttribution: hefox commentedDid you look for an existing issue about this? I'm fairly certain I've seen one
Comment #6
PawelR CreditAttribution: PawelR commentedComment #7
PawelR CreditAttribution: PawelR commentedComment #8
PawelR CreditAttribution: PawelR commentedThanks 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.
Comment #9
PawelR CreditAttribution: PawelR commented