DivisionByZeroError: Division by zero in Drupal\Core\Pager\Pager->setTotalPages()

Created on 6 December 2024, 13 days ago

Problem/Motivation

If a user has only the "access webform overview" permission, when he try to access to webform overview page /admin/structure/webform the module trigger a php error :

DivisionByZeroError: Division by zero in Drupal\Core\Pager\Pager->setTotalPages() (line 78 of core/lib/Drupal/Core/Pager/Pager.php).
Drupal\Core\Pager\Pager->__construct(0, , 0) (Line: 56)
Drupal\Core\Pager\PagerManager->createPager(0, ) (Line: 105)
Drupal\domain_access_webform\DomainWebformEntityListBuilder->getEntityIds() (Line: 644)
Drupal\webform\WebformEntityListBuilder->load() (Line: 241)
Drupal\Core\Entity\EntityListBuilder->render() (Line: 171)
Drupal\webform\WebformEntityListBuilder->render() (Line: 23)
Drupal\Core\Entity\Controller\EntityListController->listing('webform')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
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}() (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: 28)
Drupal\Core\StackMiddleware\ContentLength->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: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I major use cases, the users do not only have this permission but it could happen.

Steps to reproduce

  1. Create a user with a role that only have the "access webform overview" permission
  2. Try to access to overview page /admin/structure/webform

Proposed resolution

Do not try to build the pager with pager.manager service if the $limit variable is set to FALSE and let the webform module render an empty page.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024