Problem/Motivation
FractionItem does not define the static method mainPropertyName() and falls back to the FieldItemBase value of 'value'. The Fraction field does not have a column named 'value', and fails a hasData() call.
Steps to reproduce
- Create a CommerceEntityTrait field with a custom fraction field type.
- Save the trait to an entity type.
- Try to load the configuration page on the entity type.
The page will fail to load. The Commerce ConfigurableFieldManager will run a call to hasData() on that field, which will fail because the column 'value' cannot be found in the base table.
Proposed resolution
Add the 'numerator' column as the fields main property value.
Return NULL from the mainPropertyName() static method.
Remaining tasks
See merge request.
Issue fork fraction-3217975
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #5
m.stentaThanks for opening this @alexandersluiter - and for the merge request!
I wasn't aware of this method (
getMainProperty()) - I'm curious where is is used, apart from Commerce, as well as more detail about how Commerce uses it.This might be a bit tricky -
`numerator`might not be the best solution. It depends on where this "main property" is used.Without a denominator, the numerator field is sort of meaningless. So if the numerator is loaded by itself and used for something - I'm worried that might lead to issues.
Is this actually an issue with Commerce's
ConfigurableFieldManager::hasData()logic I wonder?Haven't dug too deep, but I found this older issue that sounds similar/related: #3072156: ConfigurableFieldManager::hasData() doesn't work for address field types
Comment #6
alexandersluiter commentedI've updated the merge request to return a NULL value as the FieldItemInterace allows for it. It should not have any unintended consequences now. It also fixes the issue that the Commerce ConfigurableFieldManager exposes. I'm not sure what else uses it, outside of Commerce, however, the interface exists and the method is used at least once in a fairy large module project. The Interval project had the same issue and settled on returning NULL.
https://www.drupal.org/project/interval/issues/3217962
Comment #7
alexandersluiter commentedComment #9
m.stentaThanks @alexandersluiter! I merged this into the 2.x branch (this is where all new development is happening, with support for Drupal 8 and 9).
I'm hoping to tag 2.0.0 in the near future.
Comment #10
alexandersluiter commentedAwesome! Thank you!
Comment #11
m.stenta