Problem/Motivation

Entities with language set to 'Not specified' or 'Not applicable' are linked, when done through a StringFormatter, to the default language. Following such a link can change the UI language, which is not expected by the end user.

Steps to reproduce

  1. Install a clean Drupal site and make sure that "Language" module is enabled.
  2. Add a second language at /admin/config/regional/language.
  3. Configure URL negotiation at /admin/config/regional/language/detection, make sure "URL" is enabled.
  4. Configure a URL prefix for the second language at /admin/config/regional/language/detection/url
  5. Go to the "Frontpage" view and edit the filter criterion Content: Translation language (= Content language selected for page) enabling the options "Not specified" and "Not applicable". Save the view.
  6. Add a simple text field to the article content type and configure its "teaser" view mode to show it as a link it to the entity.
  7. Create a new article with the language set as "Not specified" and fill a value in the new textfield.
  8. Navigate to to the front page in the second language (for example, navigate to /es if your second language was Spanish)
  9. Check that the link in the simple field value of the new article points to the article in the default site language (English) instead of the current language (your second language).

Proposed solution/idea

Links to entities with language 'Not specified' or 'Not applicable' should default to the current UI language.

Remaining tasks

  • Fix. Done
  • Tests. Done

User interface changes

Now the links pointing to entities with language "Not specified" or "Not applicable", and printed through a StringFormatter, point to the entity in the current UI language instead of the default site language.

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

None

Original report by @aleksip

Entities with language set to 'Not specified' or 'Not applicable' are linked to the default language. Following such a link can change the UI language, which is not expected by the end user.

Issue fork drupal-2991440

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

aleksip created an issue. See original summary.

aleksip’s picture

StatusFileSize
new3.14 KB

Here is a patch with a proposed fix.

aleksip’s picture

StatusFileSize
new1.14 KB

Ouch. Well, let's just use \Drupal::languageManager() and make all the required changes if this is considered a good idea in the first place.

aleksip’s picture

Status: Active » Needs work

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

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.

markdatter’s picture

Any chance that this will be fixed and implemented in Drupal 8.8?

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

marksmith’s picture

This is still an issue in Drupal 9.

anushrikumari’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB

Rerolled #3

vdsh’s picture

rerolled for Drupal v9.x

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.

ranjith_kumar_k_u’s picture

StatusFileSize
new1.13 KB

Rerolled #11 for 9.5

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

As a bug this will need a test case

Did not review or test.

Version: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kimlop’s picture

Patch #15 fails when applied to core 10.4.0

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

oily’s picture

I came across this closed issue which looks similar. We need to reproduce on Drupal 11.x to see if it has already been fixed.

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

vidorado’s picture

Title: Links to entities with language set to 'Not specified' or 'Not applicable' should default to current UI language » StringFormatter links to entities with language set to 'Not specified' or 'Not applicable' should default to current UI language
Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests

Fixed a couple of things and added a unit test covering the case :)

oily’s picture

Removed 'Needs tests' tag as a unit test is in place.

The 'test-only' job fails as it should. A failing test is in place. Pipeline all green.

vidorado changed the visibility of the branch 11.x to hidden.

smustgrave’s picture

Status: Needs review » Needs work

Feedback in MR seems legit.

Wonder if we have to worry about backwards compatibility and add a trigger_error

vidorado’s picture

@smustgrave, could you explain better what do you mean by backwards compatibility and in which case should we trigger an error?

vidorado’s picture

Status: Needs work » Needs review

Trying to get feedback

oily’s picture

RE: #28 @vidorado Your changes to the code comments definitely makes their meaning clearer. RE: #27, the question could be raised in the Slack #core-development channel.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Feedback for this one appears to be addressed.

oily’s picture

The comments seem clearer now in line with recommendations.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new1.84 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

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.