Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
FieldException: Attempt to create an instance of field og_membership_request on bundle og_membership_type_default that already has an instance of that field. in field_create_instance() (line 490 of /opt/development/test/modules/field/field.crud.inc).
Comment | File | Size | Author |
---|---|---|---|
#5 | 1511894-og-uninstall-fields-5.patch | 1.62 KB | amitaibu |
Screenshot at 2012-04-02 13:17:43.png | 17.75 KB | rogical |
Comments
Comment #1
amitaibuPlease try and report bugs only based on the -dev version.
Comment #2
ifish CreditAttribution: ifish commentedI had the same problem, but since I'm not the tech guy, I'm gonna try to explain how I fixed it..
Basically I unintalled OG 7.x-2.0-alpha2 all modules, and then if trying to reinstall "OG" Module, it gave me this error.
I fixed it by going to "field_config_instance" and deleted 3 OG fields there:
og_membership_request
og_group_ref_other_groups
og_group_ref
So I guess the module uninstall didn't uninstall these from the mysql. Anyways if doing it manually, i was able to install OG successfully.
Comment #3
TechNikh CreditAttribution: TechNikh commentedI had the same error. Thanks to ifish
fixed by explicitly running below mysql command
Comment #4
shenzhuxi CreditAttribution: shenzhuxi commentedfields should be cleaned during uninstallation.
Comment #5
amitaibuComment #6
blkandwhtlion CreditAttribution: blkandwhtlion commentedI to had the same problem, but using the dev. I uninstalled to re-install it thinking it would fix a problem I was having (it did). Using TechNikh sql statement worked like a charm. Many thanks to TechNikh and ifish
Comment #7
amitaibuCommitted #6
Comment #9
Frederic wbase CreditAttribution: Frederic wbase commentedI would like to reopen this issue.
In the latest dev of 29 october 2012 the field instance of og membership is not deleted on uninstall. This gives on error message when you try to reinstall og module.
Let me know if you need more information.
grts
Frederic wbase
Comment #10
Frederic wbase CreditAttribution: Frederic wbase commentedactions in the actions table aren't deleted also...
Comment #11
FreekVR CreditAttribution: FreekVR commentedIt seems that the code commited in #5 no longer works. I am getting the error posted by the OP on install, and the following on uninstall:
Notice: Undefined index: field_name in og_uninstall() (line 67 of sites/all/modules/contrib/og/og.install).
Notice: Undefined index: field_name in og_uninstall() (line 71 of sites/all/modules/contrib/og/og.install).
Thus, it appears fields arent being deleted on uninstall at all, which is causing issues on reinstalls as the install scripts don't check whether these fields exist already (it assumes the above field_delete_instance functions were called)
Comment #12
rv0 CreditAttribution: rv0 commentedI can confirm that the bug is still present in latest dev
FieldException: Attempt to create an instance of field og_membership_request on bundle og_membership_type_default that already has an instance of that field. in field_create_instance() (line 490 of field.crud.inc).
Comment #13
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedit is present in the rc2 version too
Comment #14
skyredwangThis is still broken
Comment #15
rakesh.gectcrThanks TechNikh
Its works for me....!
Comment #16
fadgadget CreditAttribution: fadgadget commentedsame error latest dev. #3 works for me
Comment #17
monching CreditAttribution: monching commented#3 works for me, too. @TechNikh, thanks!
Comment #18
milos.kroulik CreditAttribution: milos.kroulik commentedI can also confirm, that fix mentioned in #3 still works on latest dev version. Also, you can safely use it for PostgreSQL installations.
Comment #19
graker CreditAttribution: graker commentedGuys! As much as direct DB query could be a quick fix, please, be VERY cautious about using query from #3:
delete from field_config_instance where field_name like '%og_%';
The point is that the underscore symbol in SQL is actually a placeholder for one symbol. Thus '%og_%' means 'any string containing "og" with at least one (any!) symbol after'. So by running this query as is you risk loosing other, non-OG fields containing "og" symbols, like field_geography, field_blogs or field_ogre for example.
So if you are going to use the query, you should escape the underscore:
delete from field_config_instance where field_name like '%og\_%';
Comment #20
shushu CreditAttribution: shushu commentedCertainly executing direct db_query() can cause such outcomes.
Regarding to the original issue - I failed to reproduce it, and code-wise I don't see how it happens (sure, in every bug you don't see how it can happen till you see it...).
If someone has clear reproduction scenario on 7.x-2.x-dev, please describe it.
Comment #21
NancyDruI am definitely seeing this on 7.x-2.7. I don't know if OG had been installed before.
I would think one could reproduce by installing, uninstalling, and then trying to re-install
Comment #23
argiepiano CreditAttribution: argiepiano as a volunteer commentedThis is still an issue in 2022, version 7.x-2.10 of OG.
It's easy to reproduce:
1. Enable og and og_ui
2. Create a group content type and a group content content type
3. Add a group and some content
4. Disable og and og_ui
5. UNINSTALL og and og_ui
6. Reinstall og
Voila.
FieldException: Attempt to create an instance of field og_membership_request on bundle og_membership_type_default that already has an instance of that field
.The problem is that og_uninstall() relies on field_info_instances() to remove instances. By this point, the entity `og_membership` has been removed, and therefore field_info_instances() doesn't include it in the lists of entities with field instances. Thus the instance of field og_membership_request never gets removed. It remains in field_config_instances, and its table `field_data_og_membership_request` remains in the database.