Problem/Motivation

Case:
- we already have a node for two domains with two path alias entities for these domains.
- when we open a node edit form and update the path alias manually, the path alias for the other domain can be updated, but not for the current one.

Why this happens: When the node edit form loads, it uses \Drupal\path_alias\AliasRepository::lookupBySystemPath from \Drupal\path\Plugin\Field\FieldType\PathFieldItemList::computeValue to load data for the form path element, and this method doesn't take into account the current domain, so it can load the wrong entity (the last one), which is the problem, cuz it breaks aliases for the node then.

Proposed resolution

We need to decorate AliasRepository and take into account the domain value if it exists.
For example: In AliasRepository::getBaseQuery add conditions:

    $or = $query->orConditionGroup();
    $or->condition('domain_id', $current_domain);
    $or->isNull('domain_id');
    $query->condition($or);

But the question is how to get the $current_domain correctly

Comments

hitchshock created an issue. See original summary.

hitchshock’s picture

Issue summary: View changes
hitchshock’s picture

Title: Node edit form can load wrong alias entity » Node edit form can load and save the wrong alias entity
hitchshock’s picture

Issue summary: View changes