No like/dislike widgets available in article pages

Created on 15 April 2024, 8 months ago
Updated 18 April 2024, 8 months ago

Problem/Motivation

Enabled likes_and_dislike module(Drupal 10) for the content type 'Article' with custom page template does not show any like/dislike widgets in article pages.

Steps to reproduce

1. Install the module like_and_dislike
2. Choose the entity types with Like & Dislike widgets enabled through /admin/config/search/votingapi/like_and_dislike
3. Clear the cache and visit the article pages.
4. No like_and_dislike widgets is available in article page.

Thanks

🐛 Bug report
Status

Active

Version

2.0

Component

User interface

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @shinkula
  • 🇬🇧United Kingdom aaron.ferris

    I think this is this issue in votingapi: https://www.drupal.org/project/votingapi/issues/3436447 🐛 Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck() Needs review

    User error: Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck(). in /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php:141 Stack trace: #0 /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(80): Drupal\Core\Entity\Query\Sql\Query->prepare() #1 /var/www/html/web/modules/contrib/votingapi/src/VoteResultStorage.php(28): Drupal\Core\Entity\Query\Sql\Query->execute() #2 /var/www/html/web/modules/contrib/like_and_dislike/like_and_dislike.module(65): Drupal\votingapi\VoteResultStorage->getEntityResults('node', '1', 'like', 'vote_sum') #3 /var/www/html/web/modules/contrib/like_and_dislike/src/LikeDislikeVoteBuilder.php(75): like_and_dislike_get_votes(Object(Drupal\node\Entity\Node)) #4 [internal function]: Drupal\like_and_dislike\LikeDislikeVoteBuilder->build('node', '1') #5 /var/www/html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array(Array, Array) #6 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(859): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #lazy_bu...', 'exception', 'Drupal\\Core\\Ren...') #7 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(400): Drupal\Core\Render\Renderer->doCallback('#lazy_builder', 'like_and_dislik...', Array) #8 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, true) #9 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(165): Drupal\Core\Render\Renderer->render(Array, true) #10 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() #11 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(166): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #12 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(183): Drupal\Core\Render\Renderer->renderPlain(Array) #13 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(220): Drupal\Core\Render\Renderer->doRenderPlaceholder(Array) #14 /var/www/html/web/core/modules/big_pipe/src/Render/BigPipe.php(723): Drupal\Core\Render\Renderer->renderPlaceholder('callback=like_a...', Array) #15 /var/www/html/web/core/modules/big_pipe/src/Render/BigPipe.php(554): Drupal\big_pipe\Render\BigPipe->renderPlaceholder('callback=like_a...', Array) #16 [internal function]: Drupal\big_pipe\Render\BigPipe->Drupal\big_pipe\Render\{closure}() #17 /var/www/html/web/core/modules/big_pipe/src/Render/BigPipe.php(566): Fiber->start() #18 /var/www/html/web/core/modules/big_pipe/src/Render/BigPipe.php(305): Drupal\big_pipe\Render\BigPipe->sendPlaceholders(Array, Array, Object(Drupal\Core\Asset\AttachedAssets)) #19 /var/www/html/web/core/modules/big_pipe/src/Render/BigPipeResponse.php(112): Drupal\big_pipe\Render\BigPipe->sendContent(Object(Drupal\big_pipe\Render\BigPipeResponse)) #20 /var/www/html/vendor/symfony/http-foundation/Response.php(423): Drupal\big_pipe\Render\BigPipeResponse->sendContent() #21 /var/www/html/web/index.php(20): Symfony\Component\HttpFoundation\Response->send() #22 {main} in Drupal\big_pipe\Render\BigPipe->sendPlaceholders() (line 632 of /var/www/html/web/core/modules/big_pipe/src/Render/BigPipe.php)
    
  • 🇬🇧United Kingdom aaron.ferris

    With the patch from the above, and the like/dislike element shown to display per content type (needs to be configured at admin/structure/types/manage/article/display as well, then the element should start to display as expected.

  • Hi
    The above patch is for checking access to query. In my base theme(bootstrap_barrio) if i remove the patched line ->accessCheck(), I get the same error as mentioned previously.

    Uncaught PHP Exception Drupal\\Core\\Entity\\Query\\QueryException: "Entity queries must explicitly set whether the query should be access checked or not. See Drupal\\Core\\Entity\\Query\\QueryInterface::accessCheck()." at /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php line 141, referer: https://mydomain.com/article/article-node-8

    After applying the patch, i can see the like/dislike widgets in the base theme.

    However, if i switch to the sub-theme which is derived from bootstrap_barrio, i don't see any widgets. On debugging, i have found that the voting api module does get called in the subtheme, no code/css are added to the page. I can confirm like/dislike field is there in the manage display settings for the article content type.

    Thanks

  • I was displaying page body content using {{ node.body.value|raw }} and once i replace the same with {{ page.content }} the like/dislike widgets is now visible. Having said that, is it possible to display the widgets using something like {{ page.content.like_and_dislike }} ? I don't see any node variable available for like/dislike field in the twig debug mode.

  • {{ page.content.system_main['#attached'].placeholders }} displays the like/dislike widgets.

  • Another issue i am facing is that, the dislike button always remains in disabled state for anonymous users. The permissions for add/remove Like vote is already assigned to the anonymous users.

    https://imgur.com/a/tgFntPM

  • That was an issue with vote roll over on voting API (/admin/config/search/votingapi) Setting right values for roll over vote solves the problem.

Production build 0.71.5 2024