Language-specific aliases only work with url-based language negotiation

Created on 12 April 2011, over 13 years ago
Updated 1 September 2023, over 1 year ago

Updated: Comment #16

Problem/Motivation

The original poster, Dave Cohen, reported this problem running D6:

I get Page not Found errors with pathauto when locale is enabled. The aliases get associated with "English" and never work. If I manually edit an alias, changing it to "All languages", then it works. Not sure whether this is bug or my configuration, would appreciate help either way.

The problem was simplified (the Pathauto module is not required) and reproduced in D7 and D8. The configuration quirks in the original poster's site do not seem to be relevant.

Steps to reproduce (from #11 and #13)

Using Drupal core 7.21 and Pathauto 7.x-dev: Elaborating on the steps to reproduce in D7 and D8 (based on the thread above):

  1. Configure Drupal:
    • D7: enable the core Locale and Content Translation modules.
    • D8: enable the core Language and Content Translation modules
  2. D7/D8: visit admin/config/regional/language, press "Add language" and select "Spanish" from the drop-down
  3. D7/D8: press the "Detection and Selection" tab aka as admin/config/regional/language/configure
  4. D7/D8 In the column of tick boxes make sure that Detection Method URL is unticked while Detection Method Session is ticked; leave the remaining tickboxes set to what they are
  5. Configure Content Types:
    • D7: on the content type settings page for Article admin/structure/types/manage/article tick the Publishing options tab and then the Enabled radio button under "Multilingual support."
    • D8: visit /admin/config/regional/content-language and tick the Content box (Custom Language Settings) as well as the Article box in the Translatable column.
  6. D7/D8: add content: node/add/article, specify an alias under "URL path settings" and in the Language drop-down select "English". Save
  7. D7/D8: Verify that you can View the page via the URL alias
  8. D7/D8: Edit the page, changing the language selector to Spanish. Save.
  9. You can now no longer View the page via its URL alias, although node/... still works.

Is this the problem or a feature?? It's a problem, at the very least it s counterintitutive and not clearly documentedโ€ฆ

Proposed resolution

In #8 SiliconMind proposed an explanation of the problem:

I think that this happens because drupal_lookup_path from path.inc uses global $language_url variable to get current language. But the problem is that $language_url is set to default language if language was not set via url. This is wrong because language could be selected through user preferences or browser language.

The real problem is that url alias should work always regardless of selected language!

Workaround for this is to alter drupal_lookup_path queries to search url_alias table for entries that match provided alias but not necessarily match language that is provided by $language_url variable. The goal is to always return alias source if it exists regardless of selected language.

Remaining tasks

Issue Summary update
Move the patch in #95 to a separate issue.
Manual testing

  1. Finish charactarizing the problem and determine if we have one issue or several.
  2. Decide what the desired behavior is.
  3. Create a patch.
  4. Design tests.
  5. Update documentation
  6. Backport to D7.

User interface changes

(New or changed features/functionality in the user interface, modules added or removed, changes to URL paths, changes to user interface text.)

There will clearly be someโ€ฆ

Once this is sorted out it would be very good to document the behavior and make it easily accessible from the language configuration pages.

Another nice change would be to include the language of a page in the content listing on multi-lingual sites (although this should probably be a separate issue).

API changes

At the moment there do not appear to be any.

Original report by Dave Cohen โ†’

Rather than "hijack" #320710: Pathauto URL Alias leading to Page Not Found โ†’ , submitting new issue. I find I get Page not Found errors with pathauto when locale is enabled. The aliases get associated with "English" and never work. If I manually edit an alias, changing it to "All languages", then it works. Not sure whether this is bug or my configuration, would appreciate help either way. More about the problem: Drupal is unilaterally modifying paths specified by the content author, without notifying the content author.

Proposed resolution

  1. Do not modify user-supplied paths.
  2. If it's absolutely necessary to modify user-supplied paths, at least inform the user.
  3. Avoid 404'ing user-supplied paths -- make them redirect to the changed path, maybe?

Beta phase evaluation

<!--Uncomment the relevant rows for the issue. -->
๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Language systemย  โ†’

Last updated about 24 hours ago

  • Maintained by
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany @sun
Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States Dave Cohen

Live updates comments and jobs are added and updated live.
  • Triaged core major

    There is consensus among core maintainers that this is a major issue. Only core committers should add this tag.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs manual testing

    The change/bugfix cannot be fully demonstrated by automated testing, and thus requires manual testing in a variety of environments.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024