Problem/Motivation
Warning: count(): Parameter must be an array or an object that implements Countable in Drupal\views_autocomplete_api\Service\ViewsAutocompleteApiManager->getViewsDisplayId() (regel 95 van /app/web/modules/contrib/views_autocomplete_api/src/Service/ViewsAutocompleteApiManager.php)
The argument $count_view passed to getViewsDisplayId() must be an int, on line 95 the function count is applied to $count_view which lead to a php warning. The use of count() has no needed.
Steps to reproduce
Open a url like /admin/view_content/view_autocomplete_search_all?q=pen and inspect /admin/reports/dblog
Proposed resolution
Remove the count function applied to $count_view
(First patch contains a bug added views_autocomplete_api-3.patch)
Comments
Comment #2
4p commentedComment #3
4p commentedComment #4
4p commentedComment #5
brolad commented#3 solved the issue, thanks for the patch. But I guess we should contain all the logic inside the ViewsAutocompleteApiManager.php file. I mean we should remove the count() from ViewsAutocompleteApiController.php that passes to methods getViewsDisplayId() & prepareArgumentViews() and replace these methods to accept array type and make it compatible with providing count() and other expecting logic. What do you think?
Comment #6
trevorbradley commentedReviewed and working.
Note that in PHP 8.1, this isn't a warning, it's an error that broke my site. #3 patches the issue and my AJAX call is working again.
Comment #7
trevorbradley commentedComment #8
vladimirausThank you for your contributions. 🎂
Committed. 🚀