Documentation for EntityDefinitionUpdateManagerInterface::getFieldStorageDefinition missing NULL return

Created on 14 July 2020, over 4 years ago
Updated 26 June 2023, over 1 year ago

Problem/Motivation

The documentation for \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface::getFieldStorageDefinition says that methods always returns \Drupal\Core\Field\FieldStorageDefinitionInterface:

   * @return \Drupal\Core\Field\FieldStorageDefinitionInterface
   *   The field storage definition.

But implementation \Drupal\Core\Entity\EntityDefinitionUpdateManager::getFieldStorageDefinition can return NULL.

  /**
   * {@inheritdoc}
   */
  public function getFieldStorageDefinition($name, $entity_type_id) {
    $storage_definitions = $this->entityLastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions($entity_type_id);
    return isset($storage_definitions[$name]) ? clone $storage_definitions[$name] : NULL;
  }

Proposed resolution

Add NULL as return type to the interface documentation.

Remaining tasks

- Reviews needed

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Documentation 

Last updated 6 days ago

No maintainer
Created by

🇷🇺Russia niklan Russia, Perm

Live updates comments and jobs are added and updated live.
  • Quick fix

    Very small and simple change. Preferred over Quickfix.

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.

  • 🇬🇧United Kingdom joachim

    > I think we should deprecate returning NULL and throw an exception (in the D10 future) instead.

    Agreed, but could we reset this issue to being a documentation quick fix, so the docs correctly reflect what the code does, and file a separate issue to improve the code?

Production build 0.71.5 2024