Problem/Motivation
On the saveToDedicatedTables() in the SqlContentEntityStorage.php is not working properly with mapitem fields, the following code:
foreach ($storage_definition
->getColumns() as $column => $attributes) {
$column_name = $table_mapping
->getFieldColumnName($storage_definition, $column);
// Serialize the value if specified in the column schema.
$value = $item->{$column};
if (!empty($attributes['serialize'])) {
$value = serialize($value);
}
$record[$column_name] = SqlContentEntityStorageSchema::castValue($attributes, $value);
}At the $value = $item->{$column}; is trying to get $item->value that does not exist in this item(the correct in my analysis would be $item->values)
Steps to reproduce
Programatically insert an array in a MapField, try to save the entity that has the field data.
Proposed resolution
I changed the code to:
if(!isset($item->$column)){
$value = $item->getValue();
}
else{
$value = $item->$column;
}
But its a invasive solution that changes the drupal core, and i want to discuss with you guys if this is really an issue and if this change is safe to do.
Remaining tasks
Discuss the problem and check if this is a core issue or it's a mistake from my part.
discuss if the proposed solution is ok.
Comments