dpi / avatars

Avatar Kit for Drupal
https://drupal.org/project/avatars
GNU General Public License v2.0
3 stars 2 forks source link

Exception thrown when viewing the user registration form with avatar generator field #27

Closed fotiDim closed 8 years ago

fotiDim commented 8 years ago

If I give any permission to an anonymous user I get

"Drupal\Core\Database\InvalidQueryException: Query condition 'avatars_preview.uid IN ()' cannot be empty. in Drupal\Core\Database\Query\Condition->condition() (line 71 of .../core/lib/Drupal/Core/Database/Query/Condition.php)."

dpi commented 8 years ago

Are you sure the error surfaces as a result of assigning the permission to the anonymous role? Or does it happen regardless of the permission?

Can I get a full stack trace of the error?

fotiDim commented 8 years ago

100% sure. It only happens on anonymous users when I give them any Avatarkit permission.

Can you suggest a way to generate the syslog?

dpi commented 8 years ago

Can you give ef02cfa a shot and see if it resolves your issue.

If you still are having issues:

  1. re-open this issue
  2. Go to the Logging and errors page and enable All messages, with backtrace information radio.
  3. When the error surfaces again, paste the full backtrace (or take a screenshot).
fotiDim commented 8 years ago

Just tried ef02cfa and it didn't solve the issue. I did what you suggested and this is the backtrace:

The website encountered an unexpected error. Please try again later.

Drupal\Core\Database\InvalidQueryException: Query condition 'avatars_preview.uid IN ()' cannot be empty. in Drupal\Core\Database\Query\Condition->condition() (line 71 of core/lib/Drupal/Core/Database/Query/Condition.php).
Drupal\Core\Database\Query\Select->condition('avatars_preview.uid', Array, 'IN') (Line: 53)
Drupal\Core\Entity\Query\Sql\Condition->compile(Object) (Line: 162)
Drupal\Core\Entity\Query\Sql\Query->compile() (Line: 81)
Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 503)
Drupal\Core\Entity\EntityStorageBase->loadByProperties(Array) (Line: 116)
Drupal\avatars\Entity\AvatarPreview::getAvatarPreview(Object, Object) (Line: 140)
Drupal\avatars\AvatarManager->refreshAvatarGenerator(Object, Object, 0) (Line: 167)
Drupal\avatars\AvatarManager->refreshAllAvatars(Object) (Line: 102)
Drupal\avatars\Plugin\Field\FieldWidget\AvatarGeneratorPreviewWidget->formElement(Object, 0, Array, Array, Object) (Line: 324)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 85)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 168)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 54)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object, Object) (Line: 270)
Drupal\user\AccountForm->form(Array, Object, Object) (Line: 45)
Drupal\user\RegisterForm->form(Array, Object) (Line: 115)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 512)
Drupal\Core\Form\FormBuilder->retrieveForm('user_register_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm('user_register_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
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}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
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: 206)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 120)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 74)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
dpi commented 8 years ago

Confirmed the exception is shown on the user registration form when:

dpi commented 8 years ago

Try this one.

Avatar preview will not work on the registration form because:

I advise that you hide the avatar generator field element from the user registration from.

fotiDim commented 8 years ago

The exception is gone now.

I would love to follow your advice but hiding the avatar generator field also hides it from logged in users. Is there a workaround for that?

dpi commented 8 years ago

Go to your user entity form display settings at /admin/config/people/accounts/form-display

You should see two tabs at the top, 'Default' and 'Register'. Just remove the form display from the 'Register' tab.

fotiDim commented 8 years ago

Super, that did the trick. I had to enable this setting to see the 'Register' tab:

screen shot 2016-07-17 at 23 01 42

@dpi from what I understand there is no point in giving any AvatarKit permission to anonymous users. Is that right?

dpi commented 8 years ago

Thats correct, anonymous users arn't yet supported #30

The user registration form exposed an issue because it is an in-between state. Wherein a user entity is ready to be created, but we cannot use it yet.