- Issue created by @brooke_heaton
- ๐ฎ๐ณIndia rakesh.regar Rajasthan, India
rakesh.regar โ made their first commit to this issueโs fork.
- ๐ฎ๐ณIndia Raveen Kumar
Yes, in recent drupal versions, Entity queries must explicitly set whether the query should be access checked or not.
Here is an example of an entity query with access checking disabled.
$query = \Drupal::entityQuery('node')
->condition('status', 1)
->accessCheck(FALSE) // Disable access checking
->execute(); - Status changed to Needs review
9 months ago 8:07am 21 March 2024 - Status changed to Closed: cannot reproduce
9 months ago 1:18pm 21 March 2024 - ๐บ๐ธUnited States AaronBauman Philadelphia
The access check is performed upon the query itself in
\Drupal\salesforce_mapping\SalesforceMappingStorage::loadByProperties
/** * {@inheritdoc} */ public function loadByProperties(array $values = []) { // Build a query to fetch the entity IDs. $entity_query = $this->getQuery()->accessCheck(FALSE); $this->buildPropertyQuery($entity_query, $values); // Sort by the mapping weight to ensure entities/objects are processed in // the correct order. $entity_query->sort('weight'); $result = $entity_query->execute(); return $result ? $this->loadMultiple($result) : []; }
SalesforceMappingStorage is just a wrapper.
If you're still having this issue, can you please share a full stack trace?
- ๐บ๐ธUnited States brooke_heaton
Here is a full stack trace of my error, if this can help elucidate the problem. Sorry for any confusion:
Backtrace #0 /code/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(80): Drupal\Core\Entity\Query\Sql\Query->prepare() #1 /code/web/modules/contrib/salesforce/modules/salesforce_mapping/src/Plugin/Validation/Constraint/UniqueFieldsConstraintValidator.php(37): Drupal\Core\Entity\Query\Sql\Query->execute() #2 /code/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(202): Drupal\salesforce_mapping\Plugin\Validation\Constraint\UniqueFieldsConstraintValidator->validate(Object(Drupal\salesforce_mapping\Entity\MappedObject), Object(Drupal\salesforce_mapping\Plugin\Validation\Constraint\MappingSfidConstraint)) #3 /code/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(154): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints(Object(Drupal\salesforce_mapping\Entity\MappedObject), '000000000000212...', Array) #4 /code/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(106): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter), Array, true) #5 /code/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php(93): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate(Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter), NULL, NULL) #6 /code/web/core/lib/Drupal/Core/TypedData/TypedData.php(132): Drupal\Core\TypedData\Validation\RecursiveValidator->validate(Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter)) #7 /code/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(518): Drupal\Core\TypedData\TypedData->validate() #8 /code/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(188): Drupal\Core\Entity\ContentEntityBase->validate() #9 [internal function]: Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object(Drupal\Core\Form\FormState)) #10 /code/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array(Array, Array) #11 /code/web/core/lib/Drupal/Core/Form/FormValidator.php(275): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState)) #12 /code/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'salesforce_mapp...') #13 /code/web/core/lib/Drupal/Core/Form/FormBuilder.php(593): Drupal\Core\Form\FormValidator->validateForm('salesforce_mapp...', Array, Object(Drupal\Core\Form\FormState)) #14 /code/web/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm('salesforce_mapp...', Array, Object(Drupal\Core\Form\FormState)) #15 /code/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\salesforce_mapping_ui\Form\MappedObjectForm), Object(Drupal\Core\Form\FormState)) #16 /code/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #17 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #18 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #19 /code/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #20 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #21 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #22 /code/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #23 /code/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #24 /code/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /code/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /code/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 /code/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #30 /code/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #31 /code/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #32 /code/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #33 /code/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #34 /code/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #35 {main}
- ๐บ๐ธUnited States AaronBauman Philadelphia
Best I can tell, looks like you're on an old version.
The line numbers don't match up with 5.0.4 or 5.0.x, and this was fixed in 5.0.3The issue with UniqueFieldsConstraintValidator was addressed here:
๐ Entity queries must explicitly set whether the query should be access checked or not Fixed
and here: https://git.drupalcode.org/project/salesforce/-/commit/48bcdc174373ec082... - ๐บ๐ธUnited States brooke_heaton
Oh interesting. Thanks for pointing that out. I'll look into it. Thanks Aaron!