Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292436

pointless if() block in EntityViewsData

$
0
0

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


Viewing all articles
Browse latest Browse all 292436

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>