I have a relation type name "order_customer":
source_bundles = array(
0 => 'order:*',
1 => 'customer:*',
);
Entity type "order" is defined in module "order".
Entity type "customer" is defined in module "customer".
Relation type "order_customer" is created when module "customer" is installed. After i install 2 modules, relation type "order_customer" is created and everything is ok.
But when i disable module customer. I get the error message:
Notice: Undefined index: customer in relation_views_data_alter() (line 188 of /data/www/myapp/sites/all/modules/contrib/relation/views/relation.views.inc).
When i disable module "customer", entity type "customer" is also disable, but relation type between "order" and "customer" still exists in database. So i get this error message.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | check_relation_available-1697508_v2.patch | 1.24 KB | howto |
| #1 | check_relation_available-1697508.patch | 1.22 KB | howto |
Comments
Comment #1
howto commentedUpload a patch to fix this problem.
Comment #2
howto commentedWe need to check $source_bundle is "*"
I apply new patch. Sorry for spam.
Comment #3
mikran commentedIf the relation is provided by the 'customer' module shouldn't that module also take care of disabling views and relations that were provided by said module? Changing to support request for now as I can't really catch the bug in here
Comment #4
steveoliver commentedTo #3's point:
, you'll need to implement hook_disable in your custom module. Best of luck. Changing title and marking closed.
Comment #5
zkday commentedThis module should fixed this bug!
In this case, the relation module have used and created this information (relationship from order to customer). I thinks, relation module need support for fixing this bug!
Comment #6
naught101 commentedI don't really see how this is relation's problem. If the relation was created manually, then just delete it. If it was created by the custom module, then the custom module should delete it, as per #4.
The other options would be:
Either of the last two should be possible with hook_entity_bundle_delete(), however this is D8 only, and there is no equivalent in D7, so this code would have to implement each hook_[entity]_type_delete manually, which wouldn't work for custom module's custom entity types anyway.
So zkday: I agree, relation does need support for fixing this bug. If you have any good ideas, or patches, let us know. For the moment though, I'm inclined to think that this is such an edge case that it's not worth dealing with.
Comment #7
ayalas commentedI am having this problem too.
Deleting relations in hook_disable is not a good solution, because all the module's other data remains until the module is uninstalled. So, if the module is re-enabled, we end up with all the data, just without the relations, i.e. with a corrupted data.
If there was a way to disable and enable the relation types that would have helped - and such code should indeed be in hook_enable/disable.
Comment #8
naught101 commentedInteresting idea ayalas. See discussion at #1976546: Add managed flags to relation type table
Comment #8.0
naught101 commentedFix some typo
Comment #9
mikran commentedI don't think there really is anything relation can do here, in D7 at least.
There are similar problems elsewhere too, for example taxonomy references don't get deleted when you delete taxonomy term / vocab (see https://www.drupal.org/project/taxonomy_orphanage).