I have set up a Site with CER in multiple node types.

Then i disabled the comment module.
When trying to uninstall the comment module, i get the followin error:

Recoverable fatal error: Argument 1 passed to cer_field_delete_instance() must be an array, null given in cer_field_delete_instance() (line 81 of [mysite]\sites\all\modules\cer\cer.module).

Comments

anou’s picture

I have the same problem.
To solve temporary the issue, you can just remove "array" from line 81function cer_field_delete_instance( array $instance ) in cer.module. Then re-try to uninstall comment module, should work this time.

corentin.crouvisier’s picture

I have the same error message uninstalling commerce discount.

miroslavbanov’s picture

hook_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?

nwom’s picture

I have the same problem when attempting to uninstall Entity E-mail. #1 works perfectly as a workaround.

nwom’s picture

I ran into the same problem again when attempting to uninstall the core Comment module.

aaronbauman’s picture

Status: Active » Needs review
StatusFileSize
new533 bytes

Here's the quick-and-dirty patch i used to get around this annoyance.

miroslavbanov’s picture

Status: Needs review » Reviewed & tested by the community

I 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.

phenaproxima’s picture

Status: Reviewed & tested by the community » Needs work

I'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?

phenaproxima’s picture

Status: Needs work » Needs review

Whoops, meant to mark this NR.

miroslavbanov’s picture

Just 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.

phenaproxima’s picture

IMHO, 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.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

This 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 be null and is passed it's value directly to field_delete_instance() in message_subscribe module, same with message_notify in it's uninstall and in core field_ui_field_delete_form_submit. So you can't expect it to be an array from many different angles.

  • aaronbauman authored 68eebcf on 7.x-3.x
    Issue #2344169 by aaronbauman, MiroslavBanov, phenaproxima: fatal error...
phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed

I'm convinced. Committed and pushed.

joelpittet’s picture

@phenaproxima thanks for considering the patch carefully and championing type hints, it would be nice to see more:)

Status: Fixed » Closed (fixed)

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