Problem/Motivation

When saving a field translation, a notice pops up, Notice</em>: Undefined index: field.storage.node.field_name in Drupal\config_translation\Form\ConfigTranslationFormBase->submitForm() (line 203 of /.../core/modules/config_translation/src/Form/ConfigTranslationFormBase.php).'

I can't find an issue related to this and I don't think it's any of the settings I've used.

Proposed resolution

Make sure the config is not set for form values that are not posted.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

borisson_ created an issue. See original summary.

Leksat’s picture

Version: 8.1.1 » 8.1.x-dev
FileSize
1.06 KB
854 bytes

The bug exists in all 8.x branches.

I added a comment to the patch.

Leksat’s picture

nevergone’s picture

#2 tested and works well: notice is not exist!

nevergone’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Looks like we're missing test coverage then.

borisson_’s picture

I added a test, the test-only patch also serves as an interdiff. I wrote this test while mid-air on my way to dev days milan, so I hope it's good enough, this isn't the easiest place to focus ;).

The last submitted patch, 7: configuration-2746253-7--test-only.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 7: configuration-2746253-7.patch, failed testing.

pguillard’s picture

In fact this patch applies to 8.2, and does not applies to 8.1.
In my opinion this ticket should target 8.2 first, and then be moved to 8.1. I am wrong ?
I guess we need @alexpott 's opinion.

borisson_’s picture

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

Retested with 8.2.x, also changed the targeted version.

The last submitted patch, 7: configuration-2746253-7--test-only.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review

Test only patch fails as expected, the patch with the code included passes for 8.2 as well. Do I need to make another patch for 8.1 or is it fine to get this in for 8.2 first?

borisson_’s picture

The last submitted patch, 14: configuration-2746253-14--d8.1.patch, failed testing.

RoloDMonkey’s picture

Priority: Normal » Major

To me, this seems to fit the definition of a Major bug.

Xano’s picture

Priority: Major » Minor
Status: Needs review » Needs work

This is a minor bug, because PHP notices do not break anything, and as far as I can see nothing's buggy apart from the notice.

I think this is almost ready to be RTBC'd. However, the newly introduced test method must also confirm the existence of the new translation.

borisson_’s picture

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

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now 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.

Arne Slabbinck’s picture

At some point in configuring my Drupal 8 site I experienced the same Notice, but the field wasn't translatable anymore to other languages.
I can confirm the patch in #18 (configuration-2746253-14--d8.1.patch) resolved this issue (using Drupal 8.1.8)

mpp’s picture

RTBC.

PS: I do consider this a major issue. Not because of the notice but because it prevented saving and thus translating a label. In my case I had a non-translatable field (value) with a label that needed translating.

mpp’s picture

Status: Needs review » Reviewed & tested by the community
cilefen’s picture

Title: Configuration translation save throws an undefined notice. » Configuration translation save triggers an undefined index notice

Exceptions are thrown.

alexpott’s picture

Priority: Minor » Normal
Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php
@@ -193,6 +193,12 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
     foreach ($this->mapper->getConfigNames() as $name) {
+
+      // Skip the config if it does not have translatable data.
+      if (!isset($form_values[$name])) {
+        continue;
+      }
+

Maybe we can do this better by doing:
foreach ($form_values as $name => $value) {
And then doing
$element->setConfig($base_config, $config_translation, $value);

It's great to see a test. I've confirmed it fails without the fix.

mogio_hh’s picture

Will this be fixed in the next Drupal version? Do I need the patch or can I wait?
Thanks

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

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.

TrevorBradley’s picture

Fix worked for me.

eiriksm’s picture

Status: Needs work » Needs review
Issue tags: +DevDaysSeville
FileSize
3.4 KB

Fixed per comments in #24

Utilvideo’s picture

Tested, worked

flocondetoile’s picture

#28 fix the issue and I can now translate fields label.

mpp’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 240524f to 8.4.x and fb8b2ce to 8.3.x. Thanks!

Thanks to everyone for all the comments confirming the fix works. I credited myself because my comment in #24 directly changed the patch.

  • alexpott committed 240524f on 8.4.x
    Issue #2746253 by borisson_, Leksat, eiriksm, alexpott: Configuration...

  • alexpott committed fb8b2ce on 8.3.x
    Issue #2746253 by borisson_, Leksat, eiriksm, alexpott: Configuration...

Status: Fixed » Closed (fixed)

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