Problem/Motivation
In issue
#540294: Move node language settings from Locale to Node module β
, the language settings were moved from locale.module to node.module. An apparently accidental change occurred at the same time, where new nodes that are created on a single-language site are now always the site default language, instead of LANGUAGE_NONE.
This causes some new issues when dealing with URL aliases on a single-language site. URL aliases that are created manually do not have the option to set a language, so therefor langcode is always "und" in the url_alias table for manual aliases. However, all nodes that are created are the default language, and so you end up in a situation where one alias is used for the actual path, and another alias is shown on the node form. Changing the alias in the node form no longer affects the actual URL at all any more, because the manual alias (created after the node) always wins.
Steps to reproduce:
- Install Drupal 8 in English
- Create a new node. Give it the alias "about" on the node form.
- Visit admin/config/search/path and add a new URL alias with the system path "node/1", and the alias "about2".
- Visit the node. Note that the URL alias is now "about2".
- Edit the node. The URL alias on the node form is still "about", not "about2". Any changes you make to the alias at this point will have no effect at all, the alias will always be "about2".
The reason for this behavior is because the url_alias table will contain two aliases pointing at the same node. One is for "und", and the other is for "en". The latest alias in the table (regardless of langcode) will be the alias used in the URL. While the langcode that matches the node will be used in the node form.
All of this is due to a shift in the way nodes are created by default on a single language site:
- Drupal 7: All nodes are LANGUAGE_NONE in a single-language site.
- Drupal 8: All nodes are the default language in a single-language site.
It seems that the change in Drupal 8 did not intend to introduce an inconsistency between the node form and standalone URL alias form.
Even on a multilingual site, the standalone URL alias form defaults to 'not specified':
Proposed resolution
Make it so that all aliases created on a single-language site use the default language instead of LanguageInterface::LANGCODE_NOT_SPECIFIED. Multilingual sites could respect the content language settings that can be configured at /admin/config/regional/content-language - this would include defaulting to the site default language.
Remaining tasks
Implement.
User interface changes
None.
API changes
None
Original report by quicksketch
In issue
#540294: Move node language settings from Locale to Node module β
, the language settings were moved from locale.module to node.module. An apparently accidental change occurred at the same time, where new nodes that are created on a single-language site are now always the site default language, instead of LANGUAGE_NONE.
This causes some new issues when dealing with URL aliases on a single-language site. URL aliases that are created manually do not have the option to set a language, so therefor langcode is always "und" in the url_alias table for manual aliases. However, all nodes that are created are the default language, and so you end up in a situation where one alias is used for the actual path, and another alias is shown on the node form. Changing the alias in the node form no longer affects the actual URL at all any more, because the manual alias (created after the node) always wins.
Steps to reproduce:
- Install Drupal 8 in English
- Create a new node. Give it the alias "about" on the node form.
- Visit admin/config/search/path and add a new URL alias with the system path "node/1", and the alias "about2".
- Visit the node. Note that the URL alias is now "about2".
- Edit the node. The URL alias on the node form is still "about", not "about2". Any changes you make to the alias at this point will have no effect at all, the alias will always be "about2".
The reason for this behavior is because the url_alias table will contain two aliases pointing at the same node. One is for "und", and the other is for "en". The latest alias in the table (regardless of langcode) will be the alias used in the URL. While the langcode that matches the node will be used in the node form.
All of this is due to a shift in the way nodes are created by default on a single language site:
- Drupal 7: All nodes are LANGUAGE_NONE in a single-language site.
- Drupal 8: All nodes are the default language in a single-language site.
I'm not sure which assumption is valid, but it seems that the change in Drupal 8 was unintentional.