pointless if() block in EntityViewsData

Created on 22 March 2023, over 1 year ago
Updated 25 April 2023, over 1 year ago

Problem/Motivation

EntityViewsData does this:

    if ($table_mapping = $this->storage->getTableMapping($field_definitions)) {

But the return docs for SqlEntityStorageInterface::getTableMapping() don't say that the return can be anything falsy:

   * @return \Drupal\Core\Entity\Sql\TableMappingInterface
   *   A table mapping object for the entity's tables.

The implementation, SqlContentEntityStorage::getCustomTableMapping() always returns the result of getCustomTableMapping(), and that is always an object:

  public function getCustomTableMapping(ContentEntityTypeInterface $entity_type, array $storage_definitions, $prefix = '') {
    $prefix = $prefix ?: ($this->temporary ? 'tmp_' : '');
    return DefaultTableMapping::create($entity_type, $storage_definitions, $prefix);
  }

Steps to reproduce

Proposed resolution

Remove the if() check.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Fixed

Version

10.1 โœจ

Component
Viewsย  โ†’

Last updated about 2 hours ago

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024