Hello

I've faced following issue: I've placed a pattern for users. I haven't defined any language restriction for such pattern:
Pattern definition UI

Then, once I create an new account, pattern works only for the language on what it was created (this, because src/PathautoGenerator.php::createEntityAlias on line 180, aprox, language is fetched from entity: $langcode = $entity->language()->getId();). But of course, users do not have enabled translation. So, it should take "und" because alias should work for all languages.

Patch on the way...

Issue fork pathauto-3127656

Command icon 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

waspper created an issue. See original summary.

waspper’s picture

StatusFileSize
new1.07 KB
waspper’s picture

Status: Active » Needs review

Status: Needs review » Needs work

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

malte.koelle’s picture

Patch #2 looks good to me, besides the fact that the tests are failing.
I found this issue #2923672: Aliases not generated for users on one language. Could this possibly be a duplicate?

waspper’s picture

I agree @malte.koelle. They're same issue. But I think (IMHO) we should manage it here, because this patch should work for any entity. And there, they're talking about just users. Anyway, let's allow them to decide :)

berdir’s picture

There are several language related and overlapping issues with recent activity atm. Please help to unify that by closing things as duplicates and combining patches.

Keep in mind that:

a) There are long-standing issues open in drupal core that are related to the path alias widget and language handling. My argument so far was always that the behavior of pathauto should be consistent with manually created aliases and I don't really plan to change that.

b) Any change will not only need to pass the existing tests but also have additional test coverage for the new use case.

vflirt’s picture

It seems that the languages selector on the pattern is misunderstood. As far as I understand it we can set a specific pattern for specific language which would require the alias field first to be translatable meaning when the node is in French (or for the French translation of the source node) we can have different pattern. If no languages are selected then this pattern is applied to all translations and this is the how it currently works.
CreateAlias calls $pattern = $this->getPatternByEntity($entity); which loads pattern based on conditions. All I tested works correct.

From what I see as the patch and thinking here is that the created alias would be with language not specified which is not how pathauto and core work by default. I suggest we close this issue as working as designed. If path alias is needed for language not specified which is what I also need than you should look for https://www.drupal.org/project/drupal/issues/2689459 that fixes core issue for manually entered urls and I suggest we work on a patch in https://www.drupal.org/project/pathauto/issues/3069519 as it describes exactly that issue in pathauto.

If you small amount of content you can manually change the language of the generated aliases but in my cases there could be thousands of nodes so not really easy.

benjifisher made their first commit to this issue’s fork.

benjifisher’s picture

For the project I am working on, I have already applied the core patch from #2689459: If you don't want to translate your URL alias, the original URL alias won't work with your translations. I would like Pathauto to be consistent. I always think twice before going against @Berdir's advice, but in this case I think the arguments in #7 do not apply for this site.

If I understand correctly, the point of #8 is that we should check whether the alias is set to be translated, as well as the configured languages for the pattern, before using language neutral. I think that is correct, but that condition is satisfied for my site.

I looked at the test failures from #2. If I read it correctly, the failure is when an alias is manually edited, then the node is set to use the Pathauto pattern. I tried that manually, and it worked as expected. That needs further investigation.

The patch in #2 is pretty simple, but I think it is a little simpler to use array_filter() instead of array_reduce(). I have created an issue fork with the original patch and then changing that.

rteijeiro’s picture

I used the solution described in #2946354: Alias not using language undefined when alias is not translatable as it seems core patch in #2689459 is not working for automatically generated url aliases. Will keep it as a temporary solution until core is fixed.

Referenced other related issues.

mably’s picture

Status: Needs work » Closed (duplicate)

Let's close this as a duplicate of #2946354.

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.