Problem/Motivation

LanguageFormatter doesn't get all languages and doesn't check if a language is available before trying to display it.

Steps to reproduce:

1. Enable translation module
2. Go to admin/config/regional/content-language, make sure that Content is enabled and "Show language selector on create and edit pages" is checked for Article.
3. admin/structure/types/manage/article/display, make sure that language is shown
4. Create a node of that type, select language not specified or not applicable.
5. Enjoy the fatal error that you get when trying to view that node.

Proposed resolution

Check it.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
1.6 KB

Status: Needs review » Needs work

The last submitted patch, 1: language-formatter-fatal-2461013-1.patch, failed testing.

Gábor Hojtsy’s picture

Issue tags: +D8MI, +language-base

This should be able to display the locked language names too, so it should indeed get all languages. Also the classic question of whether this should display at least the language code for languages which are now deleted then comes up :)

Gábor Hojtsy’s picture

Issue tags: +medium
keopx’s picture

Assigned: Unassigned » keopx
keopx’s picture

keopx’s picture

Status: Needs work » Needs review
keopx’s picture

Assigned: keopx » Unassigned

@Berdir I see the issue needs tests, but I need more information to do this and test type.

keopx’s picture

Assigned: Unassigned » keopx
keopx’s picture

Assigned: keopx » Unassigned
Status: Needs review » Needs work
FileSize
3 KB
1.11 KB

The patch works fine, but in this patch I added some test changed, it does not work and needs more work.

Thanks @Berdir for your time.

Anonymous’s picture

Status: Needs work » Needs review

Do you mean the code change works, but the new test coverage change doesn't work as expected?

Triggering testbot.

Status: Needs review » Needs work

The last submitted patch, 10: language-formatter-fatal-2461013-10.patch, failed testing.

Berdir’s picture

Yes, exactly. Turns out we didn't create the node yet, also we need to exclude that one in a few places.

I still think that the default frontpage should allow content of the current language OR not specified, otherwise that content is never shown to anyone. So I added a @todo there, I think we have an issue somewhere.

The last submitted patch, 13: language-formatter-fatal-2461013-13-test-only.patch, failed testing.

scottalan’s picture

Issue tags: -Needs tests

Removing "Needs Test" tag. Already has a test.

keopx’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, test works.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/node/src/Tests/Views/NodeLanguageTest.php
    @@ -146,6 +157,10 @@ public function testLanguages() {
    +      // @todo Should the frontpage always display untranslatable content?
    +      if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) {
    +        continue;
    

    Let's find that issue somewhere, or failing that, file it. :)

  2. +++ b/core/modules/node/src/Tests/Views/NodeLanguageTest.php
    @@ -90,6 +94,13 @@ protected function setUp() {
    +    // Create non-translatable nodes.
    +    foreach ($this->nodeTitles[LanguageInterface::LANGCODE_NOT_SPECIFIED] as $index => $title) {
    +      $node = $this->drupalCreateNode(array('title' => $title, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'type' => 'page', 'promote' => 1));
    +      $node->body->value = $this->randomMachineName(32);
    +      $node->save();
    +    }
    

    Is the bug Views-specific? I didn't get that from the summary. If not it's strange to add the only test coverage there.

Also steps to reproduce/test would be helpful for reviewing. :)

Berdir’s picture

1. I knew it would be a bad idea to sneak that in :p... I'll create an issue, talked about it with @Gabor before...
2. No, it's not specific to views, but I'm not aware of anything that uses a formatter for displaying a language other than views. Field formatters are the new views field plugins ;)

Gábor Hojtsy’s picture

@Berdir: well, entities have language hidden in their display formats, that can be turned on too?

thenchev’s picture

Status: Needs work » Needs review
Berdir’s picture

Issue summary: View changes

1. Yes, just removing the todo and documenting it as it being so is fine, it's not related to this issue.

Steps to reproduce added to the issue summary. We could also write a test that does that instead and not do it using views, but on the other site, that's what the issue that added the language formatter did as well: #2384863: Translation language base field handler should use views field handler, provide unified options.

Gabor, thoughts?

Berdir’s picture

This is also blocking redirect.module, we want to convert the admin overview to a view and it fatals with that because non-language specific redirects are common and the default for redirect: https://github.com/md-systems/redirect/pull/28

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +sprint

Yeah #2384863: Translation language base field handler should use views field handler, provide unified options added views coverage because it was about reproducing prior views functionality. Now with the cleaned up test comments, let's see if committers are fine just basing off of that test. It certainly tests the same thing either way.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

@Gábor Hojtsy yep I'm happy.

This issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 67692cb and pushed to 8.0.x. Thanks!

  • alexpott committed 67692cb on 8.0.x
    Issue #2461013 by Berdir, keopx, Denchev, Gábor Hojtsy, xjm: Trying to...
Gábor Hojtsy’s picture

Issue tags: -sprint

Amazing, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.