When I enable translation for a content type. And then create a node of that type and then when I edit that node, I see the following notice on my site.

Notice: Undefined variable: source_langcode in Drupal\content_translation\ContentTranslationHandler->entityFormAlter() (line 415 of core/modules/content_translation/src/ContentTranslationHandler.php).

Drupal\content_translation\ContentTranslationHandler->entityFormAlter(Array, Object, Object) (Line: 18)
Drupal\node\NodeTranslationHandler->entityFormAlter(Array, Object, Object) (Line: 400)
content_translation_form_alter(Array, Object, 'node_living_unit_edit_form') (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'node_living_unit_edit_form') (Line: 836)
Drupal\Core\Form\FormBuilder->prepareForm('node_living_unit_edit_form', Array, Object) (Line: 418)
Drupal\Core\Form\FormBuilder->rebuildForm('node_living_unit_edit_form', Object, Array) (Line: 627)
Drupal\Core\Form\FormBuilder->processForm('node_living_unit_edit_form', Array, Object) (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 694)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I updated the Drupal core using composer from 8.8.0 with the following steps

composer update drupal/core:^8.8.1 --with-dependencies

CommentFileSizeAuthor
#5 Screenshot from 2020-01-21 11-24-08.png34.08 KBhmdnawaz

Comments

hmdnawaz created an issue. See original summary.

knyshuk.vova’s picture

Issue tags: +LutskGCW20

Tagging for Drupal Global Contribution Weekend

hmdnawaz’s picture

Is there any solution for this issue?

knyshuk.vova’s picture

hmdnawaz,
we have a plan to work with it on 25th of January.
Could you please add more steps with more details about how to reproduce the issue, if you have the same issue on your side? It will be helpful for further developers to reproduce and fix it.

hmdnawaz’s picture

StatusFileSize
new34.08 KB

Steps to reproduce

Created a content type. Enabled the translation for that content type
enabled translation

Created a node of that content type.
Went to node/[nid]/edit
Clicked on the translation tab.
Then clicked Add for another language and the following error displays
Notice: Undefined variable: source_langcode in /var/www/web/core/modules/content_translation/src/ContentTranslationHandler.php on line 437
Added the translation and saved the node.

Then I open the node to edit in default language /en/node/[nid]/edit. On the form I can see that error again.
Notice: Undefined variable: source_langcode in /var/www/web/core/modules/content_translation/src/ContentTranslationHandler.php on line 437

In my case this condition does not becomes true.

if ($has_translations && $new_translation) {

on line 346 on ContentTranslationHandler.php
and the source_langcode variable is defined inside that condition that is why I am getting the error.

yugro’s picture

Assigned: Unassigned » yugro
yugro’s picture

I have installed drupal 8.8.1 and enabled translation for basic page. There is no warning while editing newly created node.
Can you please give more details to reproduce that notice?

yugro’s picture

Assigned: yugro » Unassigned
hmdnawaz’s picture

Then Why I am getting this error? Is there any config which is missed on site and I have to re-import that config? Can someone help me on that?

monymirza’s picture

Version: 8.8.1 » 8.8.4
Status: Active » Closed (works as designed)