Problem/Motivation
I have a user with permission to one domain. This user creates another user. New user gets saved but it throws a warning shown below -
Warning: Invalid argument supplied for foreach() in Drupal\domain\DomainElementManager::submitEntityForm() (line 112 of modules/contrib/domain/domain/src/DomainElementManager.php).
Drupal\domain\DomainElementManager::submitEntityForm(Array, Object)
call_user_func_array('\Drupal\domain\DomainElementManager::submitEntityForm', Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 589)
Drupal\Core\Form\FormBuilder->processForm('user_form', Array, Object) (Line: 318)
Drupal\Core\Form\FormBuilder->buildForm('user_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
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: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->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: 669)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
I believe this error is being shown for this user because it has access to one domain only. I tried checking the checkbox for that domain but got the same error.
Proposed resolution
I propose to check the $values variable if its an array before doing a foreach on it. I have tried that and it worked, therefore, attaching the patch here.
Remaining tasks
NA
User interface changes
NA
API changes
NA
Data model changes
NA
Release notes snippet
NA
Comments
Comment #2
sorabh.v6Patch for the error.
Comment #3
agentrickardThanks. This is a great report. I'll take a look.
When you upload a patch, you can always set the issue status to Needs Review.
Comment #4
sorabh.v6Yeah, I usually set the status as Needs Review. But I was in hurry yesterday therefore forgot to update the status :)
Comment #6
agentrickardCommitted!