TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in _menu_check_access()

Created on 16 January 2023, over 1 year ago
Updated 26 April 2023, over 1 year ago

Problem/Motivation

Switching to PHP 8 generated the following error:

TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in _menu_check_access() (line 645 of /app/web/includes/menu.inc).

Proposed resolution

Add array type declaration to $arguments in line 645 of includes/menu.inc.

- $item['access'] = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]);
+ $item['access'] = (count((array)$arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]);
πŸ› Bug report
Status

Closed: works as designed

Version

7.0 ⚰️

Component
Menu systemΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ͺπŸ‡ͺEstonia tormi Tallinn

Live updates comments and jobs are added and updated live.
  • PHP 8.0

    The issue particularly affects sites running on PHP version 8.0.0 or later.

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.

  • Status changed to Needs review over 1 year ago
  • Status changed to Postponed: needs info over 1 year ago
  • πŸ‡ΈπŸ‡°Slovakia poker10

    Thanks for reporting this @tormi. Can you please provide steps to reproduce this issue? Is it reproducible on clean D7 install, or you need some contrib module (which is probably malforming the serialized data)?

  • Status changed to Closed: works as designed over 1 year ago
  • πŸ‡ͺπŸ‡ͺEstonia tormi Tallinn

    So I think it will be better to check the root cause why the serialized data are not an array, than mask this with a conversion.

    Indeed, thanks.

Production build 0.71.5 2024