Problem/Motivation

Notice appears in logs:

Notice: Undefined index: und in content_translation_language_configuration_element_validate() (line 617 of /var/lib/tugboat/stm/web/core/modules/content_translation/content_translation.module)

Steps to reproduce

  1. Install Drupal
  2. Enable Language and Content translation modules
  3. Go to /admin/structure/types/manage/page
  4. In the 'Language settings' tab:
    1. For 'Default language', select -Not specified- or -Not applicable-
    2. Check 'Enable translation'
  5. Save
  6. Get an error: "Show language selector" is not compatible with translating content that has default language: . Either do not hide the language selector or pick a specific language.

Proposed resolution

Fix the Undefined array key error so there is no notice in the logs.

Remaining tasks

Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Pasqualle created an issue. See original summary.

Version: 8.6.0-rc1 » 8.6.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.6.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. Branches prior to 8.8.x are not supported, and 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.

pameeela’s picture

Title: PHP notice: undefined index » Notice in logs when setting invalid translation config for a content type
Issue summary: View changes
Priority: Normal » Minor
Issue tags: +Bug Smash Initiative

Update title with more info and IS with steps to reproduce

codersukanta’s picture

I think this is by design and if we allow undefined content to be translated then I see multiple issues to get out of it. If we select -Not specified- or -Not applicable- then as per the current design the validation error message should display as we cant translate content from undefined language.

Pasqualle’s picture

I am not saying Drupal should support this combination, I just wanted to report that the message is wrong and the PHP notice should be fixed.

highlighting problem in the message (with ???), in case it is not clear from the issue description:

... that has default language: ???. Either do ...

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
Lendude’s picture

Priority: Minor » Normal
Status: Active » Needs review
FileSize
1.43 KB
2.39 KB

Easily reproduced, easily fixed. Here is a test and fix for this.

Lendude’s picture

Ignore that fix, this is it.

The last submitted patch, 9: 2994000-9-TEST_ONLY.patch, failed testing. View results

quietone’s picture

Version: 9.3.x-dev » 10.0.x-dev
Issue summary: View changes

I applied the patch to D10 and took it for a spin. It works just fine, there are no errors in the log.

quietone’s picture

Status: Needs review » Needs work

Too a closer look at the patch and just a suggested wording change in the comment.

+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php
@@ -205,6 +205,17 @@ public function testSettingsUI() {
+    // Test that we can't use the 'Not specified' default language when not
+    // showing the language selector.

I think this reads better, "Test that we can't use the 'Not specified' default language when it is not showing in the language selector.'

Lendude’s picture

Status: Needs work » Needs review
FileSize
931 bytes
2.4 KB

Updated the comment.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Nice work folks!

  • catch committed 16ea850 on 10.0.x
    Issue #2994000 by Lendude, Pasqualle, quietone, pameeela: Notice in logs...
  • catch committed da9a2b4 on 10.1.x
    Issue #2994000 by Lendude, Pasqualle, quietone, pameeela: Notice in logs...
  • catch committed 88f1522 on 9.4.x
    Issue #2994000 by Lendude, Pasqualle, quietone, pameeela: Notice in logs...
  • catch committed a63c760 on 9.5.x
    Issue #2994000 by Lendude, Pasqualle, quietone, pameeela: Notice in logs...
catch’s picture

Version: 10.0.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.1.x and cherry-picked back through to 9.4.x, thanks!

xjm’s picture

I think this may have broken D9 HEAD.

xjm’s picture

...Attached the patch to the wrong issue, sorry... It's a revert of https://www.drupal.org/project/drupal/issues/3082211. Still need to see the results, though, so letting it run.

xjm’s picture

Let's run a revert of this issue itself at the same time just to be sure; I never know what it means when an integer in a D7 migration test changes.

xjm’s picture

It was indeed the other issue; sorry for noise!

Status: Fixed » Closed (fixed)

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