Many %2C in URLs and "A non-numeric value encountered in Drupal\search_api_page\Controller\SearchApiPageController->prepareQuery()"
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3580419. -->
Reported by: [anybody](https://www.drupal.org/user/291091)
Related to !35
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Submitting a search with any input, e.g. "Lorem" results in the following URL:<br>
<a href="https://www.example.com/search/lorem?page=1%2C%2C0%2C%2C%2C0%2C0%2C%2C0%2C0%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C0%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C0">https://www.example.com/search/lorem?page=1%2C%2C0%2C%2C%2C0%2C0%2C%2C0%2C0%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C0%2C%2C%2C%2C%2C%2C%2C%2C%2C%2C0</a><br>
and the following warning being shown:</p>
<pre>Warning: A non-numeric value encountered in Drupal\search_api_page\Controller\SearchApiPageController->prepareQuery() (line 273 of modules/contrib/search_api_page/src/Controller/SearchApiPageController.php).<br><br>Drupal\search_api_page\Controller\SearchApiPageController->prepareQuery() (Line: 110)<br>Drupal\search_api_page\Controller\SearchApiPageController->page()<br>call_user_func_array() (Line: 123)<br>Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext():121}() (Line: 634)<br>Drupal\Core\Render\Renderer::{closure:Drupal\Core\Render\Renderer::executeInRenderContext():634}()<br>Fiber->start() (Line: 635)<br>Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)<br>Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)<br>Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController():96}() (Line: 183)<br>Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)<br>Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)<br>Drupal\Core\StackMiddleware\Session->handle() (Line: 48)<br>Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)<br>Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)<br>Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 118)<br>Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 92)<br>Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 263)<br>Drupal\shield\ShieldMiddleware->bypass() (Line: 219)<br>Drupal\shield\ShieldMiddleware->handle() (Line: 62)<br>Drupal\crowdsec\Middleware->handle() (Line: 50)<br>Drupal\ban\BanMiddleware->handle() (Line: 48)<br>Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)<br>Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)<br>Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 49)<br>Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle() (Line: 54)<br>Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 745)<br>Drupal\Core\DrupalKernel->handle() (Line: 19)</pre><p>Use clean URLs setting is enabled</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Submit a search value in a Search Api Page and see the warning and the weird URL as written</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3 id="summary-ui-changes">User interface changes</h3>
<h3 id="summary-api-changes">API changes</h3>
<h3 id="summary-data-model-changes">Data model changes</h3>
issue
GitLab AI Context
Project: project/search_api_page
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/search_api_page/-/raw/8.x-1.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/search_api_page
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD