Problem/Motivation

Background:
1. \Drupal\Core\Language\LanguageInterface::TYPE_URL is not configurable and cannot be made configurable without editing the configuration by hand. Thus, \Drupal\language\Plugin\Derivative\LanguageBlock::getDerivativeDefinitions() will never generate a language switcher block for the URL language type.

2. Given you have a language-specific path alias and visit that URL given by the alias, \Drupal\Core\PathProcessor\PathProcessorAlias::processInbound() will delegate to \Drupal\Core\Path\AliasManager::getPathByAlias() determine the system path of the current URL. The latter (rightly) uses LanguageInterface::TYPE_URL to determine the current language for the alias.

Problem:
Using the language switcher block will generate the switch links using type Language\LanguageInterface::TYPE_INTERFACE (see 1.). Unless this happens to match the negotiation rules of LanguageInterface::TYPE_URL it will thus produce links which when clicked will result in a "Page not found" error, because the system path cannot be determined (see 2.).

This problem is mitigated by the fact that in the default configuration, that Drupal ships with, Language\LanguageInterface::TYPE_INTERFACE and Language\LanguageInterface::TYPE_URL have matching negotiation rules, so that this problem does not surface. However, because the URL negotiation cannot be configured (see 1.), as soon as the interface negotiation is changed, this breaks.

Note that this is further mitigated by #2666634: Session and content entity switch links do not set the URL language, because at the moment language switch link generation does not work with language-aware aliases when using session negotiation. That does not change the fact that the aliases cannot be resolved properly, it just means that the language switcher block does not properly link to the aliases in the first place.

Proposed resolution

???

Remaining tasks

First step: Find a solution.

User interface changes

???

API changes

???

Data model changes

???

CommentFileSizeAuthor
#3 2666628-3-test.patch3.69 KBtstoeckler

Comments

tstoeckler created an issue. See original summary.

tstoeckler’s picture

Issue summary: View changes

Updating issue summary.

tstoeckler’s picture

Issue summary: View changes
Status: Active » Needs review
Issue tags: -Needs tests
StatusFileSize
new3.69 KB

OK, here's a test proving that this is broken.

I wasn't aware that #2666634: Session and content entity switch links do not set the URL language actually changes the behavior here slightly, so noting that in the issue summary.

tstoeckler’s picture

Issue summary: View changes

I've been working on this and #2666634: Session and content entity switch links do not set the URL language in parallel, that's why the patch is what it is and it is in fact valid, but I wanted to point out that since this is actually not necessarily related to the switch links, but to the alias resolving which is broken under these circumstances, the test should be somewhere other than LanguageSwitchingTest in the end.

Status: Needs review » Needs work

The last submitted patch, 3: 2666628-3-test.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

manuel.adan’s picture

Version: 8.5.x-dev » 8.6.x-dev
Status: Needs work » Active
Related issues: +#1125428: Language-specific aliases only work with url-based language negotiation

I ran into this. Trying to access a content entity with:

  1. Language interface: es
  2. Content language: es
  3. Path alias language: es

I got "page not found". (Default language is 'en').

As mentioned in the issue description (2 years ago), the URL language negotiation rule is disabled in my configuration. I spent a few hours to determine what was wrong.

I did not heard about URL language type before, there is no configuration entry in config UI and it is not covered by the documentation. What's the point of having an URL language negotiation type?

I managed to solve it by manually editing the "language.types" configuration, making a copy of the "language_interface:" values into the "language_url:" section. But after saving the language negotiation preferences, it returns to the defaults. As a test, I tried to manually add the language URL type in the list of configurable types as follows (language.types.yml):

...
configurable:
  - language_interface
  - language_content
  - language_url
...

That makes the language URL type negotiation configuration appear in the preferences form ( admin/config/regional/language/detection ), it works despite of a bunch of PHP notices.

Precisely to expose this configuration options in the same way that the content language detection could be a solution to this.

manuel.adan’s picture

That makes the language URL type negotiation configuration appear in the preferences form ( admin/config/regional/language/detection ), it works despite of a bunch of PHP notices.

I found that it is actually another bug: #2824086: URL language detection has missing title and description

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

david.qdoscc’s picture

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative, +Needs issue summary update

This came up as part of the daily bug smash triage.

Is this still reproducible on the latest version of Drupal core? If so, can we update the IS with the steps?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Wanted to follow up one more time if steps can be provided.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Since there's been no follow up and was followed up twice going to close out. If still an issue in D11 lets re-open

Thanks.

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.