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

CommentFileSizeAuthor
#2 user_creation_error_3037134_2_D8.patch836 bytessorabh.v6

Comments

sorabh.v6 created an issue. See original summary.

sorabh.v6’s picture

StatusFileSize
new836 bytes

Patch for the error.

agentrickard’s picture

Status: Active » Needs review

Thanks. 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.

sorabh.v6’s picture

Yeah, I usually set the status as Needs Review. But I was in hurry yesterday therefore forgot to update the status :)

  • agentrickard authored 85c9dc5 on 8.x-1.x
    Merge pull request #472 from agentrickard/submit-values
    
    Issue #3037134...
  • agentrickard committed e61acd0 on 8.x-1.x authored by sorabh.v6
    Issue #3037134 by sorabh.v6: Error on user creation page
    
agentrickard’s picture

Status: Needs review » Fixed

Committed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.