Problem/Motivation
This was an oversight in #2846554: Make the PathItem field type actually computed and auto-load stored aliases.
when using get directly on a PathItem
and not a PathFieldItemList
instance the alias is not loaded.
So this will not work:
$node_storage->resetCache();
$loaded_node = $node_storage->load($node->id());
$this->assertEquals('/foo', $loaded_node->get('path')[0]->get('alias')->getValue());
This was discovered in #2871591: Allow ComplexData in TypedData to specify computed properties that should be exposed in normalization and other contexts
because it caused the path values not to be normalized in that issue.
This issue fixes the normalization.
Proposed resolution
Override \Drupal\path\Plugin\Field\FieldType\PathItem::get()
and call \Drupal\path\Plugin\Field\FieldType\PathItem::ensureLoaded
before calling the parent get() method.
Remaining tasks
Patch & tests & Review
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#2 | 2908674-2.patch | 1.37 KB | tedbow |
#2 | 2908674-2-test-only-FAIL.patch | 775 bytes | tedbow |
Comments
Comment #2
tedbowHere is patch and test-only patch
Comment #4
Wim LeersLooks simple & obvious.
This blocks #2871591: Allow ComplexData in TypedData to specify computed properties that should be exposed in normalization and other contexts.
Comment #5
BerdirMakes sense.
Need to find time to look at the generic computed field issue so we can at least move all those overrides to a base class.
Comment #6
Wim LeersGlad to have your +1, Berdir :)
Comment #9
larowlanCommitted as 867ecd8 and pushed to 8.5.x.
Comment #10
BerdirI know we don't commit things to 8.4.x at the moment, but since this is a bugfix, maybe we want to keep it as RTBC or something on 8.4.x and commit it for 8.4.1?
Comment #11
Wim LeersGood point!
Comment #15
xjmActually since 8.3.x we've expanded RC rules to be patch rules except for the last week or so, so I think this can be backported.
The test failure was for the applies-check on 8.5.x, which obviously it doesn't since it was already committed. Thanks!