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).
dd

Files: 
CommentFileSizeAuthor
#5 1511894-og-uninstall-fields-5.patch1.62 KBamitaibu
PASSED: [[SimpleTest]]: [MySQL] 875 pass(es).
[ View ]
Screenshot at 2012-04-02 13:17:43.png17.75 KBrogical

Comments

amitaibu’s picture

Version:7.x-2.0-alpha2» 7.x-2.x-dev
Status:Active» Postponed (maintainer needs more info)

Please try and report bugs only based on the -dev version.

ifish’s picture

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

TechNikh’s picture

I had the same error. Thanks to ifish
fixed by explicitly running below mysql command

delete from field_config_instance where field_name like '%og_%';
shenzhuxi’s picture

fields should be cleaned during uninstallation.

amitaibu’s picture

Title:FieldException: Attempt to create an instance of field og_membership_request» Delete on OG fields on uninstall
Status:Postponed (maintainer needs more info)» Needs review
StatusFileSize
new1.62 KB
PASSED: [[SimpleTest]]: [MySQL] 875 pass(es).
[ View ]
blkandwhtlion’s picture

I 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

amitaibu’s picture

Status:Needs review» Fixed

Committed #6

Status:Fixed» Closed (fixed)

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

Frederic wbase’s picture

Status:Closed (fixed)» Active

I 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

Frederic wbase’s picture

actions in the actions table aren't deleted also...

FreekVR’s picture

It 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)

rv0’s picture

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

SocialNicheGuru’s picture

it is present in the rc2 version too

skyredwang’s picture

Version:7.x-2.x-dev» 7.x-2.0-rc4

This is still broken

rakesh.gectcr’s picture

Thanks TechNikh

Its works for me....!

fadgadget’s picture

same error latest dev. #3 works for me

monching’s picture

Issue summary:View changes

#3 works for me, too. @TechNikh, thanks!

milos.kroulik’s picture

I can also confirm, that fix mentioned in #3 still works on latest dev version. Also, you can safely use it for PostgreSQL installations.

graker’s picture

Guys! 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\_%';

shushu’s picture

Version:7.x-2.0-rc4» 7.x-2.x-dev
Status:Active» Postponed (maintainer needs more info)

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

NancyDru’s picture

I 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