DivisionByZeroError When Searching

Created on 16 October 2024, about 2 months ago

Problem/Motivation

I am testing the SearchStax modules on a site with an existing Search API Solr powered setup and view. I have enabled the SearchStax module, but have NOT done any configuration (in other words, my view and search are NOT using SearchStax). However, the SearchStax module throws a fatal error on a search result:

The website encountered an unexpected error. Try again later.

DivisionByZeroError: Division by zero in _searchstax_add_tracking() (line 146 of modules/contrib/searchstax/searchstax.module).
searchstax_preprocess_views_view()
call_user_func_array() (Line: 261)
Drupal\Core\Theme\ThemeManager->render() (Line: 446)
Drupal\Core\Render\Renderer->doRender() (Line: 459)
Drupal\Core\Render\Renderer->doRender() (Line: 203)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() (Line: 246)
Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 188)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

1. I used DDEV with the ddev-drupal-solr Add-On
2. I'm running a typical search setup (using Search API, Search API Solr, Views, Facets, Search API Autocomplete, etc.)
3. I've generated 50 pages of content using devel generate
4. I've built a search view with an exposed filter with autocomplete
5. Autocomplete works fine on the page
6. When I use the exposed filter to search on my search view, the server throws a fatal error

Note: this all works perfectly fine as soon as I disable your module.

Proposed resolution

At minimum, you need to add additional logic to your module so that it's not firing on views / indexes that it doesn't own.

Ideally this code should not fatal err out. There's no reason for it to throw a fatal, it should fail gracefully.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.4

Component

Code

Created by

🇺🇸United States mikemadison Seattle, WA

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