Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm getting the following error when clearing caches:
Notice: Undefined index: controller class in entity_type_supports() (line 84 of drupal-7/sites/all/modules/contrib/entity/entity.module).
followed by a bunch of warnings that are spun from this initial error.
The problem is this line of code:
if ($op != 'access') {
return in_array('EntityAPIControllerInterface', class_implements($info['controller class']));
}
The errors are resolved when we wrap this call to class_implements in a second if statement, as so:
if ($op != 'access') {
if (array_key_exists('controller class', $info)) {
return in_array('EntityAPIControllerInterface', class_implements($info['controller class']));
}
}
I've included a patch that provides the same kind of protection for revision delete.
Comment | File | Size | Author |
---|---|---|---|
#2 | entity-prevent_errors_with_ifs-2034467-2.patch | 908 bytes | jenlampton |
entity-prevent_errors_with_ifs.patch | 939 bytes | jenlampton | |
Comments
Comment #1
dman CreditAttribution: dman commentedI'm seeing this still today, though I'd not encountered it before.
FWIW, it seems to be triggered for me when entity_type_supports() is called with entity_type 'bean'.
Which is odd, as I don't have 'bean' on my system. I did just install uuid_features and I suspect that is being messy.
However, it still would make sense to use this robust patch to clean up unexpected situations.
(When I'm lazy about undefined indexes that aren't really a problem, I sometimes just squash the notice with a @ - that works too.)
Comment #2
jenlamptonnew patch. this one applies cleanly.
Comment #3
donquixote CreditAttribution: donquixote commentedI'm using another patch locally, but this looks good too.
Main thing is to return FALSE if there is no controller class. Which this patch does.
(I did not actually test, so can't rtbc)
Comment #4
das-peter CreditAttribution: das-peter commentedComment #5
AlfTheCat CreditAttribution: AlfTheCat commentedTried the patch but no luck. It applied but didn't resolve the problem for me.