Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When creating a view with a filter on interface language, the following error occurs:
Notice: Undefined offset: 0 in Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->createFilterQuery() (line 1691 of modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php).
Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->createFilterQuery('ss_search_api_language', Array, 'IN', Object) (Line: 1588)
Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->createFilterQueries(Object, Array, Array) (Line: 1556)
Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->getFilterQueries(Object, Array, Array) (Line: 903)
Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->search(Object) (Line: 427)
Drupal\search_api\Entity\Server->search(Object) (Line: 346)
Drupal\search_api\Query\Query->execute() (Line: 501)
Drupal\search_api\Plugin\views\query\SearchApiQuery->execute(Object) (Line: 1412)
Drupal\views\ViewExecutable->execute() (Line: 104)
Drupal\facets\Plugin\facets\facet_source\SearchApiViews->fillFacetsWithResults(Array) (Line: 346)
Drupal\facets\FacetManager\DefaultFacetManager->updateResults('search_api_views:search:page_1') (Line: 198)
Drupal\facets\FacetManager\DefaultFacetManager->processFacets('search_api_views:search:page_1') (Line: 365)
Drupal\facets\FacetManager\DefaultFacetManager->returnProcessedFacet(Object) (Line: 181)
Drupal\facets\Plugin\Condition\OtherFacet->evaluate() (Line: 66)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 77)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\block\BlockAccessControlHandler->resolveConditions(Array, 'and') (Line: 123)
Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 93)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 334)
Drupal\Core\Entity\Entity->access('view', NULL, 1) (Line: 56)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 259)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 98)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
An error occurred while trying to search with Solr: Solr HTTP error: OK (400) {"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","org.apache.solr.parser.ParseException"],"msg":"org.apache.solr.search.SyntaxError: Cannot parse 'ss_search_api_language:': Encountered \"<EOF>\" at line 1, column 23.\nWas expecting one of:\n <BAREOPER> ...\n \"(\" ...\n \"*\" ...\n <QUOTED> ...\n <TERM> ...\n <PREFIXTERM> ...\n <WILDTERM> ...\n <REGEXPTERM> ...\n \"[\" ...\n \"{\" ...\n <LPARAMS> ...\n \"filter(\" ...\n <NUMBER> ...\n ","code":400}} .
$field is ss_search_api_language
$value is array ( '***LANGUAGE_language_interface***' => '"en"'
Comment | File | Size | Author |
---|---|---|---|
#13 | 2773019-12.patch | 1.35 KB | mkalkbrenner |
#9 | 2773019-test-only.patch | 596 bytes | mkalkbrenner |
#3 | 2773019-1.patch | 598 bytes | mpp |
Comments
Comment #2
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #3
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #4
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedarray_shift($value) will work on an array with non integer hash keys.
question remains why the key is "***LANGUAGE_language_interface***" and not 0?
Comment #5
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #6
AsadKamil CreditAttribution: AsadKamil at Valuebound commentedPatch applied cleanly to 8.x Branch
Thanks
Comment #7
mkalkbrennerDid anyone double check if it works with the database backend?
Comment #8
mpp CreditAttribution: mpp as a volunteer and at AmeXio commented@mkalkbrenner, just tested it with the db backend and it's working fine. The issue is only related to the SearchApiSolrBackend when only one value is selected.
Comment #9
mkalkbrennerI created a test only patch on top of #2775497: Run \Drupal\search_api\Tests\ViewsTest on Solr Backend.
But this test succeeds! Can you tell me some more details about your setup?
Comment #10
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedIt's a search_api_solr view.
PHP 7 (tested with php 5.6 that's not the issue), Drupal 8.1.7 with Solr 6 and 2 languages enabled.
Created an index with some node types and some fields among which language.
Created a search view that shows rendered entities on this index with a filter
Item language: The item's language
.Comment #12
idhard CreditAttribution: idhard commentedi can confirm the same bug , and the patch #3 worked out . thanks!
Comment #13
mkalkbrennerI still can't reproduce the issue, in other words I always get numeric index keys.
Nevertheless the patch makes sense as it is more robust, even for future usages.
But we if we do the array_ahift(), we have to it for the other operators as well, not just for one particular operator.
I attached an enhanced patch.
Comment #15
mkalkbrenner