Problem/Motivation
Domain path logic is done in node form submission. Therefore, it does not act on contents created by other ways, such as via REST or programmatically.
Steps to reproduce
In a installation with the domain_path and domain_path_pathauto modules enabled and some pathauto pattern set, create a new content programmatically. The domain path alias is not created.
Proposed resolution
Move domain path logic to entity API based events, as pathauto does.
Remaining tasks
TBD.
User interface changes
None.
API changes
TBD.
Data model changes
None.
Issue fork domain_path-3247423
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 #2
quadrexdevI think it makes sense and should be implemented. I'll work on it.
Comment #3
_tarik_ commentedHi quadrexdev
This module is used in one of my projects with JSON:API and has problems mentioned in the task description.
I plan to start work on this in the next few days. Would you mind assigning this issue to me?
I plan to do these steps to fix the problem:
Comment #4
_tarik_ commentedHi, I have pushed part of the required changes that provide the ability to use domain path fields on the entity API level.
However, changes for the domain_pathauto aren't finished. We need to cover new code by tests and refactor it.
But that is the start of work on this issue.
Comment #5
mably commentedCreated the related MR for better visibility of the work that has been done.
Looks like a significant change.
Comment #7
mably commentedComment #8
mably commentedComment #10
mably commentedFixed in 2.x.
Comment #14
idebr commentedMy local environment already had a number of base field overrides that tripped up field logic for 'path', for example:
core.base_field_override.node.page.path.yml
I'm not sure what triggers the creation of such base field override. However, the result was the domain_path widget was never applied and the node edit form triggered several warnings:
Comment #15
mably commentedHi @idebr, could you give a try to this issue's MR?
#3564844: Switch to using the default core path_alias table instead of the custom domain_path one
I was required to add a weight of
10to thedomain_pathmodule to have its hooks processed after those of thepathmodule.Comment #16
idebr commenteddomain_path_entity_base_field_info correctly fires after the path module, but the base field override from #14 still take precedence. For bundles without base overrides, the code works correctly.
The relevant code from \Drupal\Core\Entity\EntityFieldManager::buildBundleFieldDefinitions that overrides the base field definition is here: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...
Perhaps a more fool-proof approach is to add a property to the PathItem similar to pathauto? https://git.drupalcode.org/project/pathauto/-/blob/8.x-1.x/src/PathautoI...
Or rename the base field to 'domain_path' to prevent the clash altogether
Comment #17
mably commentedThis field override is not new. How come you are getting hit now?
Can't you get rid of that override in #14?
Comment #18
mably commentedLooks like we should use the
hook_entity_base_field_info_alter()hook.Comment #20
mably commented@idebr, could you give a try to MR 62 and tell me if it fixes your problem?
EDIT:
In fact, it doesn't work. Looks like we will have to use a custom field name like
domain_path.Comment #21
mably commentedMR 62 has been updated to use a new dedicated field name (
domain_path). All tests are green.Could you give it a try @idebr?