Problem/Motivation

Step to reproduce:
1- Install a drupal 8 in Spanish.
2- In "admin/config/regional/language/add" add Inglés language.
3- Go to "/en/admin/modules" install "Configuration Translation" and "Content Translation" modules.
4- Go to "/en/admin/structure/types/manage/page/fields", click in "Add field", in "Re-use an existing field', select "Image: Field image", "Save and continue".
5- Bump!

RuntimeException: A config mapper can only contain configuration for a single language. in Drupal\config_translation\ConfigNamesMapper->getLangcode() (line 398 of core/modules/config_translation/src/ConfigNamesMapper.php).

Drupal\config_translation\Access\ConfigTranslationOverviewAccess->access(Object, Object)
call_user_func_array(Array, Array)
Drupal\Core\Access\AccessManager->performCheck('config_translation.access.overview', Object)
Drupal\Core\Access\AccessManager->check(Object, Object, NULL, 1)
Drupal\Core\Access\AccessManager->checkNamedRoute('entity.field_config.config_translation_overview.node', Array, Object, 1)
Drupal\Core\Menu\LocalTaskManager->getTasksBuild('entity.field_config.node_field_edit_form', Object)
Drupal\Core\Menu\LocalTaskManager->getLocalTasks('entity.field_config.node_field_edit_form', 0)
Drupal\Core\Menu\Plugin\Block\LocalTasksBlock->build()
Drupal\block\BlockViewBuilder::preRender(Array)
call_user_func('Drupal\block\BlockViewBuilder::preRender', Array)
Drupal\Core\Render\Renderer->doRender(Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1)
__TwigTemplate_0f04497e0607dbb55ae785558deed68eacde76e3989f8c8e0779ccf1b6af549c->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
twig_render_template('core/themes/seven/templates/page.html.twig', Array)
Drupal\Core\Theme\ThemeManager->render('page', Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1)
__TwigTemplate_16436f2456eb6e9f1287d658a3b71677eb9755e9eb4796bd9e27a1209ebeaf7f->doDisplay(Array, Array)
Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
twig_render_template('core/themes/classy/templates/layout/html.html.twig', Array)
Drupal\Core\Theme\ThemeManager->render('html', Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)

Fields have two config objects,
the "Edit" tab is field.field... and
the "Field settings" the field.storage...

When installing in spanish, using standard profile, the field and storage config have langcode es.
After adding english, and enabling configuration translation module, and specifying en in the admin url, the field config (not storage) has the langcode en.
The translate tab, then errors because it expects all the config on the form to have the same source.

This is only a problem when config translation is enabled. (The field stuff is fine.)

Proposed resolution

Possible solution,
instead of a fatal error, give a warning. Wording the warning might be tricky. Maybe "Warning, the field configuration and field settings configuration have different source languages, and will not be able to be translated."

Remaining tasks

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Create a patch Instructions
Add automated tests Instructions
Embed before and after screenshots in the issue summary Novice Instructions
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards Instructions

User interface changes

Adding a warning.

API changes

??

Data model changes

No.

Comments

rpayanm created an issue. See original summary.

YesCT’s picture

Issue summary: View changes
Issue tags: +Needs tests

I'm not sure this is Critical.
I looked at https://www.drupal.org/core/issue-priority
It might qualify under
"Render the system unusable and have no workaround."
unless the "workaround" is: add existing fields in the same language that was used when the field was created.

We can discuss what the wording of the warning should be.
"Warning, the field configuration and field settings configuration have different source languages, and will not be able to be translated."

Discussed the cause of the problem with @Gábor Hojtsy and @tstoeckler and updated the issue summary

YesCT’s picture

Didier Misson’s picture

Same problem when "add field" in D 8.1.0 with English and French language...

[Fri Apr 22 09:53:01.982068 2016] [fcgid:warn] [pid 25084] [client 87.66.35.0:50313] mod_fcgid: stderr: Uncaught PHP Exception RuntimeException: "A config mapper can only contain configuration for a single language." at /home/mysite/public_html/core/modules/config_translation/src/ConfigNamesMapper.php line 393, referer: http://mysite.misson.ovh/fr/admin/structure/types/manage/test/fields/add-field