Problem/Motivation

I got this error for the Drupal 10 and php 8.1

TypeError: Drupal\core_event_dispatcher\Event\Entity\EntityFieldAccessEvent::getItems(): Return value must be of type Drupal\Core\Field\FieldItemListInterface, null returned in Drupal\core_event_dispatcher\Event\Entity\EntityFieldAccessEvent->getItems() (line 72 of modules/contrib/hook_event_dispatcher/modules/core_event_dispatcher/src/Event/Entity/EntityFieldAccessEvent.php).

In the class construct this parameter is allowed to be optional.

So in order to resolve this issue need to allow return null for this function

  /**
   * Get the items.
   *
   * @return null|\Drupal\Core\Field\FieldItemListInterface
   *   The items.
   */
  public function getItems(): ?FieldItemListInterface {
    return $this->items;
  }
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Lysenko created an issue. See original summary.

lysenko’s picture

Issue summary: View changes
lysenko’s picture

Issue summary: View changes
lysenko’s picture

Issue summary: View changes

lysenko’s picture

Assigned: lysenko » Unassigned
Status: Active » Needs review
el7cosmos’s picture

Thanks, Lysenko. Are you able to add a test case in \Drupal\Tests\core_event_dispatcher\Kernel\Entity\EntityFieldAccessEventTest?

el7cosmos’s picture

Version: 4.0.0-beta1 » 4.x-dev
Status: Needs review » Needs work
Issue tags: +Need tests
el7cosmos’s picture

Assigned: Unassigned » el7cosmos

el7cosmos’s picture

Assigned: el7cosmos » Unassigned
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.