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
.
Comment | File | Size | Author |
---|---|---|---|
#2 | votingapi-3110353-2.patch | 798 bytes | Kingdutch |
Comments
Comment #2
KingdutchTo help editors I've added a comment about the result of the
\Drupal::service()
call. IDEs may now complain that we're only catchingPluginNotFoundException
and not anInvalidPluginDefinitionException
. 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.Comment #3
andralex CreditAttribution: andralex at EPAM Systems for EPAM Systems commentedTested locally and it looks good.
Comment #4
alex_optimFor me too.
Comment #5
pifagorComment #7
pifagor