Problem/Motivation
Unable to create New Content Types on a fresh drupal site which is installed using a Minimal Installation Profile.
Fatal error: Call to a member function setDefaultLangcode() on a non-object in /home/s239c0a1a65252cc/www/core/modules/language/language.module on line 218
Screenshot :
Screen capture that reproduces this error : http://youtu.be/ESTa2xbo-VI
Proposed resolution
Remaining tasks
- Identify the which causes the bug
- Create a Patch
- Commit it
the
User interface changes
None
API changes
Language Module
Comment | File | Size | Author |
---|---|---|---|
#5 | add-new-content-type-bundle-name-to-form-state-2417893-5.patch | 628 bytes | lahoosascoots |
call-to-member-non-object.png | 17.13 KB | gobinathm |
Comments
Comment #1
lahoosascoots CreditAttribution: lahoosascoots commentedStack Trace:
Fatal error: Call to a member function setDefaultLangcode() on a non-object in /Users/matthew.lucasiewicz/src/beta_test/core/modules/language/language.module on line 218 Call Stack: 0.0002 252392 1. {main}() /Users/matthew.lucasiewicz/src/beta_test/index.php:0 0.0111 1675248 2. Drupal\Core\DrupalKernel->handle() /Users/matthew.lucasiewicz/src/beta_test/index.php:24 0.0344 4158144 3. Stack\StackedHttpKernel->handle() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/DrupalKernel.php:565 0.0344 4158192 4. Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() /Users/matthew.lucasiewicz/src/beta_test/core/vendor/stack/builder/src/Stack/StackedHttpKernel.php:23 0.0344 4158400 5. Drupal\Core\StackMiddleware\PageCache->handle() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:58 0.0484 5359912 6. Drupal\Core\StackMiddleware\PageCache->pass() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/StackMiddleware/PageCache.php:105 0.0484 5359960 7. Drupal\Core\StackMiddleware\KernelPreHandle->handle() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/StackMiddleware/PageCache.php:126 0.0693 8338232 8. Symfony\Component\HttpKernel\HttpKernel->handle() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:53 0.0693 8338312 9. Symfony\Component\HttpKernel\HttpKernel->handleRaw() /Users/matthew.lucasiewicz/src/beta_test/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php:66 0.1456 14487696 10. call_user_func_array() /Users/matthew.lucasiewicz/src/beta_test/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php:145 0.1456 14488120 11. Drupal\Core\Controller\FormController->getContentResult() /Users/matthew.lucasiewicz/src/beta_test/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php:145 0.1579 16344368 12. Drupal\Core\Form\FormBuilder->buildForm() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/Controller/FormController.php:79 0.2264 22101360 13. Drupal\Core\Form\FormBuilder->processForm() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/Form/FormBuilder.php:247 0.2438 22876184 14. Drupal\Core\Form\FormSubmitter->doSubmitForm() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/Form/FormBuilder.php:481 0.2438 22876392 15. Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/Form/FormSubmitter.php:56 0.4404 27478680 16. call_user_func_array() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/Form/FormSubmitter.php:116 0.4404 27478760 17. language_configuration_element_submit() /Users/matthew.lucasiewicz/src/beta_test/core/lib/Drupal/Core/Form/FormSubmitter.php:116
Comment #2
lahoosascoots CreditAttribution: lahoosascoots commentedSo the Fatal is being thrown in language.module inside language_configuration_element_submit()
$values['bundle'] is coming back NULL. loadByEntityTypeBundle returns NULL if $entity_type_id or $bundle is NULL thus making $config NULL which causes the fatal when we try to setDefaultLangcode().
I tried to tap into the same process on a standard install instead of minimal and language_configuration_element_submit doesn't seem to be called calling field_ui_form_node_type_form_submit instead, which is confirmed by tapping into the submit handlers of the form.
Comment #3
lahoosascoots CreditAttribution: lahoosascoots commentedDisabling Field UI removes the field_ui_form_node_type_form_submit handler and adds in the language_configuration_element_submit.
Comment #4
lahoosascoots CreditAttribution: lahoosascoots commentedDisabling Field UI also introduces the error.
Comment #5
lahoosascoots CreditAttribution: lahoosascoots commentedSo it looks like the save handler in core/modules/node/src/NodeTypeForm.php doesn't go back and update the bundle name in the language configuration in form_state after the content type is created caused the language module to get a null value for the bundle.
This patch fixes the issue. Whether it is correctly done or not and in the the right place? I'll need some extra eyes.
Comment #6
lahoosascoots CreditAttribution: lahoosascoots commentedComment #7
dawehnerIt would be nice to have tests for this bug!
Comment #8
rpayanmComment #9
rpayanmSee this #2408439: Language / Translation settings are not saved when adding a new bundle..