Problem

The votingapi_views_data_alter function in votingapi.views.inc uses an empty check on the result of EntityTypeManager::getStorage to see if the entity type vote_type is missing. In the case it's missing no views data is altered.

EntityTypeManager::getStorage doesn't return NULL for a missing entity. Instead it throws a PluginNotFoundException when the entity does not exist.

Since votingapi doesn't depend on a module that may provide this entity type the scenario that the entity does not (yet) exist can happen during installation or uninstallation.

Solution

Change the empty() check if-statement into a try {} catch() {} block that will return when there's a PluginNotFoundException.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Kingdutch created an issue. See original summary.

Kingdutch’s picture

To help editors I've added a comment about the result of the \Drupal::service() call. IDEs may now complain that we're only catching PluginNotFoundException and not an InvalidPluginDefinitionException. However, that latter exception is not one we expect and should be presented to a user. We only expect (and handle) the case where the entity type is not available.

andralex’s picture

Status: Needs review » Reviewed & tested by the community

Tested locally and it looks good.

alex_optim’s picture

For me too.

pifagor’s picture

  • pifagor committed 5a819ab on 8.x-3.x authored by Kingdutch
    Issue #3110353 by Kingdutch, andralex, alex_optim, pifagor:...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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