count(): Argument #1 ($value) must be of type Countable|array, int given dans count()

Created on 12 December 2023, about 1 year ago
Updated 13 December 2023, about 1 year ago

Problem/Motivation

I have this message in dblog

TypeError : count(): Argument #1 ($value) must be of type Countable|array, int given dans count() (/app/web/modules/contrib/views_autocomplete_api/src/Service/ViewsAutocompleteApiManager.php ligne 95)

Steps to reproduce

** PHP 8.0
** Drupal 9

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Needs review

Version

2.1

Component

Code

Created by

๐Ÿ‡ฟ๐Ÿ‡ผZimbabwe chaimaa faris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @chaimaa faris
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chetan 11

    chetan 11 โ†’ made their first commit to this issueโ€™s fork.

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chetan 11

    Hi,
    I have fixed the above error on "views_autocomplete_api" module, please check the attached MR.
    Thanks.

  • Hi Chetan,

    Unfortunately, your commit removed the fix :/

          if (count($display_id) !== count($count_view)) {
    

    This should be replaced by

          if (count($display_id) !== $count_view) {
    

    We are already have count in the Controller which call the Service

    # src/Controller/ViewsAutocompleteApiController.php
        $display_ids = $this->viewsAutocompleteManager->getViewsDisplayId($display_id, count($view_name));
    
    # /Service/ViewsAutocompleteApiManager.php
      public function getViewsDisplayId($display_id, $count_view) {
        if (!empty($display_id)) {
          $display_id = explode(',', $display_id);
          if (count($display_id) !== count($count_view)) {
    
  • ๐Ÿ‡ฟ๐Ÿ‡ผZimbabwe chaimaa faris

    I fixed the problem mentioned in the issue. You can use this patch if you encounter the same problem

Production build 0.71.5 2024