I've found that with the current (Drupal 8) version of Pathauto, it is not possible to have both custom and automatically generated aliases per translation - only per node. For example, if I have a node translated into French and Spanish, and I have automatic aliases, and set a custom alias on the French translation, that custom alias will override the aliases for the Spanish and English translations of the node, as well.

This patch takes the langcode into account, as well as the entity ID. I've tested it pretty thoroughly, but I've never gotten into the guts of Pathauto before, so please test and let me know if anything is missing. It now allows for each translation of a node to use either the custom or automatic alias.

Comments

aburke626 created an issue. See original summary.

aburke626’s picture

StatusFileSize
new0 bytes

Status: Needs review » Needs work

The last submitted patch, 2: alias-per-translation-2880482.patch, failed testing.

aburke626’s picture

StatusFileSize
new1.36 KB
aburke626’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: alias-per-translation-2880482.patch, failed testing.

aburke626’s picture

StatusFileSize
new1.36 KB

Updated patch - one instance of changing `EntityID` to `entity_id`.

aburke626’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: allow_for_custom_or-2880482-7.patch, failed testing.

andreyjan’s picture

StatusFileSize
new1.57 KB

Re-rolled the patch for current module's version.

andreyjan’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 10: allow_for_custom_or-2880482-10.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

Component: Code » I18n stuff
damienmckenna’s picture

Version: 8.x-1.0 » 8.x-1.x-dev
damienmckenna’s picture

I wonder if the tests fail because EntityAliasTypeBase::batchDelete() needs to be updated to handle the concatenated ID string too?

damienmckenna’s picture

Also, this needs an update script to append the langcode to 'name' values in the {key_value} records.

damienmckenna’s picture

Issue summary: View changes

A quick update to be clear on what the status is on this change.

The basic functionality works correctly, so kudos to @aburke626 for digging through that!

There are a few problems with the current patch:

  • It needs an update script to fix existing records, i.e. hook_post_update_NAME()
  • The batch deletion system needs to be updated accordingly, and this is what's causing the test failures; I don't know how often this functionality is used on most sites, so many sites might be fine without it for now.
jansete’s picture

I think that this issue is very important.

Multiple editors working in different translations of the same node could get unexpected results if each of one check or uncheck "Generate automatic translations".

dylanmehl’s picture

StatusFileSize
new1.39 KB

The latest patch did not apply on Pathauto version 8.x-1.11. I re-rolled the latest patch and made it compatible with 8.x-1.11.

mably’s picture

mably’s picture

Status: Needs work » Closed (duplicate)

Closing as a duplicate of #3131794.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.