Answers.Body: <p>This issue is solved with the new Drupal 8.6.14 update.
  So it seems to have a conflict between Drupal 8.6.13 and CiviCRM 5.12.0.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-08T16:08:38.337Z
Answers.LastActivityDate: 2019-04-08T16:08:38.337Z
Answers.UserDisplayName: Ichi
Answers.Body: <p>We are using Drupal : 8.7.5</p>
  
  <p>CiviCRM : 5.13.6 ESR</p>
  
  <p>We had same issue when admin try to create new user.</p>
  
  <p>After comparing drupal 7 and drupal 8 module files, i found one the config setting is missing in drupal 8 module.</p>
  
  <p>After applying changes, user get created but logged in user get logged out.</p>
  
  <p>Then i found that in synchronize function we are resting the CiviCRM session. if we comment it, auto logout get stopped.</p>
  
  <p>Here is are the both changes.</p>
  
  <pre><code>--- a/modules/contrib/civicrm/civicrm.module
  +++ b/modules/contrib/civicrm/civicrm.module
  @@ -251,6 +251,7 @@ function _civicrm_get_profiles($contact_id) {
   function civicrm_form_user_register_form_alter(&amp;$form, &amp;$form_state, $form_id) {
     $civicrm = \Drupal::service('civicrm');
     $civicrm-&gt;initialize();
  +  CRM_Core_Config::singleton()-&gt;keyDisable = TRUE; // to skip quickform key validation
     $html = \CRM_Core_BAO_UFGroup::getEditHTML(NULL, '', NULL, TRUE, TRUE, NULL, FALSE, $civicrm-&gt;getCtype());
  
     // Need to disable the page cache.
  @@ -273,6 +274,7 @@ function civicrm_form_user_register_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    */
   function _civicrm_user_register_form_validate(&amp;$form, FormStateInterface $form_state) {
     \Drupal::service('civicrm')-&gt;initialize();
  +  CRM_Core_Config::singleton()-&gt;keyDisable = TRUE; 
     $errors = CRM_Core_BAO_UFGroup::isValid(NULL, '', TRUE);
  
     if (is_array($errors)) {
  diff --git a/vendor/civicrm/civicrm-core/CRM/Core/BAO/UFMatch.php b/vendor/civicrm/civicrm-core/CRM/Core/BAO/UFMatch.php
  index 39731cfa9..c60dbe23d 100644
  --- a/vendor/civicrm/civicrm-core/CRM/Core/BAO/UFMatch.php
  +++ b/vendor/civicrm/civicrm-core/CRM/Core/BAO/UFMatch.php
  @@ -100,7 +100,6 @@ public static function synchronize(&amp;$user, $update, $uf, $ctype, $isLogin = FALS
  
       // reset the session if we are a different user
       if ($ufID &amp;&amp; $ufID != $userSystemID) {
  -      $session-&gt;reset();
  
         //get logged in user ids, and set to session.
         if ($isUserLoggedIn) {
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-20T08:54:54.927Z
Answers.LastActivityDate: 2019-08-20T08:54:54.927Z
Answers.UserDisplayName: Sunil Pawar
Body: <p>The upgrade of CiviCRM 5.12.0 version breaks the user registration process on Drupal 8 : <code>Error type: Could not find a valid session key.</code>
  I tried the upgrade on two different D8 sites with same issue.
  Select another Civi profile doesn't change it neither. </p>
  
  <pre><code>Apr 06 22:50:18  [info] $backTrace = #0 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Error.php(381): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Controller.php(833): CRM_Core_Error::fatal("We can't load the requested web page. This page requires cookies to be enable...")
  #2 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Controller.php(828): CRM_Core_Controller-&gt;invalidKeyCommon()
  #3 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Controller.php(312): CRM_Core_Controller-&gt;invalidKey()
  #4 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Controller.php(204): CRM_Core_Controller-&gt;key("CRM_Profile_Form_Dynamic", TRUE, FALSE)
  #5 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Controller/Simple.php(66): CRM_Core_Controller-&gt;__construct("Dynamic Form Creator", TRUE, NULL, "CRM_Profile_Form_Dynamic", TRUE, FALSE)
  #6 /server_path/vendor/civicrm/civicrm-core/CRM/Core/BAO/UFGroup.php(834): CRM_Core_Controller_Simple-&gt;__construct("CRM_Profile_Form_Dynamic", "Dynamic Form Creator", NULL)
  #7 /server_path/docroot/modules/contrib/civicrm/civicrm.module(265): CRM_Core_BAO_UFGroup::getEditHTML(NULL, "", NULL, TRUE, TRUE, NULL, FALSE, "Individual")
  #8 /server_path/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(539): civicrm_form_user_register_form_alter((Array:26), Object(Drupal\Core\Form\FormState), "user_register_form")
  #9 /server_path/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(834): Drupal\Core\Extension\ModuleHandler-&gt;alter("form", (Array:26), Object(Drupal\Core\Form\FormState), "user_register_form")
  #10 /server_path/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(276): Drupal\Core\Form\FormBuilder-&gt;prepareForm("user_register_form", (Array:26), Object(Drupal\Core\Form\FormState))
  #11 /server_path/docroot/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder-&gt;buildForm("user_register_form", Object(Drupal\Core\Form\FormState))
  #12 [internal function](): Drupal\Core\Controller\FormController-&gt;getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
  #13 /server_path/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array((Array:2), (Array:2))
  #14 /server_path/docroot/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}()
  #15 /server_path/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
  #16 /server_path/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext((Array:2), (Array:2))
  #17 /server_path/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}()
  #18 /server_path/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
  #19 /server_path/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #20 /server_path/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #21 /server_path/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #22 /server_path/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #23 /server_path/docroot/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #24 /server_path/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #25 /server_path/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #26 /server_path/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #27 /server_path/docroot/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #28 /server_path/docroot/index.php(19): Drupal\Core\DrupalKernel-&gt;handle(Object(Symfony\Component\HttpFoundation\Request))
  #29 {main}
  </code></pre>
  
Tags: <drupal-8>
Title: CiviCRM 5.12.0 breaks Drupal 8 registration
ThreadText: # CiviCRM 5.12.0 breaks Drupal 8 registration
  
  (Asked by: username_0 on 2019-04-06)
  
  The upgrade of CiviCRM 5.12.0 version breaks the user registration process on Drupal 8 : `Error type: Could not find a valid session key.`
  I tried the upgrade on two different D8 sites with same issue.
  Select another Civi profile doesn't change it neither.
  
  ```
  Apr 06 22:50:18  [info] $backTrace = #0 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Error.php(381): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Controller.php(833): CRM_Core_Error::fatal("We can't load the requested web page. This page requires cookies to be enable...")
  #2 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Controller.php(828): CRM_Core_Controller->invalidKeyCommon()
  #3 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Controller.php(312): CRM_Core_Controller->invalidKey()
  #4 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Controller.php(204): CRM_Core_Controller->key("CRM_Profile_Form_Dynamic", TRUE, FALSE)
  #5 /server_path/vendor/civicrm/civicrm-core/CRM/Core/Controller/Simple.php(66): CRM_Core_Controller->__construct("Dynamic Form Creator", TRUE, NULL, "CRM_Profile_Form_Dynamic", TRUE, FALSE)
  #6 /server_path/vendor/civicrm/civicrm-core/CRM/Core/BAO/UFGroup.php(834): CRM_Core_Controller_Simple->__construct("CRM_Profile_Form_Dynamic", "Dynamic Form Creator", NULL)
  #7 /server_path/docroot/modules/contrib/civicrm/civicrm.module(265): CRM_Core_BAO_UFGroup::getEditHTML(NULL, "", NULL, TRUE, TRUE, NULL, FALSE, "Individual")
  #8 /server_path/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(539): civicrm_form_user_register_form_alter((Array:26), Object(Drupal\Core\Form\FormState), "user_register_form")
  #9 /server_path/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(834): Drupal\Core\Extension\ModuleHandler->alter("form", (Array:26), Object(Drupal\Core\Form\FormState), "user_register_form")
  #10 /server_path/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(276): Drupal\Core\Form\FormBuilder->prepareForm("user_register_form", (Array:26), Object(Drupal\Core\Form\FormState))
  #11 /server_path/docroot/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm("user_register_form", Object(Drupal\Core\Form\FormState))
  #12 [internal function](): Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
  #13 /server_path/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array((Array:2), (Array:2))
  #14 /server_path/docroot/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
  #15 /server_path/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
  #16 /server_path/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext((Array:2), (Array:2))
  #17 /server_path/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
  #18 /server_path/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
  #19 /server_path/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #20 /server_path/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #21 /server_path/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #22 /server_path/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #23 /server_path/docroot/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #24 /server_path/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #25 /server_path/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #26 /server_path/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #27 /server_path/docroot/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, TRUE)
  #28 /server_path/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
  #29 {main}
  
  ```
  
  **Tags:** drupal-8
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-04-08. Score: 2
  
  This issue is solved with the new Drupal 8.6.14 update.
  So it seems to have a conflict between Drupal 8.6.13 and CiviCRM 5.12.0.
  
  
  ---
  
  ### Answer by username_1 on 2019-08-20. Score: 0
  
  We are using Drupal : 8.7.5
  
  CiviCRM : 5.13.6 ESR
  
  We had same issue when admin try to create new user.
  
  After comparing drupal 7 and drupal 8 module files, i found one the config setting is missing in drupal 8 module.
  
  After applying changes, user get created but logged in user get logged out.
  
  Then i found that in synchronize function we are resting the CiviCRM session. if we comment it, auto logout get stopped.
  
  Here is are the both changes.
  
  ```
  --- a/modules/contrib/civicrm/civicrm.module
  +++ b/modules/contrib/civicrm/civicrm.module
  @@ -251,6 +251,7 @@ function _civicrm_get_profiles($contact_id) {
   function civicrm_form_user_register_form_alter(&$form, &$form_state, $form_id) {
     $civicrm = \Drupal::service('civicrm');
     $civicrm->initialize();
  +  CRM_Core_Config::singleton()->keyDisable = TRUE; // to skip quickform key validation
     $html = \CRM_Core_BAO_UFGroup::getEditHTML(NULL, '', NULL, TRUE, TRUE, NULL, FALSE, $civicrm->getCtype());
  
     // Need to disable the page cache.
  @@ -273,6 +274,7 @@ function civicrm_form_user_register_form_alter(&$form, &$form_state, $form_id) {
    */
   function _civicrm_user_register_form_validate(&$form, FormStateInterface $form_state) {
     \Drupal::service('civicrm')->initialize();
  +  CRM_Core_Config::singleton()->keyDisable = TRUE; 
     $errors = CRM_Core_BAO_UFGroup::isValid(NULL, '', TRUE);
  
     if (is_array($errors)) {
  diff --git a/vendor/civicrm/civicrm-core/CRM/Core/BAO/UFMatch.php b/vendor/civicrm/civicrm-core/CRM/Core/BAO/UFMatch.php
  index 39731cfa9..c60dbe23d 100644
  --- a/vendor/civicrm/civicrm-core/CRM/Core/BAO/UFMatch.php
  +++ b/vendor/civicrm/civicrm-core/CRM/Core/BAO/UFMatch.php
  @@ -100,7 +100,6 @@ public static function synchronize(&$user, $update, $uf, $ctype, $isLogin = FALS
  
       // reset the session if we are a different user
       if ($ufID && $ufID != $userSystemID) {
  -      $session->reset();
  
         //get logged in user ids, and set to session.
         if ($isUserLoggedIn) {
  
  ```
  
  
  ---
  
  