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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tedbow created an issue. See original summary.

tedbow’s picture

Here is patch and test-only patch

The last submitted patch, 2: 2908674-2-test-only-FAIL.patch, failed testing. View results

Berdir’s picture

Makes 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.

Wim Leers’s picture

Glad to have your +1, Berdir :)

  • larowlan committed 867ecd8 on 8.5.x
    Issue #2908674 by tedbow: When using get() method directly on PathItem...

larowlan credited larowlan.

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed as 867ecd8 and pushed to 8.5.x.

Berdir’s picture

I 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?

Wim Leers’s picture

Version: 8.5.x-dev » 8.4.x-dev
Status: Fixed » Reviewed & tested by the community

Good point!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: 2908674-2.patch, failed testing. View results

  • xjm committed 6462ddf on 8.4.x authored by larowlan
    Issue #2908674 by tedbow: When using get() method directly on PathItem...

xjm credited xjm.

xjm’s picture

Status: Needs work » Fixed

Actually 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.