Argument #1 ($entity) must be of type Drupal\Core\Entity\ContentEntityInterface, null given

Created on 2 July 2025, 2 days ago

Problem/Motivation

We have the module installed on a site with commerce integration. However, when we go through the checkout of the site, we see logs along the lines of

TypeError: _ckeditor_mentions_entity_collect_mentions(): Argument #1 ($entity) must be of type Drupal\Core\Entity\ContentEntityInterface, null given, called in /web/modules/contrib/ckeditor_mentions/modules/ckeditor_mentions_entity/ckeditor_mentions_entity.module on line 107 in _ckeditor_mentions_entity_collect_mentions() (line 17 of /web/modules/contrib/ckeditor_mentions/modules/ckeditor_mentions_entity/ckeditor_mentions_entity.module).

Steps to reproduce

  1. Install commerce
  2. Configure commerce
  3. Add product(s)
  4. Install this module
  5. Configure module
  6. Add product to cart
  7. Go through the checkout
  8. Check the logs

Proposed resolution

Set parameter one to nullable like so

function _ckeditor_mentions_entity_collect_mentions(?ContentEntityInterface $entity) {
  if (!$entity) {
    return [];
  }
  // Rest of the code
}

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇧🇪Belgium blacksnipe

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

Comments & Activities

Production build 0.71.5 2024