- Issue created by @mike vogel
As shown below, I added accessCheck(FALSE) line to the loadByUser function that threw the exception, uninstalled and reinstalled the modules and the problem didn't happen. I then turned on organizations and connections and got the fatal exception shown after the code.
public static function loadByUser($account, $status = TRUE) {
$contact = &drupal_static(__FUNCTION__ . $account->id(), FALSE);// If we don't have a cached Contact and we have a uid to load the Contact
// by, proceed.
if (!$contact && !empty($account->id())) {// Find Contacts linked to the current Drupal User.
$query = \Drupal::entityQuery('redhen_contact');
$query->accessCheck(FALSE);
$query->condition('uid', $account->id(), '=');
$query->condition('status', $status);
$results = $query->execute();Fatal error: Declaration of Drupal\redhen_connection\Routing\RouteSubscriber::getSubscribedEvents() must be compatible with Drupal\Core\Routing\RouteSubscriberBase::getSubscribedEvents(): array in /var/www/html/web/modules/contrib/redhen/modules/redhen_connection/src/Routing/RouteSubscriber.php on line 66
- Assigned to sarwan_verma
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 8:05am 26 September 2023 - 🇮🇳India sarwan_verma
Hi mike vogel@,
I have solve this issue and also created MR for this Drupal\Core\Entity\Query\QueryInterface::accessCheck() . Kindly review the changes .Thank you.
I reviewed and the MR looks correct and those changes fix the errors on my site. I
- Status changed to Needs work
about 1 year ago 1:30am 27 September 2023 As I've continued to use the site there are additional places where ->accessCheck(FALSE); is missing and I believe needs to be added. I only hit the bug in one of these places but I believe its needed in them all.
- validate function in: redhen/modules/redhen_dedupe/src/Form/RedhenDedupeMergeForm.php
- redhenDedupeMerge function in: redhen/modules/redhen_dedupe/src/Form/RedhenDedupeMergeForm.php
- buildConfigurationForm function in: redhen/modules/redhen_connection/src/Plugin/Action/ChangeConnectionRole.php
- loadByMail function in: web/modules/contrib/redhen/modules/redhen_contact/src/Entity/Contact.phpAfter fixing those I encountered this error after creating an organization:
The website encountered an unexpected error. Please try again later.
TypeError: htmlspecialchars(): Argument #1 ($string) must be of type string, Drupal\Core\Link given in htmlspecialchars() (line 436 of core/lib/Drupal/Component/Utility/Html.php).
Drupal\Component\Utility\Html::escape(Object) (Line: 265)
Drupal\Component\Render\FormattableMarkup::placeholderEscape(Object) (Line: 216)
Drupal\Component\Render\FormattableMarkup::placeholderFormat('You have not created any %bundle types yet. @link to add a new type.', Array) (Line: 195)
Drupal\Core\StringTranslation\TranslatableMarkup->render() (Line: 15)
Drupal\Core\StringTranslation\TranslatableMarkup->__toString() (Line: 471)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 187)
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: 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)I think the fix is to apply the patch at: https://www.drupal.org/project/drupal/issues/3352384 ✨ Add Exception for TypeError Argument must be String in \Drupal\Component\Utility\Html escape{} Needs work but I haven't successfully done it yet.
- Status changed to Closed: duplicate
11 months ago 11:37pm 23 January 2024 - 🇺🇸United States wxactly
Marking this as a duplicate. Anyone following this issue should check out the patches here: https://www.drupal.org/project/redhen/issues/3402288#comment-15344955 🐛 Entity queries must explicitly set whether the query should be access checked or not RTBC