Multiple php notices when using distance search in views and search api

Created on 16 May 2023, over 1 year ago

Problem/Motivation

I'm using search API with views to create a map. The map is of the indexed nodes and the geolocation field is used to place them in the right location on the map. If I add a filter for the geolocation field (exposed or not) for filtering by distance from a given point I have multiple instances of:

Notice: Trying to access array offset on value of type bool in Drupal\views\Plugin\views\PluginBase->setOptionDefaults() (line 187 of /var/www/vhosts/talentmaps2022.local/httpdocs/core/modules/views/src/Plugin/views/PluginBase.php)

In the recent log messages.

Steps to reproduce

Add an index for a content type with a geolocation field and index the geolocation field as long/lat. Add a view using the index as the data source and a map display to show the nodes an a map.

Then add a filter of "Content datasource: Geolocation (< geocode). The notices should now be in the recent log messages. This happens when editing the view in the backend theme or viewing on the front end so it's not the theme that's the issue.

Here's the full trace:

Notice: Trying to access array offset on value of type bool in Drupal\views\Plugin\views\PluginBase->setOptionDefaults() (line 187 of /var/www/vhosts/example.com/httpdocs/core/modules/views/src/Plugin/views/PluginBase.php)
#0 /var/www/vhosts/example.com/httpdocs/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8, 'Trying to acces...', '/var/www/vhosts...', 187)
#1 /var/www/vhosts/example.com/httpdocs/core/modules/views/src/Plugin/views/PluginBase.php(187): _drupal_error_handler(8, 'Trying to acces...', '/var/www/vhosts...', 187, Array)
#2 /var/www/vhosts/example.com/httpdocs/core/modules/views/src/Plugin/views/PluginBase.php(141): Drupal\views\Plugin\views\PluginBase->setOptionDefaults(Array, Array)
#3 /var/www/vhosts/example.com/httpdocs/core/modules/views/src/Plugin/views/HandlerBase.php(104): Drupal\views\Plugin\views\PluginBase->init(Object(Drupal\views\ViewExecutable), Object(Drupal\views_block_filter_block\Plugin\views\display\ViewsBlockFilterBlockPluginDisplayBlock), Array)
#4 /var/www/vhosts/example.com/httpdocs/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php(95): Drupal\views\Plugin\views\HandlerBase->init(Object(Drupal\views\ViewExecutable), Object(Drupal\views_block_filter_block\Plugin\views\display\ViewsBlockFilterBlockPluginDisplayBlock), Array)
#5 /var/www/vhosts/example.com/httpdocs/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(894): Drupal\views\Plugin\views\filter\FilterPluginBase->init(Object(Drupal\views\ViewExecutable), Object(Drupal\views_block_filter_block\Plugin\views\display\ViewsBlockFilterBlockPluginDisplayBlock), Array)
#6 /var/www/vhosts/example.com/httpdocs/core/modules/views/src/ViewExecutable.php(1045): Drupal\views\Plugin\views\display\DisplayPluginBase->getHandlers('filter')
#7 /var/www/vhosts/example.com/httpdocs/core/modules/views/src/ViewExecutable.php(903): Drupal\views\ViewExecutable->_initHandler('filter', Array)
#8 /var/www/vhosts/example.com/httpdocs/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2318): Drupal\views\ViewExecutable->initHandlers()
#9 /var/www/vhosts/example.com/httpdocs/core/modules/views/src/ViewExecutable.php(1697): Drupal\views\Plugin\views\display\DisplayPluginBase->preExecute()
#10 /var/www/vhosts/example.com/httpdocs/core/modules/views/src/ViewExecutable.php(1665): Drupal\views\ViewExecutable->preExecute(Array)
#11 /var/www/vhosts/example.com/httpdocs/core/modules/views_ui/src/ViewUI.php(611): Drupal\views\ViewExecutable->preview('map', Array)
#12 /var/www/vhosts/example.com/httpdocs/core/modules/views_ui/src/ViewPreviewForm.php(62): Drupal\views_ui\ViewUI->renderPreview('map', Array)
#13 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/Entity/EntityForm.php(106): Drupal\views_ui\ViewPreviewForm->form(Array, Object(Drupal\Core\Form\FormState))
#14 /var/www/vhosts/example.com/httpdocs/core/modules/views_ui/src/ViewFormBase.php(41): Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
#15 [internal function]: Drupal\views_ui\ViewFormBase->buildForm(Array, Object(Drupal\Core\Form\FormState), 'map')
#16 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array(Array, Array)
#17 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/Form/FormBuilder.php(375): Drupal\Core\Form\FormBuilder->retrieveForm('view_preview_fo...', Object(Drupal\Core\Form\FormState))
#18 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm('view_preview_fo...', Object(Drupal\Core\Form\FormState), Array)
#19 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm('view_preview_fo...', Array, Object(Drupal\Core\Form\FormState))
#20 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\views_ui\ViewPreviewForm), Object(Drupal\Core\Form\FormState))
#21 /var/www/vhosts/example.com/httpdocs/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#22 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#23 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#24 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#25 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#26 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#27 /var/www/vhosts/example.com/httpdocs/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#28 /var/www/vhosts/example.com/httpdocs/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#29 /var/www/vhosts/example.com/httpdocs/modules/contrib/redirect_after_login/src/RedirectMiddleware.php(46): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Drupal\redirect_after_login\RedirectMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /var/www/vhosts/example.com/httpdocs/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /var/www/vhosts/example.com/httpdocs/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#35 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 /var/www/vhosts/example.com/httpdocs/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#37 /var/www/vhosts/example.com/httpdocs/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#38 /var/www/vhosts/example.com/httpdocs/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#39 {main}

🐛 Bug report
Status

Active

Version

3.12

Component

Geolocation Field / Backend

Created by

🇬🇧United Kingdom vaccinemedia

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

Comments & Activities

Production build 0.71.5 2024