TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in count() (line 40 of web/modules/contrib/tac_lite/src/Form/SchemeForm.php)

Created on 3 September 2022, over 2 years ago
Updated 28 August 2023, over 1 year ago

Problem/Motivation

In the setting page I have this error when click on "Scheme":

TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in count() (line 40 of /web/modules/contrib/tac_lite/src/Form/SchemeForm.php)

Proposed resolution

In line 40 of modules/contrib/tac_lite/src/Form/SchemeForm.php replacement this code:

if (count($vids)) {
with this:

    if (count((array)$vids)) {

Works for me with Drupal 9.4.5 and PHP 8.1

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇹Italy kris77

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    This fix is a start and would be a good idea in any case.

    I am seeing this after having enabled tac_lite but not doing any config. If there are no schemes configured, it should not show the "Scheme 1" tab at all and visiting the URL should give a 404.

  • 🇮🇳India msankhala Bikaner, Rajasthan

    Patch #5 works fine. If there are no schemes configured then the "Scheme 1" tab shows proper instructions:

    First, select one or more vocabularies on the settings tab. Then, return to this page to complete configuration.

    Which I believe is good enough, instead of hiding the "Scheme 1" entirely until you select the vocabulary.

Production build 0.71.5 2024