Cannot Uninstall Field Collection Module for the life of me.
I tried deleting the database tables in PHPmyadmin.
Are there any dependencies or other things I can try?

Comments

markabur’s picture

Same here. I've disabled it, but it doesn't show up on the Uninstall tab like other modules do.

Hopiu’s picture

Same here. It's not even possible to disable the module as it is

Required by: Drupal (Fields pending deletion)

But under fields collections it says:

No field collections have been defined yet. To do so attach a field collection field to any entity.

Is it safe to just delete the module from the filesystem?

danon1981’s picture

+1

kscheirer’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Component: User interface » Code
Assigned: Unassigned » kscheirer
Priority: Normal » Major

Bug confirmed - this seems pretty serious. Steps to reproduce:

  1. Fresh D7 install + field_collection-7.x-1.0-beta5+1-dev enabled
  2. Create a new content type (Article)
  3. Attach a new Field Collection (Events)
  4. Add 2 fields to the collection at /admin/structure/field-collections (Name text field, and Date integer field)
  5. Go to Modules page (/admin/modules), Field Collection checkbox is not enabled meaning the module cannot be disabled
  6. At Content types page (/admin/structure/types) delete new content type (Article)
  7. drush cc all
  8. At the modules page again, Field Collection checkbox is still not enabled meaning the module cannot be disabled

Workaround: the easiest way to uninstall this module

  1. Remove all content types that make use of field collections (cause you are about to uninstall the module).
  2. Disable the module via command line: drush sqlq "update system set status = 0 where type = 'module' and name = 'field_collection'"
  3. Field Collection will now appear on the Uninstall tab (admin/modules/uninstall) and uninstall normally.
siramsay’s picture

+1

mexicoder’s picture

To uninstall this module
Go to the module list
In field collection click the link field list
Find your fields listed as field collection and click 'delete instances'
Your module will now say fields pending deletion
Run cron
You can now disable the module then uninstall the normal way through drush or using the interface

tristanbradley’s picture

+1

puzl’s picture

Edit: Read #6. You should run cron.

markosef’s picture

I had same problem. Helped flushing cache and running cron, probably only cron was what did that. Also before that did delete content type with field collection. Too bad this module is so buggy as number of issues shows that it is highly needed.

mexicoder’s picture

Hi Guys

did you go through each of the steps in #6? The cron run is pretty important and I'd definitely recommend trying these steps before any more drastic DB actions.

m1r1k’s picture

#6 and #10 are right, you will not be able to disable or uninstall field_collection until there are any field collection items. You need to delete all field collection entries to Drupal be sure nothing will be broken (hard safe mode :) the same stuff with already used options in List fields). You can check which fields are required Field Collection here www.your-site.com/admin/reports/fields. And after you will delete fields from UI, you HAVE to run cron, because Drupal doesn't delete them after first attempt :) It just renames table (add deleted_ prefix), but 'field_config' and 'field_config_instance' tables still think these fields exist. Check here https://api.drupal.org/api/drupal/modules!field!field.crud.inc/function/... for more info.

kscheirer’s picture

davewilly’s picture

I was getting this Log message after deleting Field Collection values and fields from a Content Type:

EntityFieldQuery->addFieldCondition() (line 765 of /home/_____/public_html/includes/entity.inc).

I also couldn't delete the module:
--@-- [~/public_html/sites/all/modules]# drush dis field_collection
field_collection is a required module and can't be disabled. Reason: Fields pending deletion

I fixed it by running field_purge_batch(1000);

kopeboy’s picture

Guys, I don't have any field collection field, still I can't disable the module.

Maybe it was imported via Features from another site where I had a field collection, but know I don't have any and I don't know how to disable this module (which is giving me errors..)

If i'm sure I am not currently using any field collection, can I safely delete the module folder from the server?

Or, how can I execute "drush sqlq "update system set status = 0 where type = 'module' and name = 'field_collection'" from comment #4 if I don't have drush/terminal access on the live site?

mexicoder’s picture

@kopeboy have you done all of the steps in #6?

Wolf_22’s picture

Issue summary: View changes

So let me get this straight...

The only way to remove a module is by first removing a bunch of fields?

mexicoder’s picture

@Wolf_22 yes unfortunately everything is in #6

Anonymous’s picture

I don't have any fields and did the step as said in #6, but I still cannot disable the module. Ran cron 50 times, cc all 50 times, still nothing. To try I added field fields in field_collection and deleted again, still nothing changes.

Field report doesn't say any field as field_collection... as there is none....

This is major Bug in field_collection module. I updated to recent version as of now i.e. 1.0-beta-7 but still same issue.

Anonymous’s picture

Holy Lord, I fixed this for me.... (sorry not the bug fix)

Those who are looking for quick fix:

Log into database and ->

Select * from field_config where type = "field_collection"

Delete the rows

Same with field config instance table like

SELECT * FROM field_config_instance where entity_type = "field_collection";

Get rid of those.

No need to run cron, go to http://sitename/sites/admin/modules and disable Field Collection module. I was even able to uninstall without any issue now.

Edit: I should have been more clear here...
The steps I followed is almost exact as #6,
1.) first remove all the fields inside the Fields Collection.
2.) Then remove the field collection from the content type
3.) Run the Cron
4.) try to disable the module, if you cannot then Go ahead with my query statements above

mexicoder’s picture

I can only post this so many times, but yes there is an inherent problem with the way this module works, the safest way to uninstall this is to do each of the steps in #6 in the same order, you may have to run cron a number of times. I'd never recommend using direct queries to resolve this issue.

jmuzz’s picture

I this really a problem with Field Collections? I have used other modules that supply a field and most of them don't allow me to deactivate them when there is an instance of the field type. I think it is built into the way Drupal handles field types that are supplied by modules.

mexicoder’s picture

No jmuzz ou are right, this problem doesn't apply just to this module, there is a fix but you'd be talking about quite a lot or refactoring

jmuzz’s picture

If I understand the issue correctly it doesn't apply just to contributed modules either. If you have a node with a text field you can't deactivate the text module in core. So my question is, how is there "an inherent problem with the way this module works" ? Isn't this just how fields work?

kscheirer’s picture

Field Collection just makes the problem worse, but it isn't the root of the problem as mexicoder pointed out. People often run into this bug when trying out Field Collection and then trying to remove it.

jmuzz’s picture

How is it a bug though? I don't think you are supposed to be able to uninstall a module when it is supplying a field that is being used in a bundle.

mexicoder’s picture

@jmuzz, no there is a fix which relates to how and where the fields are controlled within the module, so it's not a bug per se but as I suggested an inherent problem with the module, i.e it works in a certain way which combines with an issue within Drupal and the way it handles fields, the fix addresses this but as I say you'd be talking about refactoring and maybe a bit of a messy upgrade path

iphan’s picture

#19 fixed it. Thank you!

mexicoder’s picture

Hi @iphan for anyone else looking for the solution I'd complete the steps in #6 before starting to use direct db queries as in #19

jmuzz’s picture

@mexicoder How is it a problem with the module? I don't think people should be able to uninstall it when it is still providing fields. That could lead to unintentional data loss. There is a reason that Drupal handles fields this way and letting users skip the steps about removing the fields the module provides before removing the module itself is dangerous.

If you create a node type with a text field, for example, you are not able to deactivate or uninstall the text module until that field no longer exists. Can anybody provide an argument for why you should be able to?

duckzland’s picture

Crude way to FORCE uninstall using drush :

drush sql-query "delete from field_config where type='field_collection';"
drush sql-query "delete from field_config_instance where entity_type='field_collection';"
drush dis field_collection
drush pm-uninstall field_collection
RAWDESK’s picture

@jmuzz,
Here's my argument, since it seems to be only way to get around this field_name constraint issue :
https://www.drupal.org/project/field_collection/issues/2498567
Surprisingly this method worked on our staging environment, but not on production, resulting in

"field_collection is a required module and can't be disabled. Reason: Field type(s) in use - see Field list"

Anybody a clue how to get around this ?

RAWDESK’s picture

So, this 6 year old hint worked for me :
https://www.drupal.org/project/field_collection/issues/1400478#comment-5...

- delete field_collection module from modules directory
- delete paragraphs module from modules directory (my case also had a field_name constraint with paragraph_item)
- add my field_name field to user entity (via UI)
- restore both removed modules

Eventually, disabling of field_collection, neither paragraphs module was required to fix
https://www.drupal.org/project/field_collection/issues/2498567

dalegrebey’s picture

Ran Cron, Cleared Cache, No Field Collections -- Still can not disable, let alone uninstall this thing.

EDIT: #19 Worked for me.

Recommend against this module.

kscheirer’s picture

Assigned: kscheirer » Unassigned
bcobin’s picture

#30 worked a treat - thank you, @duckzland!

mrs_hatch’s picture

#19 for the win! Thank you so much.

ram4nd’s picture

Status: Active » Needs work
markabur’s picture

Status: Needs work » Active

Back to "Active" as there's no patch here that needs work. Please see:

https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-...

Active
No patch is attached to the issue. This is the default state of a new issue, but may also sometimes be used for 'resetting' an issue that has gotten off-course even if the issue has old patches attached.

Needs work ["CNW"]
There is a patch attached to the issue, but the patch needs additional work before it should be reviewed. The author of the patch may indicate that it is incomplete, or the patch has gone through the reviewing process and has received feedback about areas where it needs improvement.

ram4nd’s picture

There is no patch that needs work, but there are steps that need to be made into a patch.

thomaswalther’s picture

My list of field collections is empty.
I run cron over 30 times.
I only have empty tables field_collection_item and field_collection_item_revision.
I still can not find, where the lost collections are.

So i can not delete the module.