Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument must be of type Countable|array in SolariumQuerier.php #16

Closed
coret opened this issue Oct 11, 2024 · 1 comment
Closed

Argument must be of type Countable|array in SolariumQuerier.php #16

coret opened this issue Oct 11, 2024 · 1 comment

Comments

@coret
Copy link

coret commented Oct 11, 2024

When searching I get the following error (may related to Daniel-KM/Omeka-S-module-AdvancedSearch#14 ?):

TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/http/goudatijdmachine.nl/omeka-s-modules/SearchSolr/src/Querier/SolariumQuerier.php:196
Stack trace:
#0 /home/http/goudatijdmachine.nl/omeka-s-modules/SearchSolr/src/Querier/SolariumQuerier.php(196): count()
#1 /home/http/goudatijdmachine.nl/omeka-s-modules/AdvancedSearch/src/Mvc/Controller/Plugin/SearchRequestToResponse.php(264): SearchSolr\Querier\SolariumQuerier->query()
#2 [internal function]: AdvancedSearch\Mvc\Controller\Plugin\SearchRequestToResponse->__invoke()
#3 /home/http/goudatijdmachine.nl/omeka-s-4.1.1/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php(275): call_user_func_array()
#4 /home/http/goudatijdmachine.nl/omeka-s-modules/AdvancedSearch/src/Controller/SearchController.php(154): Laminas\Mvc\Controller\AbstractController->__call()
#5 /home/http/goudatijdmachine.nl/omeka-s-4.1.1/vendor/laminas/laminas-mvc/src/Controller/AbstractActionController.php(71): AdvancedSearch\Controller\SearchController->searchAction()
#6 /home/http/goudatijdmachine.nl/omeka-s-4.1.1/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Laminas\Mvc\Controller\AbstractActionController->onDispatch()
#7 /home/http/goudatijdmachine.nl/omeka-s-4.1.1/vendor/laminas/laminas-eventmanager/src/EventManager.php(179): Laminas\EventManager\EventManager->triggerListeners()
#8 /home/http/goudatijdmachine.nl/omeka-s-4.1.1/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php(97): Laminas\EventManager\EventManager->triggerEventUntil()
#9 /home/http/goudatijdmachine.nl/omeka-s-4.1.1/vendor/laminas/laminas-mvc/src/DispatchListener.php(132): Laminas\Mvc\Controller\AbstractController->dispatch()
#10 /home/http/goudatijdmachine.nl/omeka-s-4.1.1/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Laminas\Mvc\DispatchListener->onDispatch()
#11 /home/http/goudatijdmachine.nl/omeka-s-4.1.1/vendor/laminas/laminas-eventmanager/src/EventManager.php(179): Laminas\EventManager\EventManager->triggerListeners()
#12 /home/http/goudatijdmachine.nl/omeka-s-4.1.1/vendor/laminas/laminas-mvc/src/Application.php(325): Laminas\EventManager\EventManager->triggerEventUntil()

#13 /home/http/goudatijdmachine.nl/omeka-s-4.1.1/index.php(21): Laminas\Mvc\Application->run()
#14 {main}

Commenting out the following code gets rid of the error and I get search results again (albeit without facets):

if (!$this->byResourceType && count($this->resourceTypes) > 1) {
$allResourceIdsByType = $this->response->getAllResourceIds(null, true);
if (isset($allResourceIdsByType['resources'])) {
$this->response->setAllResourceIdsByResourceType(['resources' => $allResourceIdsByType['resources']]);
} else {
$this->response->setAllResourceIdsByResourceType(['resources' => array_merge(...array_values($allResourceIdsByType))]);
}
$resultsByType = $this->response->getResults();
if (isset($resultsByType['resources'])) {
$this->response->setResults(['resources' => $resultsByType['resources']]);
} else {
$this->response->setResults(['resources' => array_replace(...array_values($resultsByType))]);
}
$totalResultsByType = $this->response->getResourceTotalResults();
$total = isset($totalResultsByType['resources']) ? $totalResultsByType['resources'] : array_sum($totalResultsByType);
$this->response->setResourceTotalResults('resources', $total);
$this->response->setTotalResults($total);
}

FYI:
Omeka S - version 4.1.1
Advanced Search - version 3.4.32
Advanced Search adapter for Solr - version 3.5.48

@Daniel-KM
Copy link
Owner

Ok, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants