Ignore non-existing range values silently

Created on 25 December 2023, 9 months ago

Problem/Motivation

If a user changes the range values in the URL manually, you get a huge warning entry in the database log of about ~7500 characters (see below).

Steps to reproduce

Use the module, select some facets, change the numeric value in a range manually, and see a warning in the log.

Proposed resolution

Ignore values which are not part of the pre-defined ranges, by checking if the value exists in the array.

Remaining tasks

User interface changes

API changes

Data model changes

A single warning from the log:

php Warning: Undefined array key 25020 in Drupal\facet_range_list_item\Plugin\facets\query_type\SearchApiRangeList->calculateRange() (line 37 of /var/www/html/web/modules/custom/facet_range_list_item/src/Plugin/facets/query_type/SearchApiRangeList.php) #0 /var/www/html/web/core/includes/bootstrap.inc(164): _drupal_error_handler_real(2, 'Undefined array...', '/var/www/html/w...', 37)
#1 /var/www/html/web/modules/custom/facet_range_list_item/src/Plugin/facets/query_type/SearchApiRangeList.php(37): _drupal_error_handler(2, 'Undefined array...', '/var/www/html/w...', 37)
#2 /var/www/html/web/modules/contrib/facets/src/QueryType/QueryTypeRangeBase.php(32): Drupal\facet_range_list_item\Plugin\facets\query_type\SearchApiRangeList->calculateRange('25020')
#3 /var/www/html/web/modules/contrib/facets/src/FacetManager/DefaultFacetManager.php(167): Drupal\facets\QueryType\QueryTypeRangeBase->execute() 
#4 /var/www/html/web/modules/contrib/facets/src/EventSubscriber/SearchApiSubscriber.php(51): Drupal\facets\FacetManager\DefaultFacetManager->alterQuery(Object(Drupal\search_api\Query\Query), 'search_api:view...') 
#5 [internal function]: Drupal\facets\EventSubscriber\SearchApiSubscriber->queryAlter(Object(Drupal\search_api\Event\QueryPreExecuteEvent), 'search_api.quer...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#6 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\search_api\Event\QueryPreExecuteEvent), 'search_api.quer...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) 
#7 /var/www/html/web/modules/contrib/search_api/src/Query/Query.php(596): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Drupal\search_api\Event\QueryPreExecuteEvent), 'search_api.quer...') 
#8 /var/www/html/web/modules/contrib/search_api/src/Plugin/views/cache/SearchApiCachePluginTrait.php(206): Drupal\search_api\Query\Query->preExecute() 
#9 /var/www/html/web/modules/contrib/search_api/src/Plugin/views/cache/SearchApiCachePluginTrait.php(173): Drupal\search_api\Plugin\views\cache\SearchApiTagCache->generateResultsKey()
#10 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1434): Drupal\search_api\Plugin\views\cache\SearchApiTagCache->cacheGet('results') 
#11 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1469): Drupal\views\ViewExecutable->execute(NULL)
#12 /var/www/html/web/core/modules/views/src/Plugin/views/display/Page.php(199): Drupal\views\ViewExecutable->render() 
#13 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1645): Drupal\views\Plugin\views\display\Page->execute() 
#14 /var/www/html/web/core/modules/views/src/Element/View.php(81): Drupal\views\ViewExecutable->executeDisplay('map', Array) 
#15 [internal function]: Drupal\views\Element\View::preRenderViewElement(Array)
#16 /var/www/html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array(Array, Array)
#17 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(858): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...') 
#18 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(421): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#19 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false) 
#20 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render(Array, false) 
#21 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() 
#22 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(231): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#23 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#24 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#25 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) 
#26 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) 
#27 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#28 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) 
#29 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#30 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#31 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#32 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /var/www/html/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#34 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#35 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#37 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#38 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#39 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#40 {main}.
🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇩🇰Denmark ressa Copenhagen

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