Closed (fixed)
Project:
Corresponding Entity References
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Sep 2014 at 12:42 UTC
Updated:
9 Nov 2017 at 19:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
anouI have the same problem.
To solve temporary the issue, you can just remove "array" from line 81
function cer_field_delete_instance( array $instance )in cer.module. Then re-try to uninstall comment module, should work this time.Comment #2
corentin.crouvisier commentedI have the same error message uninstalling commerce discount.
Comment #3
miroslavbanov commentedhook_field_delete_instance is not documented unfortunately:
https://api.drupal.org/api/drupal/modules!field!field.api.php/function/h...
The only implementation in core doesn't have array typehint:
https://api.drupal.org/api/drupal/modules!image!image.module/function/im...
I guess it is best to remove the array typehint?
Comment #4
nwom commentedI have the same problem when attempting to uninstall Entity E-mail. #1 works perfectly as a workaround.
Comment #5
nwom commentedI ran into the same problem again when attempting to uninstall the core Comment module.
Comment #6
aaronbaumanHere's the quick-and-dirty patch i used to get around this annoyance.
Comment #7
miroslavbanov commentedI don't think this is quick-and-dirty. I think in cer module it was wrong to typehint this parameter in the first place. Drupal core doesn't typehint.
Also I tested it with and without the patch, and I am marking it RTBC.
Comment #8
phenaproximaI'm sorry, but I'm not sure I agree that it was wrong to type hint the parameter. Just because the hook definition didn't specify a type hint doesn't mean it shouldn't. Type hinting is one of the best ways to detect bad input in a function. Doing an is_array() check, and a silent return, is functionally equivalent to type hinting.
Before I can commit this, I think the question we need to answer is why in the world $instance would not be an array. What are the circumstances under which this would happen? Could it be a core bug? Some sort of corrupted configuration in the site? A conflict with another module?
Comment #9
phenaproximaWhoops, meant to mark this NR.
Comment #10
miroslavbanov commentedJust to clarify about this issue. You can easily reproduce it with just CER and Comment modules. You can install only CER from http://simplytest.me/ no other dependencies are needed. Then disable Comment. Then uninstall Comment. There will be a fatal error.
Could something else be wrong somewhere? Quite possibly - yes. But to me, it isn't worth it to investigate.
Comment #11
phenaproximaIMHO, something like this is definitely worth the time to reproduce and trace. The hook in question is practically undocumented, but as far as I can tell, it should always receive a field instance definition. The fact that it's not is troublesome.
Comment #12
joelpittetThis fixed comment module not being able to uninstall. You could fix core, but no other module is type hinting that to array. But the return value of
field_info_instance()can benulland is passed it's value directly tofield_delete_instance()inmessage_subscribemodule, same withmessage_notifyin it's uninstall and in corefield_ui_field_delete_form_submit. So you can't expect it to be an array from many different angles.Comment #14
phenaproximaI'm convinced. Committed and pushed.
Comment #15
joelpittet@phenaproxima thanks for considering the patch carefully and championing type hints, it would be nice to see more:)