Problem/Motivation
Currently the isReadOnly Method does not differentiate between a read only field and a computed field.
I am trying to copy all field values from one entity to another and failing miserably. As the related issues note, there's not really a set understanding of what isReadOnly() even returns but when I look at what is actually setReadOnly then those fields really shouldn't be changed so it would make sense to just skip fields that isReadOnly() except DataDefinition::isReadOnly falls back to computed if read only is not explicitly set so computed fields like path will appear like "read only" when they are not. The same bug of hurt applies to the pathauto property because, again, this is at the very root of the typed data hierarchy.
Proposed resolution
The sensible route would be to add setReadOnly(FALSE) to path_entity_field_info but I have no idea what havoc that will play with backwards compatibility.
Comments
Comment #2
hchonovI guess that starting Drupal 9 we could fix that and prevent read only fields from being changed after they have been populated once.
Comment #3
ghost of drupal pastComment #12
luke.stewart commentedIssue of the day for BSI.
At the core is the question whether a computed field should be considered read only. This issue postulates that it should not be the case.
There are two interpretations:
Read Only to be immutable. In which case a computed field would not met this criteria.
Read Only to mean - only read operations should be performed, but the result of a read operation might change (in the case of a calculated field).
Given the associated #2907629 it probably makes sense for a wider decision as to how to hand readOnly fields this would then inform whether computed fields should be considered readOnly which would then inform whether this should be considered a bug or a feature request.
Either way this probably needs an issue summary update.