Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Undefined array key 0 in Hussainweb\DrupalApi\Entity\Collection\EntityCollection->current() #304

Open
gauravmahlawat opened this issue Nov 20, 2023 · 3 comments

Comments

@gauravmahlawat
Copy link

gauravmahlawat commented Nov 20, 2023

Error message
Warning: Undefined array key 0 in Hussainweb\DrupalApi\Entity\Collection\EntityCollection->current() (line 92 of /var/www/html/vendor/hussainweb/drupal-api-client/src/Entity/Collection/EntityCollection.php).
Hussainweb\DrupalApi\Entity\Collection\EntityCollection->current() (Line: 64)
Drupal\do_username\DOUserInfoRetriever->getUserInformation('bisma-qadri') (Line: 78)
Drupal\do_username\DOUserInfoRetriever->isValidUser('bisma-qadri') (Line: 52)
Drupal\do_username\Plugin\Validation\Constraint\UsernameValidConstraintValidator->validate(Object, Object) (Line: 202)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints(Object, '00000000000006ce0000000000000000', Array) (Line: 154)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object) (Line: 164)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object) (Line: 164)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object, Array, 1) (Line: 106)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate(Object, NULL, NULL) (Line: 93)
Drupal\Core\TypedData\Validation\RecursiveValidator->validate(Object) (Line: 132)
Drupal\Core\TypedData\TypedData->validate() (Line: 485)
Drupal\Core\Entity\ContentEntityBase->validate() (Line: 188)
Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'user_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('user_form', Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('user_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

@gauravmahlawat
Copy link
Author

PR: hussainweb/drupal-api-client#5

@hussainweb
Copy link
Member

@gauravmahlawat, the problem is here: https://git.drupalcode.org/project/do_username/-/blob/2.x/src/DOUserInfoRetriever.php?ref_type=heads#L64. We are calling ->current() directly without any validation.

I think we should use current() instead but that function seems to have been deprecated for objects. We should explore a better way to call ->current() here or wrap it in a call to ->valid().

@gauravmahlawat
Copy link
Author

Thank you @hussainweb, I will check and work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants