When trying to save a FALSE-value in a boolean field, the Drupal\feeds\Feeds\Target\Boolean-class does not format it properly.
It sets the value in $values['value'] to be a boolean value, however, boolean fields in Drupal expect int (0/1). This results in a warning when importing entities, and the value is not saved:
SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column '[field_name]_value' at row 1: INSERT INTO {user__[field_name]} (entity_id, revision_id, bundle, delta, langcode, [field_name]_value) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 10 [:db_insert_placeholder_1] => 10 [:db_insert_placeholder_2] => user [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => da [:db_insert_placeholder_5] => )
If i change the code to cast the boolean value to an integer, it works without warnings.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | boolean_target_does_not-2769015-2.patch | 465 bytes | mian3010 |
Comments
Comment #2
mian3010 commentedAttached proposed solution
Comment #3
twistor commentedComment #5
twistor commentedThe BooleanTest needs to be updated.
We can remove the extra string cast. trim() will always return a string. Also, can remove the extra set of parenthesis.
Comment #7
twistor commentedFixed on commit. As well as some other minor cleanups.
Thanks!