TypeError: Argument #2 ($config) must be of type array, null given

Created on 2 October 2024, 4 months ago

Problem/Motivation

After implementing a custom [my_module]_content_lock_entity_lockable function according to content_lock.api.php, and visiting the Views listing page /admin/structure/views, the following error is generated:

TypeError: [my_module]_content_lock_entity_lockable(): Argument #2 ($config) must be of type array, null given

Steps to reproduce

  1. Create a custom module or use an existing custom module.
  2. Implement the hook_content_lock_entity_lockable function according to what is found in the content_lock.api.php file.
  3. Attempt to visit the Views listing page at /admin/structure/views..
  4. Either a WSOD displaying "The website encountered an unexpected error. Try again later." or an error similar to what was listed under Problem/Motivation should be displayed.

Proposed resolution

The config parameter of the following hook_content_lock_entity_lockable function is as follows:
function hook_content_lock_entity_lockable(\Drupal\Core\Entity\EntityInterface $entity, array $config, string $form_op = NULL): bool

Update the file ContentLock.php on line 456, so that if it attempts to load the $config and receives a NULL value, that it sets this to an empty array, as that is what is expected in the above hook function:

Remaining tasks

Create an MR that includes the change to fix the issue.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

๐Ÿ› Bug report
Status

Active

Version

2.4

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States kevgrob

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024